maps_regeocode
Convert latitude-longitude coordinates into readable address information using AMap's reverse geocoding service to identify administrative divisions and locations.
Instructions
将一个高德经纬度坐标转换为行政区划地址信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes | 经纬度 |
Implementation Reference
- build/index.js:261-292 (handler)Handler function that performs reverse geocoding by calling the AMap regeocode API with the given location (longitude,latitude), extracts province, city, district and returns them as JSON.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)Schema definition for the maps_regeocode tool, specifying input as an object with required 'location' string (coordinates).const REGEOCODE_TOOL = { name: "maps_regeocode", description: "将一个高德经纬度坐标转换为行政区划地址信息", inputSchema: { type: "object", properties: { location: { type: "string", description: "经纬度", }, }, required: ["location"], }, };
- build/index.js:854-857 (registration)Registration of the maps_regeocode handler in the CallToolRequestHandler switch statement.case "maps_regeocode": { const { location } = request.params.arguments; return await handleReGeocode(location); }
- build/index.js:848-850 (registration)Registration of tool list handler which includes the maps_regeocode schema via MAPS_TOOLS array.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: MAPS_TOOLS, }));