Amap MCP Server

Provides geographic information services and route planning for AI agents.

README.md

🌐 Amap MCP Server

🗺️ 高德地图 MCP (Model Context Protocol) 服务器 - 为 AI 智能体提供完整的地理信息服务和路线规划功能

基于 Model Context Protocol (MCP) 协议的高德地图服务集成,支持地理编码、路线规划、POI搜索等核心功能,专为 AI 智能体和 LLM 应用设计。

✨ 核心特性

功能模块 描述 工具数量
🗺️ 地理编码 地址与坐标相互转换 2
🚗 路线规划 驾车/步行/骑行/公交/地铁 6
🔍 POI搜索 关键字/周边/多边形/详情查询 4
🏛️ 行政区划 城市区域层级查询 1
🌐 IP定位 基于IP的地理位置 1
📍 AOI边界 兴趣区域边界查询 1

总计:15+ 个专业工具


🚀 快速开始

1️⃣ 安装依赖

# 使用 pip
pip install -r requirements.txt

# 使用 uv (推荐,更快)
uv pip install -r requirements.txt

2️⃣ 配置环境变量

方式一:复制配置文件(推荐)

# 复制环境变量模板
cp .env.example .env
# 编辑 .env 文件,填入您的 API Key

方式二:直接创建 .env 文件

创建 .env 文件并配置高德 API 密钥:

# ========== 必需配置 ==========
# 高德地图 Web 服务 API Key
# 获取地址:https://lbs.amap.com/dev/
AMAP_API_KEY=your_amap_api_key_here

# ========== API 地址配置(可选,使用默认值) ==========
# 地理编码
AMAP_GEO_URL=https://restapi.amap.com/v3/geocode/geo
AMAP_REGEO_URL=https://restapi.amap.com/v3/geocode/regeo

# 路线规划
AMAP_DRIVING_URL=https://restapi.amap.com/v5/direction/driving
AMAP_WALKING_URL=https://restapi.amap.com/v5/direction/walking
AMAP_BICYCLING_URL=https://restapi.amap.com/v5/direction/bicycling
AMAP_EBIKE_URL=https://restapi.amap.com/v5/direction/electrobike
AMAP_BUS_URL=https://restapi.amap.com/v5/direction/transit/integrated
AMAP_SUBWAY_TRANSIT=https://restapi.amap.com/v5/direction/transit/integrated

# POI 搜索
AMAP_SEARCH_POI_URL=https://restapi.amap.com/v5/place/text
AMAP_SEARCH_POI_AROUND_URL=https://restapi.amap.com/v5/place/around
AMAP_SEARCH_POI_POLYGON_URL=https://restapi.amap.com/v5/place/polygon
AMAP_SEARCH_POI_DETAIL_URL=https://restapi.amap.com/v5/place/detail
AMAP_AOI_POLYLINE_URL=https://restapi.amap.com/v5/aoi/polyline

# 行政区划 & IP
AMAP_REGION_QUERY_URL=https://restapi.amap.com/v3/config/district
AMAP_IP_URL=https://restapi.amap.com/v3/ip

# ========== 日志配置(可选) ==========
# 日志级别: DEBUG, INFO, WARNING, ERROR, CRITICAL
# AMAP_LOG_LEVEL=INFO
# 日志文件路径
# AMAP_LOG_FILE=amap_mcp.log

3️⃣ 获取 API 密钥

  1. 访问 高德开放平台
  2. 注册/登录账号
  3. 创建应用 → 选择「Web服务」
  4. 获取 API Key

4️⃣ 启动服务

# 方式1: 直接运行 MCP 服务器
python amap_mcp.py

# 方式2: 使用 MCP CLI
mcp run amap_mcp.py

🔧 MCP Server 集成配置

Claude Desktop / Cursor 等 MCP 客户端

在 MCP 客户端配置文件中添加:

{
  "mcpServers": {
    "amap-mcp-server": {
      "transport": "stdio",
      "command": "python",
      "args": ["D:\\mycode\\travelagent\\amap_mcp\\amap_mcp.py"],
      "env": {
        "AMAP_API_KEY": "your_amap_api_key_here"
      }
    }
  }
}

环境变量配置(推荐)

