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 main handler function for the 'search_nearby_locations' tool. It constructs parameters with latLong and category, then calls the make_api_request helper to fetch data from Tripadvisor's location/search endpoint.@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)Helper function used by search_nearby_locations (and other tools) to make authenticated HTTP GET requests to the Tripadvisor Content API.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()