maps_geo
Convert structured addresses and landmark names into precise latitude and longitude coordinates for location-based services and geographic data applications.
Instructions
将详细的结构化地址转换为经纬度坐标。支持对地标性名胜景区、建筑物名称解析为经纬度坐标
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | 待解析的结构化地址信息 | |
| city | No | 指定查询的城市 |
Implementation Reference
- build/index.js:293-337 (handler)Implements the maps_geo tool: converts structured address to latitude/longitude coordinates using Amap Geocoding API.async function handleGeo(address, city, sig) { const url = new URL("https://restapi.amap.com/v3/geocode/geo"); url.searchParams.append("key", AMAP_MAPS_API_KEY); url.searchParams.append("address", address); 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: `Geocoding failed: ${data.info || data.infocode}`, }], isError: true, }; } const geocodes = data.geocodes || []; const res = geocodes.length > 0 ? geocodes.map((geo) => ({ country: geo.country, province: geo.province, city: geo.city, citycode: geo.citycode, district: geo.district, street: geo.street, number: geo.number, adcode: geo.adcode, location: geo.location, level: geo.level, })) : []; return { content: [{ type: "text", text: JSON.stringify( { return: res, }, null, 2, ), }], isError: false, }; }
- build/index.js:32-50 (schema)Defines the input schema and metadata for the maps_geo tool.const GEO_TOOL = { name: "maps_geo", description: "将详细的结构化地址转换为经纬度坐标。支持对地标性名胜景区、建筑物名称解析为经纬度坐标", inputSchema: { type: "object", properties: { address: { type: "string", description: "待解析的结构化地址信息", }, city: { type: "string", description: "指定查询的城市", }, }, required: ["address"], }, };
- build/index.js:858-861 (registration)Dispatches calls to the maps_geo handler in the tool execution switch statement.case "maps_geo": { const { address, city } = request.params.arguments; return await handleGeo(address, city); }
- build/index.js:848-850 (registration)Registers the tool list including maps_geo for the ListTools request.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: MAPS_TOOLS, }));