{
  "mcpServers": {
    "amap-mcp-server": {
      "transport": "stdio",
      "command": "python",
      "args": ["D:\\mycode\\travelagent\\amap_mcp\\amap_mcp.py"]
    }
  }
}

配合 .env 文件使用:

AMAP_API_KEY=your_amap_api_key_here

Linux/macOS 路径示例

{
  "mcpServers": {
    "amap-mcp-server": {
      "transport": "stdio",
      "command": "python",
      "args": ["/home/user/travelagent/amap_mcp/amap_mcp.py"]
    }
  }
}

📚 API 工具列表

📍 地理编码

工具名称 功能描述 输入示例
geocoding 地址转坐标 {"address": "北京市朝阳区阜通东大街6号"}
reverse_geocoding 坐标转地址 {"location": "116.481488,39.990464"}

🚗 路线规划

工具名称 功能描述 策略选项
driving_route_planning 驾车路线 速度优先/费用最低/距离最短/推荐路线
walking_route_planning 步行路线 室内外路线规划
bicycling_route_planning 骑行路线 自行车专用路线
elect_bike_route_planning 电动车路线 续航/充电站优化
public_transit_route_planning 公交路线 地铁/公交/换乘方案
amap_route_subway 地铁路线 城市地铁换乘

🔍 POI 搜索

工具名称 功能描述
search_poi 关键字搜索 POI
search_poi_around 周边 POI 搜索
search_poi_polygon 多边形区域 POI 搜索
search_poi_detail POI 详情查询
search_aoi_boundary AOI 边界查询

🏛️ 行政区划 & IP

工具名称 功能描述
administrative_region_query 行政区划查询
ip_positioning IP 定位

💡 使用示例

Python 示例

import asyncio
from amap_mcp import geocoding, driving_route_planning

async def travel_planner():
    """智能行程规划示例"""
    
    # 1️⃣ 地址转坐标
    address_result = await geocoding({
        "address": "北京市朝阳区望京soho",
        "city": "北京"
    })
    origin = address_result["data"]["location"]
    
    # 2️⃣ 获取目的地坐标
    dest_result = await geocoding({
        "address": "上海浦东新区陆家嘴",
        "city": "上海"
    })
    destination = dest_result["data"]["location"]
    
    # 3️⃣ 规划驾车路线
    route = await driving_route_planning({
        "o

Tools 15

geocodingConverts an address into geographic coordinates.
reverse_geocodingConverts geographic coordinates into an address.
driving_route_planningPlans a driving route between two points.
walking_route_planningPlans a walking route between two points.
bicycling_route_planningPlans a bicycling route between two points.
elect_bike_route_planningPlans an electric bike route between two points.
public_transit_route_planningPlans a public transit route using bus and subway.
amap_route_subwayPlans a subway transit route.
search_poiSearches for points of interest using keywords.
search_poi_aroundSearches for points of interest in the surrounding area.
search_poi_polygonSearches for points of interest within a polygon area.
search_poi_detailRetrieves detailed information about a specific POI.
search_aoi_boundaryQueries the boundary of an area of interest.
administrative_region_queryQueries administrative region hierarchy.
ip_positioningDetermines geographic location based on IP address.

Environment Variables

AMAP_API_KEYrequiredThe API key obtained from the Amap Open Platform.

Try it

Find the coordinates for 'Beijing Wangjing SOHO'.
Plan a driving route from my current location to the nearest subway station.
Search for coffee shops within 1km of my current coordinates.
What is the administrative region hierarchy for Shanghai?
Get the address for the coordinates 116.481488, 39.990464.

Frequently Asked Questions

What are the key features of Amap MCP Server?

Geocoding and reverse geocoding for address-coordinate conversion.. Multi-modal route planning including driving, walking, cycling, and public transit.. Comprehensive POI search capabilities including keyword, surrounding, and polygon searches.. Administrative region and IP-based location querying.. AOI boundary retrieval for detailed area mapping..

What can I use Amap MCP Server for?

Building AI-powered travel assistants that plan complex multi-modal itineraries.. Automating location-based data analysis for logistics and delivery planning.. Integrating real-time map data into LLM-based research tools for geographic queries.. Developing location-aware agents that provide context-specific recommendations based on user proximity..

How do I install Amap MCP Server?

Install Amap MCP Server by running: pip install -r requirements.txt

What MCP clients work with Amap MCP Server?

Amap MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Amap MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare