Skip to main content
Glama
masx200

AMap Maps MCP Server

by masx200

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
NameRequiredDescriptionDefault
addressYes待解析的结构化地址信息
cityNo指定查询的城市

Implementation Reference

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

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/masx200/amap-maps-mcp-server'

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