Skip to main content
Glama
hhw67865

TripAdvisor Vacation Planner MCP Server

by hhw67865

get_nearby_locations

Find nearby hotels, restaurants, or attractions based on specific latitude and longitude coordinates to enhance vacation planning with TripAdvisor data.

Instructions

Find locations near a specific latitude and longitude Args: latitude: Latitude coordinate longitude: Longitude coordinate category: Optional category filter (e.g., "hotels", "restaurants", "attractions")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNo
latitudeYes
longitudeYes

Implementation Reference

  • The handler function for the 'get_nearby_locations' tool, decorated with @mcp.tool() for registration. It constructs API parameters and calls the TripAdvisor nearby_search endpoint to retrieve nearby locations.
    @mcp.tool() async def get_nearby_locations(latitude: float, longitude: float, category: Optional[str] = None) -> str: """ Find locations near a specific latitude and longitude Args: latitude: Latitude coordinate longitude: Longitude coordinate category: Optional category filter (e.g., "hotels", "restaurants", "attractions") """ params = {"latLong": f"{latitude},{longitude}"} if category: params["category"] = category result = await tripadvisor_api_request("location/nearby_search", params) return json.dumps(result, indent=2)
  • Helper function that performs HTTP requests to the TripAdvisor API, handling authentication, errors, and JSON responses. Used by the get_nearby_locations tool.
    async def tripadvisor_api_request(endpoint: str, params: Dict[str, Any] = None) -> Dict[str, Any]: """Make a request to the TripAdvisor API""" if not TRIPADVISOR_API_KEY: return {"error": "TripAdvisor API key not configured. Set TRIPADVISOR_API_KEY environment variable."} headers = {"accept": "application/json", "key": TRIPADVISOR_API_KEY} if params is None: params = {} params["key"] = TRIPADVISOR_API_KEY url = f"{API_BASE_URL}/{endpoint}" async with httpx.AsyncClient() as client: try: response = await client.get(url, headers=headers, params=params, timeout=30.0) response.raise_for_status() return response.json() except httpx.HTTPStatusError as e: return { "error": f"HTTP error occurred: {e}", "details": str(e) } #Resources for specific location details

Other Tools

Related Tools

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/hhw67865/tripadvisor-mcp-server'

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