这是一个基于 Model Context Protocol (MCP) 的高德地图服务集成项目,允许 AI 模型(如 Claude、GPT等)直接调用高德地图的各种功能,包括地点搜索、路线规划、地理编码等。
这是一个基于 Model Context Protocol (MCP) 的高德地图服务集成项目,允许 AI 模型(如 Claude、GPT等)直接调用高德地图的各种功能,包括地点搜索、路线规划、地理编码等。
克隆项目代码
git clone https://github.com/yourusername/gaode-mcp.git
cd gaode-mcp
安装依赖
npm install
配置API密钥
.env
文件在项目根目录GAODE_API_KEY=你的高德地图API密钥
npm start
启动后,服务将通过标准输入/输出与MCP客户端通信。
本服务提供以下MCP工具供AI模型调用:
{
"name": "searchPOI",
"arguments": {
"keywords": "故宫",
"city": "北京",
"types": "旅游景点",
"page": 1,
"offset": 20
}
}
{
"name": "geocode",
"arguments": {
"address": "北京市朝阳区阜通东大街6号",
"city": "北京"
}
}
{
"name": "regeocode",
"arguments": {
"location": "116.481499,39.990475",
"extensions": "all"
}
}
{
"name": "getRoute",
"arguments": {
"origin": "116.481499,39.990475",
"destination": "116.465063,39.999538",
"type": "driving",
"strategy": 0
}
}
{
"name": "getWeather",
"arguments": {
"city": "110000",
"extensions": "all"
}
}
{
"name": "getPOIDetail",
"arguments": {
"id": "B000A8UIN8"
}
}
{
"name": "searchAround",
"arguments": {
"location": "116.481499,39.990475",
"keywords": "餐厅",
"types": "餐饮",
"radius": 1000,
"offset": 20
}
}
{
"name": "planTourRoute",
"arguments": {
"city": "北京",
"pois": ["故宫", "长城", "颐和园", "天坛", "鸟巢"],
"days": 3,
"transportation": "driving",
"returnHtml": true
}
}
项目包含一个示例页面 beijing_tour.html
,展示了基于高德地图服务生成的北京三日游路线规划。可以通过浏览器直接打开此文件查看效果。
可以将此服务配置为AI助手(如Claude、GPT等)的Tool或Plugin,使其能够直接调用高德地图服务。
npm start
src/index.ts
中添加新的工具定义:server.tool("yourNewTool",
{
param1: z.string().describe("参数1说明"),
param2: z.number().describe("参数2说明")
},
async (params) => {
// 实现你的功能...
return {
content: [{ type: "text", text: JSON.stringify(result) }]
};
}
);
MIT License
如有问题或建议,请提交Issue或Pull Request。
注意:请勿在公开环境中暴露你的API密钥。