Skip to main content
Glama

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
NameRequiredDescriptionDefault
locationsYesList of locations to get elevation data for

Implementation Reference

  • 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); } }
  • 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, }; } } );
  • 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") };

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/BACH-AI-Tools/MCP-Google-Maps'

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