find-place
Convert location queries into precise coordinates for hotel searches. Accepts city names, landmarks, or hotel descriptions and returns standardized place information with latitude and longitude.
Instructions
Use this tool to convert a user's location query into standardized place information with coordinates. This is essential when you need latitude and longitude for hotel searches but only have a text description. The tool accepts city names, hotel names, landmarks, or other location identifiers and returns a list of matching places with their details and precise coordinates.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| language | No | Language for the place search | en |
| query | Yes | User's input for place search |
Implementation Reference
- The 'autocompletePlaces' function is the core handler for the 'find-place' tool. It sends the user's query to a places autocomplete API, processes the results into structured place summaries with latitude/longitude coordinates, and returns a YAML-formatted response.export async function autocompletePlaces(params: { query: string; language?: string }) { // Make API request to get place suggestions const request = { "input": params.query, "language": "en", }; if (params.language) { request.language = params.language; } const autocompleteResult = await makeApiRequest<any>( "/api/v1/hotels/places/autocomplete", "POST", request, ); if (!autocompleteResult) { return createYamlResponse({ status: "error", message: "Failed to retrieve place suggestions. Please try again with a different query." }); } if (!autocompleteResult.predictions || autocompleteResult.predictions.length === 0) { return createYamlResponse({ status: "empty", message: "No places found matching your query. Please try a different search term." }); } // Format results for YAML response const placeSummaries = autocompleteResult.predictions.map((place: PlaceSuggestion, index: number) => ({ id: place.place_id, name: place.structured_formatting?.main_text || place.description, type: place.types || "Unknown", location: place.description || "", latitude: place.latitude, longitude: place.longitude, })); const response: PlaceSummaryResponse = { places: placeSummaries, count: autocompleteResult.predictions.length, message: "Found matching locations based on your search. Each result includes location coordinates that can be used with the search-hotels tool. If multiple locations match your query, please help the user select the most appropriate one based on their travel plans." }; return createYamlResponse(response); }
- src/hotel-mcp/server/standard.ts:48-60 (registration)Registers the 'find-place' tool with the MCP server, providing a detailed description, Zod input schema for 'query' and optional 'language', and the telemetry-instrumented 'autocompletePlaces' handler function.server.tool( "find-place", `Use this tool to convert a user's location query into standardized place information with coordinates. This is essential when you need latitude and longitude for hotel searches but only have a text description. The tool accepts city names, hotel names, landmarks, or other location identifiers and returns a list of matching places with their details and precise coordinates. `, { query: z.string().describe("User's input for place search"), language: z.string().optional().default("en").describe("Language for the place search"), }, getTelemetry().telemetryMiddleware.instrumentTool("find-place", autocompletePlaces) );
- Zod schema defining the input parameters for the 'find-place' tool: required 'query' string and optional 'language' string defaulting to 'en'.query: z.string().describe("User's input for place search"), language: z.string().optional().default("en").describe("Language for the place search"), },