cities_by_coordinates_closest
Find the nearest cities to any geographic coordinates, sorted by distance. Specify latitude and longitude to get a ranked list of nearby cities.
Instructions
Find cities nearest to given coordinates, ordered by distance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | Latitude | |
| lon | Yes | Longitude | |
| preferredLanguages | No | Comma-separated BCP 47 language tags |
Implementation Reference
- src/server.ts:74-78 (schema)Input schema for the cities_by_coordinates_closest tool: lat (number), lon (number), and optional preferredLanguages string.
{ lat: z.number().describe('Latitude'), lon: z.number().describe('Longitude'), preferredLanguages: z.string().optional().describe('Comma-separated BCP 47 language tags'), }, - src/server.ts:79-83 (handler)Handler function that calls client.cities.byCoordinatesClosest(params) and returns the JSON result.
async (params) => { const result = await client.cities.byCoordinatesClosest(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }, ); - src/server.ts:71-83 (registration)Registers the 'cities_by_coordinates_closest' tool via server.tool() with its description, schema, and handler.
server.tool( 'cities_by_coordinates_closest', 'Find cities nearest to given coordinates, ordered by distance.', { lat: z.number().describe('Latitude'), lon: z.number().describe('Longitude'), preferredLanguages: z.string().optional().describe('Comma-separated BCP 47 language tags'), }, async (params) => { const result = await client.cities.byCoordinatesClosest(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }, ); - src/server.ts:222-224 (helper)Reuses client.cities.byCoordinatesClosest inside the 'find_cities_near_city' compound tool when mode is 'closest'.
const nearby = mode === 'largest' ? await client.cities.byCoordinatesLargest(params) : await client.cities.byCoordinatesClosest(params);