search_locations
Find hotels, restaurants, and attractions on Tripadvisor by searching with keywords, categories, addresses, or coordinates.
Instructions
Search for locations (hotels, restaurants, attractions) on Tripadvisor
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"searchQuery": "<searchQuery>"
},
"name": "search_locations"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| searchQuery | Yes | ||
| language | No | en | |
| category | No | ||
| phone | No | ||
| address | No | ||
| latLong | No |
Implementation Reference
- src/tripadvisor_mcp/server.py:44-77 (handler)The main handler function implementing the logic for the 'search_locations' tool by preparing parameters and calling the Tripadvisor API endpoint.
async def search_locations( searchQuery: str, language: str = "en", category: Optional[str] = None, phone: Optional[str] = None, address: Optional[str] = None, latLong: Optional[str] = None, ) -> Dict[str, Any]: """ Search for locations on Tripadvisor. Parameters: - searchQuery: The text to search for - language: Language code (default: 'en') - category: Optional category filter ('hotels', 'attractions', 'restaurants', 'geos') - phone: Optional phone number to search for - address: Optional address to search for - latLong: Optional latitude,longitude coordinates (e.g., '42.3455,-71.0983') """ params = { "searchQuery": searchQuery, "language": language, } if category: params["category"] = category if phone: params["phone"] = phone if address: params["address"] = address if latLong: params["latLong"] = latLong return await make_api_request("location/search", params) - src/tripadvisor_mcp/server.py:43-43 (registration)Registers the 'search_locations' tool with the FastMCP server using the decorator.
@mcp.tool(description="Search for locations (hotels, restaurants, attractions) on Tripadvisor") - src/tripadvisor_mcp/server.py:24-42 (helper)Supporting helper function used by the tool to perform authenticated HTTP 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()