get_elevation
Retrieve elevation data for specific geographic coordinates to analyze terrain height above sea level.
Instructions
Get elevation data for locations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| locations | Yes | List of locations to get elevation data for |
Implementation Reference
- src/services/places.ts:333-360 (handler)The core handler function that fetches elevation data for given locations using the Google Maps Elevation API client.async getElevation( locations: Array<{ latitude: number; longitude: number }> ): Promise<ServiceResponse<ElevationResult[]>> { try { const locations_array = locations.map((loc) => { validateCoordinates(loc.latitude, loc.longitude); return { lat: loc.latitude, lng: loc.longitude }; }); const response = await this.client.elevation({ params: { key: config.googleMapsApiKey, locations: locations_array, }, }); return { success: true, data: response.data.results.map((result) => ({ elevation: result.elevation, location: result.location, resolution: result.resolution, })), }; } catch (error) { return handleError(error); } }
- src/mcp/create-server.ts:240-273 (registration)MCP tool registration for 'get_elevation', including input schema and a thin async handler that calls the PlacesSearcher service.server.registerTool( "get_elevation", { title: "Get Elevation", description: "Get elevation data for locations", inputSchema: ElevationSchema, }, async (args) => { try { const result = await placesSearcher.getElevation( args.locations ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) }, ], isError: !result.success, }; } catch (error) { const errorResponse = handleError(error); return { content: [ { type: "text", text: errorResponse.error || "An unknown error occurred", }, ], isError: true, }; } } );
- src/schemas/tool-schemas.ts:43-48 (schema)Zod input schema defining the expected structure for locations array in get_elevation tool.export const ElevationSchema = { locations: z.array(z.object({ latitude: z.number(), longitude: z.number() })).describe("List of locations to get elevation data for") };