maps_regeocode
Convert geographic coordinates into readable address information by translating latitude and longitude into administrative division details and street addresses.
Instructions
将一个高德经纬度坐标转换为行政区划地址信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes | 经纬度 |
Implementation Reference
- build/index.js:261-292 (handler)Handler function that executes the maps_regeocode tool: calls Amap reverse geocoding API with location, parses response to extract province, city, district.async function handleReGeocode(location) { const url = new URL("https://restapi.amap.com/v3/geocode/regeo"); url.searchParams.append("location", location); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("source", "ts_mcp"); const response = await fetch(url.toString()); const data = await response.json(); if (data.status !== "1") { return { content: [{ type: "text", text: `RGeocoding failed: ${data.info || data.infocode}`, }], isError: true, }; } return { content: [{ type: "text", text: JSON.stringify( { provice: data.regeocode.addressComponent.province, city: data.regeocode.addressComponent.city, district: data.regeocode.addressComponent.district, }, null, 2, ), }], isError: false, }; }
- build/index.js:18-31 (schema)Tool schema definition including name, description, and input schema requiring 'location' string.const REGEOCODE_TOOL = { name: "maps_regeocode", description: "将一个高德经纬度坐标转换为行政区划地址信息", inputSchema: { type: "object", properties: { location: { type: "string", description: "经纬度", }, }, required: ["location"], }, };
- build/index.js:854-857 (registration)Registration in the tool call switch statement dispatching to handleReGeocode.case "maps_regeocode": { const { location } = request.params.arguments; return await handleReGeocode(location); }
- build/streamable-http.js:20-55 (handler)Handler function that executes the maps_regeocode tool in the HTTP server version: calls Amap reverse geocoding API.async function handleReGeocode(location) { const AMAP_MAPS_API_KEY = getApiKey(); const url = new URL("https://restapi.amap.com/v3/geocode/regeo"); url.searchParams.append("location", location); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("source", "ts_mcp"); const response = await fetch(url.toString()); const data = await response.json(); if (data.status !== "1") { return { content: [ { type: "text", text: `RGeocoding failed: ${data.info || data.infocode}`, }, ], isError: true, }; } return { content: [ { type: "text", text: JSON.stringify( { provice: data.regeocode.addressComponent.province, city: data.regeocode.addressComponent.city, district: data.regeocode.addressComponent.district, }, null, 2, ), }, ], isError: false, };
- build/streamable-http.js:663-675 (schema)Tool schema definition including name, description, and input schema requiring 'location' string in HTTP server.name: "maps_regeocode", description: "将一个高德经纬度坐标转换为行政区划地址信息", inputSchema: { type: "object", properties: { location: { type: "string", description: "经纬度", }, }, required: ["location"], }, };