search_nearby_locations
Find nearby attractions, restaurants, and points of interest using latitude and longitude coordinates to discover local destinations.
Instructions
Search for locations near a specific latitude/longitude
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| latitude | Yes | ||
| longitude | Yes | ||
| language | No | en | |
| category | No |
Implementation Reference
- src/tripadvisor_mcp/server.py:79-103 (handler)The handler function for the 'search_nearby_locations' tool. It formats the latLong parameter and calls the Tripadvisor API's location/search endpoint via make_api_request. The @mcp.tool decorator registers the tool and defines its schema from the function signature and description.@mcp.tool(description="Search for locations near a specific latitude/longitude") async def search_nearby_locations( latitude: float, longitude: float, language: str = "en", category: Optional[str] = None, ) -> Dict[str, Any]: """ Search for locations near a specific latitude/longitude. Parameters: - latitude: Latitude coordinate - longitude: Longitude coordinate - language: Language code (default: 'en') - category: Optional category filter ('hotels', 'attractions', 'restaurants') """ params = { "latLong": f"{latitude},{longitude}", "language": language, } if category: params["category"] = category return await make_api_request("location/search", params)
- src/tripadvisor_mcp/server.py:24-42 (helper)Shared utility function that handles authenticated HTTP requests to the Tripadvisor Content API, adding the API key and handling responses. Used by search_nearby_locations to fetch nearby locations.async def make_api_request(endpoint: str, params: Dict[str, Any] = None) -> Dict[str, Any]: """Make a request to the Tripadvisor Content API""" if not config.api_key: raise ValueError("Tripadvisor API key is missing. Please set TRIPADVISOR_API_KEY environment variable.") url = f"{config.base_url}/{endpoint}" headers = { "accept": "application/json" } if params is None: params = {} params["key"] = config.api_key async with httpx.AsyncClient() as client: response = await client.get(url, headers=headers, params=params) response.raise_for_status() return response.json()