Skip to main content
Glama
pab1it0

Tripadvisor MCP

get_location_photos

Retrieve photos for a specific Tripadvisor location to visualize destinations before visiting or planning trips.

Instructions

Get photos for a specific location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationIdYes
languageNoen

Implementation Reference

  • The main asynchronous handler function for the 'get_location_photos' tool. It is registered via the @mcp.tool decorator and fetches photos from the Tripadvisor API for a given location ID.
    @mcp.tool(description="Get photos for a specific location")
    async def get_location_photos(
        locationId: Union[str, int],
        language: str = "en",
    ) -> Dict[str, Any]:
        """
        Get high-quality photos for a specific location.
        
        Parameters:
        - locationId: Tripadvisor location ID (can be string or integer)
        - language: Language code (default: 'en')
        """
        params = {
            "language": language,
        }
        
        # Convert locationId to string to ensure compatibility
        location_id_str = str(locationId)
        
        return await make_api_request(f"location/{location_id_str}/photos", params)
  • Helper utility function used by the get_location_photos handler (and other tools) to perform 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()

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