Skip to main content
Glama

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchQueryYes
languageNoen
categoryNo
phoneNo
addressNo
latLongNo

Implementation Reference

  • 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)
  • Registers the 'search_locations' tool with the FastMCP server using the decorator.
    @mcp.tool(description="Search for locations (hotels, restaurants, attractions) on Tripadvisor")
  • 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()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pab1it0/tripadvisor-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server