amap-location-mcp
This server provides read-only access to Amap (Gaode) location services, enabling AI assistants to:
Resolve addresses/POIs to real GCJ-02 coordinates with city disambiguation and optional proximity sorting.
Reverse geocode coordinates (GCJ-02 or WGS84) into structured addresses and nearby POIs, explicitly labeling coordinate sources.
Search nearby POIs by radius, keywords, or Amap type codes, returning distances.
Plan and compare routes for walking, driving, and transit, returning distance, duration, steps, and a recommended mode.
Plan a single-mode route between two coordinates (walking, driving, or transit).
Convert coordinates from WGS84/GPS, Baidu, or Mapbar to GCJ-02.
Coarse-locate public IPv4 addresses to province/city level.
Build a combined location context for AI models by integrating address resolution, reverse geocoding, and nearby POI search.
Maintain trust boundaries: never fakes device GPS; always marks device location only when explicitly provided via
coordinate_source: device_gps.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@amap-location-mcp how to get from Beijing South Station to the Forbidden City?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
amap-location-mcp
一个基于高德开放平台 Web 服务 API 的只读 MCP Server。它的主要用途是让 AstrBot、RikkaHub 等 AI 客户端回答“从这里怎么回家”“从北京南站到故宫怎么走”这类问题:输入起点和终点,自动解析真实高德地点,同时比较步行、驾车和公交,给出距离、预计耗时、关键步骤和推荐交通方式。
它参考了 SHowGS/SillyTavern-RealMap 的“真实地点 + 周边环境 + 路线 + 位置来源”思路,但代码为独立实现,没有复制该项目源码。
优先考虑高德官方 MCP
高德开放平台现已提供官方 MCP Server。对 Cherry Studio、RikkaHub、Cursor、AstrBot 等支持 Streamable HTTP 的客户端,建议优先直连官方服务;官方当前提供 POI 搜索、地理编码、驾车/公交/步行/骑行、距离、天气、导航与打车链接等完整工具:
{
"mcpServers": {
"AmapOfficial": {
"url": "https://mcp.amap.com/mcp?key=你的高德Web服务Key"
}
}
}申请 Key 时仍需在高德开放平台控制台选择“Web 服务”。官方接入说明见快速接入高德地图 MCP Server。Key 位于 URL 查询参数中,请只保存到私有客户端配置,不要提交到 Git。
本仓库继续保留,适合需要以下能力的场景:只向模型暴露一个综合路线工具以减少上下文、在服务端统一 Bearer 鉴权、控制字段裁剪,或自行托管兼容入口。地点容易重名时,无论使用官方还是本项目,都建议给助手加入 navigation-guard-prompt.example.txt 中的约束。
Related MCP server: MCP Location Server
定位边界
可以把地址/POI 解析为高德真实 GCJ-02 坐标。
可以把调用方主动提供的 WGS84/GPS 坐标转换为 GCJ-02,再查询地址和周边 POI。
可以对明确传入的公网 IPv4 做省市级粗定位。
不能自行读取电脑、手机或浏览器的 GPS。要获得设备实况位置,需要前端在用户授权后把坐标传给 MCP,并设置
coordinate_source: "device_gps"。不会把 POI 推测、IP 出口或 MCP 服务器位置伪装成用户的设备定位。
每次成功结果都包含:
{
"source": "amap_reverse_geocode",
"coordinate_system": "GCJ-02",
"precision": "point_of_interest",
"confidence": 0.9,
"is_device_location": false,
"observed_at": "...",
"warnings": []
}工具
工具 | 用途 |
| 主要入口:输入起点、终点地址或地点,同时查询步行、驾车、公交并推荐交通方式 |
| 地点/地址解析、候选排序和城市消歧 |
| GCJ-02/WGS84 坐标转结构化地址和附近 POI |
| 按半径、关键词或 POI 类型搜索周边 |
| WGS84、百度、Mapbar 坐标转高德 GCJ-02 |
| 定位明确传入的 IPv4,结果仅为省市级粗定位 |
| 步行、驾车、公交路线规划 |
| 一次组合地点解析、地址和周边证据,供 AI 直接使用 |
面向 AstrBot/RikkaHub 的导航专用部署建议设置 MCP_TOOL_PROFILE=directions。该模式只向客户端暴露 amap_get_directions,其余能力仍由这个综合工具在服务端内部完成,避免 8 份工具定义长期占用模型上下文。
密钥要求
本项目不会提供或内置高德 Key。使用前必须访问高德地图开放平台,登录后进入控制台创建应用并申请 API Key:
服务平台:
Web服务
下面两种凭证不能用于本项目:
Web端(JS API)KeysecurityJsCode / 安全密钥
密钥只从环境变量 AMAP_WEB_SERVICE_KEY 读取,不写入源码或配置模板。JS API 凭证不应放入 .env。
最简单的调用方式
通常只需要让 AI 调用 amap_get_directions:
{
"origin": "北京南站",
"destination": "故宫博物院",
"origin_city": "北京",
"destination_city": "北京",
"modes": ["walking", "driving", "transit"]
}返回内容包括:
起点和终点实际匹配到的高德 POI、地址及 GCJ-02 坐标;
每种可用交通方式的总距离、预计耗时和关键步骤;
recommended_mode与中文推荐理由;某一种路线查询失败时,仍保留其他可用方案。
如果地点重名,传入 origin_city / destination_city 可以减少歧义。modes 可只保留需要比较的方式。
本地安装和 stdio 运行
要求 Node.js 22 或更高版本。
git clone https://github.com/188zjl/amap-location-mcp.git
cd amap-location-mcp
npm install
npm run build
$env:AMAP_WEB_SERVICE_KEY="你的 Web服务 Key"
npm start本地开发可复制 .env.example 为 .env,再运行 npm run dev。.env 已被 Git 忽略。
服务器 Streamable HTTP 模式
AstrBot 和 RikkaHub 可以共用部署在服务器上的兼容入口。服务本身默认只监听 127.0.0.1:3000,应由 Nginx、Nginx Proxy Manager 或 Caddy 提供 HTTPS:
export AMAP_WEB_SERVICE_KEY="你的 Web服务 Key"
export MCP_TRANSPORT="http"
export MCP_AUTH_TOKEN="至少16位的随机访问令牌"
export MCP_TOOL_PROFILE="directions"
export MCP_ALLOWED_HOSTS="map-mcp.example.com"
npm startMCP 地址为 http://127.0.0.1:3000/mcp,健康检查为 http://127.0.0.1:3000/health。反向代理时需要:
将公网
https://map-mcp.example.com/mcp转发到http://127.0.0.1:3000/mcp;保留
Authorization请求头;将真实公网域名写入
MCP_ALLOWED_HOSTS;不要直接把 Node 端口暴露到公网;
/health只说明 HTTP 服务存活,最终应以真实tools/list和amap_get_directions调用为准。
可选变量见 .env.example。HTTP 模式强制 Bearer Token,且令牌至少 16 个字符。
AstrBot 配置
在 AstrBot 面板的“扩展/工具 → MCP Servers → 添加服务器”中使用 Streamable HTTP,并填入:
{
"transport": "streamable_http",
"url": "https://map-mcp.example.com/mcp",
"headers": {
"Authorization": "Bearer 你的访问令牌"
},
"timeout": 10,
"sse_read_timeout": 300
}RikkaHub 配置
复制仓库中的 rikkahub-amap-directions.example.json,替换域名和访问令牌后即可导入 RikkaHub:
{
"mcpServers": {
"AmapDirections": {
"type": "streamable_http",
"url": "https://map-mcp.example.com/mcp",
"headers": {
"Authorization": "Bearer 你的访问令牌"
}
}
}
}注意:AstrBot 使用字段 transport,RikkaHub 使用字段 type。
其他本地 MCP 客户端配置
Codex 的 config.toml 示例:
[mcp_servers.amap-location]
command = "node"
args = ["C:\\path\\to\\amap-location-mcp\\dist\\index.js"]
env = { AMAP_WEB_SERVICE_KEY = "你的 Web服务 Key" }使用 JSON 配置的 MCP 客户端可写成:
{
"mcpServers": {
"amap-location": {
"command": "node",
"args": ["C:\\path\\to\\amap-location-mcp\\dist\\index.js"],
"env": {
"AMAP_WEB_SERVICE_KEY": "你的 Web服务 Key"
}
}
}
}其他调用示例
解析地点:
{
"query": "北京大学",
"city": "北京",
"current_location": {
"longitude": 116.31,
"latitude": 39.99
}
}设备授权后传入 WGS84 GPS 坐标:
{
"location": {
"longitude": 116.397,
"latitude": 39.908
},
"coordinate_system": "WGS84",
"coordinate_source": "device_gps",
"include_nearby_pois": true
}构建 AI 位置上下文:
{
"query": "北京大学",
"city": "北京",
"nearby_keywords": "咖啡",
"radius": 800,
"nearby_limit": 8
}验证
npm run check验证内容包括 TypeScript 构建、mock 高德响应、候选排序、WGS84 转换、逆地理编码、组合上下文、路线归一化,以及 MCP stdio 的旧版与 2026-07-28 协议握手、tools/list 和 tools/call。
高德官方文档
开源许可
本项目使用 MIT License 开源。
Available Tools
8 toolsamap_build_location_context构建 AI 位置上下文BRead-onlyIdempotent
组合地点解析、逆地理编码和周边 POI,为 AI 生成可追溯的位置事实;query 或 location 至少一个。
Inputs: city, query, radius, location, +4 more. Returns: ok, data, tool, error, +2 more
amap_convert_coordinates转换为高德坐标ARead-onlyIdempotent
把 WGS84/GPS、百度或 Mapbar 坐标转换为高德 GCJ-02;最多 40 个。
Inputs: from (required), locations (required), coordinate_source. Returns: ok, data, tool, error, +2 more
amap_get_directions查询起终点路线并推荐交通方式ARead-onlyIdempotent
主要入口:输入起点和终点地址/地点,一次解析真实坐标,比较步行、驾车和公交,返回距离、耗时、关键步骤及推荐交通方式。单个方式失败时仍返回其他可用方案。
Inputs: origin (required), destination (required), modes, origin_city, +2 more. Returns: ok, data, tool, error, +2 more
amap_locate_ip显式 IP 粗定位ARead-onlyIdempotent
对明确传入的公网 IPv4 做省市级粗定位;绝不会省略 IP 后把 MCP 服务器出口冒充用户位置。
Inputs: ip (required). Returns: ok, data, tool, error, +2 more
amap_plan_route规划真实路线ARead-onlyIdempotent
按真实起终点坐标规划高德步行、驾车或公交路线,返回距离、预计耗时和关键步骤。
Inputs: mode (required), origin (required), destination (required), city, +3 more. Returns: ok, data, tool, error, +2 more
amap_resolve_location解析真实地点ARead-onlyIdempotent
把地点名或地址解析为高德真实 POI/GCJ-02 坐标,结合城市和可选当前坐标排序候选;不冒充设备 GPS。
Inputs: query (required), city, limit, current_location. Returns: ok, data, tool, error, +2 more
amap_reverse_geocode坐标逆地理编码ARead-onlyIdempotent
把 GCJ-02 或 WGS84 坐标转换为结构化地址及附近 POI。只有调用方明确声明 device_gps 时才标记为设备位置。
Inputs: location (required), radius, coordinate_source, coordinate_system, +1 more. Returns: ok, data, tool, error, +2 more
amap_search_nearby搜索周边真实 POIARead-onlyIdempotent
按中心点、半径、关键词或高德类型码搜索周边真实 POI,并返回距离。
Inputs: center (required), limit, types, radius, +3 more. Returns: ok, data, tool, error, +2 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Most tools are distinct, but 'amap_get_directions' and 'amap_plan_route' both plan routes with similar outputs, creating ambiguity. Additionally, 'amap_build_location_context' overlaps with multiple individual tools.
All tools follow a consistent 'amap_verb_noun' pattern with underscores, e.g., 'amap_search_nearby', 'amap_convert_coordinates'. No mixing of styles.
8 tools is well-scoped for a location service, covering essential functionalities without unnecessary redundancy.
Covers core features: geocoding, reverse geocoding, POI search, route planning, coordinate conversion, IP location. Minor gaps like missing batch operations, but overall sufficient for the domain.
Maintenance
Related MCP Connectors
The Google Maps MCP server is a fully-managed server provided by the Maps Grounding Lite API that connects AI applications to Google Maps Platform services. It provides three main tools for building LLM applications: searching for places, looking up weather information, and computing routes with details like distance and travel time. The server acts as a proxy that translates Google Maps data into a format that AI applications can understand, enabling agents to accurately answer real-world location and travel queries.
Geocoding, routing, isochrones, traffic, weather, and place search for AI agents. 19 MCP tools.
MCP server for Japan geodata: cadastral lot numbers (chiban) and reverse geocoding, for AI agents.
MCP server for China administrative divisions: province/city/district lookup, adcode resolution and
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP tool that integrates with Amap API services, allowing AI to access geographic information, weather data, and route planning.11-
- FlicenseNot gradedqualityDmaintenanceA MCP server that uses Amap API to provide location-based services, allowing users to get geographic information based on IP addresses and search for nearby points of interest.30-
- AlicenseAqualityDmaintenanceThe Stadia Maps MCP server provides AI assistants with access to Stadia Maps APIs for location services, geocoding, routing, and mapping capabilities.625TypeScriptBSD 3-Clause
- AlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server that wraps the Amap (高德地图) Web Service APIs, giving AI assistants like Claude Code 9 map tools: geocoding, route planning (driving/transit/walking/cycling), POI search, nearby search, distance measurement, and IP location.1234 npm1MIT