get_location_photos
Retrieve photos for a specific location to visualize destinations and plan trips using Tripadvisor data.
Instructions
Get photos for a specific location
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| locationId | Yes | ||
| language | No | en |
Implementation Reference
- src/tripadvisor_mcp/server.py:148-166 (handler)The handler function that implements the get_location_photos tool by making an API request to the Tripadvisor photos endpoint for the given location ID.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)
- src/tripadvisor_mcp/server.py:147-147 (registration)The @mcp.tool decorator that registers the get_location_photos function as an MCP tool with its description.@mcp.tool(description="Get photos for a specific location")
- src/tripadvisor_mcp/server.py:24-42 (helper)Helper function used by get_location_photos to perform the HTTP request to the Tripadvisor 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()