maps_elevation
Retrieve elevation data for specific geographic coordinates using Google Maps API integration on the MCP Google Map Server. Input latitude and longitude to access precise altitude information for multiple locations.
Instructions
獲取位置的海拔數據
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| locations | Yes | 要獲取海拔數據的位置列表 |
Implementation Reference
- src/tools/maps/elevation.ts:17-47 (handler)The ACTION function that executes the maps_elevation tool: creates PlacesSearcher with API key, fetches elevation data for locations, handles errors, and returns formatted JSON response.async function ACTION(params: any): Promise<{ content: any[]; isError?: boolean }> { try { // Create a new PlacesSearcher instance with the current request's API key const apiKey = getCurrentApiKey(); const placesSearcher = new PlacesSearcher(apiKey); const result = await placesSearcher.getElevation(params.locations); if (!result.success) { return { content: [{ type: "text", text: result.error || "Failed to get elevation data" }], isError: true, }; } return { content: [ { type: "text", text: JSON.stringify(result.data, null, 2), }, ], isError: false, }; } catch (error: any) { const errorMessage = error instanceof Error ? error.message : JSON.stringify(error); return { isError: true, content: [{ type: "text", text: `Error getting elevation data: ${errorMessage}` }], }; } }
- src/tools/maps/elevation.ts:8-13 (schema)Zod schema defining the input parameters: array of {latitude, longitude} objects for locations.const SCHEMA = { locations: z.array(z.object({ latitude: z.number().describe("Latitude coordinate"), longitude: z.number().describe("Longitude coordinate"), })).describe("List of locations to get elevation data for"), };
- src/config.ts:59-64 (registration)Registers the maps_elevation tool (imported as Elevation from ./tools/maps/elevation.js) in the server tools configuration passed to BaseMcpServer.{ name: Elevation.NAME, description: Elevation.DESCRIPTION, schema: Elevation.SCHEMA, action: (params: ElevationParams) => Elevation.ACTION(params), },