AMap Weather MCP
An MCP server that provides real-time weather information, 4-day forecasts, and city search functionality for Chinese cities via the AMap API. It enables users to query weather data using city names or administrative codes through natural language interactions.
README
AMap Weather MCP
一个基于高德地图 API 的 MCP(Model Context Protocol)服务器,提供实时天气查询和城市代码搜索功能。
功能特性
- 🌤️ 实时天气查询 - 支持按城市名称或城市代码查询天气信息
- 📍 城市搜索 - 支持精确匹配和模糊搜索中国所有城市
- 📊 4日天气预报 - 获取详细的天气预报数据
- 🔄 多种查询方式:
- 按城市名称查询(如:杭州市、北京市)
- 按行政代码(adcode)查询
- 列出所有可用城市
- 按 adcode 获取城市信息
系统需求
- Python 3.8+
- 高德地图 API 密钥(申请教程)
安装
1. 克隆或下载项目
git clone <repository-url>
cd amap-weather-mcp
2. 安装依赖
使用 uv 包管理器(推荐):
uv pip install -r requirements.txt
或使用 pip:
pip install -r requirements.txt
配置
环境变量
需要配置以下环境变量:
| 环境变量 | 说明 | 必需 |
|---|---|---|
AMAP_API_KEY |
高德地图 API 密钥 | ✅ 必需 |
使用 Claude Desktop 集成(或者使用其他方式)
将以下配置添加到 Claude Desktop 的 claude_desktop_config.json:
{
"mcpServers": {
"amap-weather-mcp": {
"name": "amap-weather-mcp",
"type": "stdio",
"isActive": true,
"command": "uv",
"args": [
"--directory",
"/path/to/amap-weather-mcp",
"run",
"main.py"
],
"env": {
"AMAP_API_KEY": "your-api-key-here"
}
}
}
}
使用方式
可用工具
1. get_weather_by_city_name
按城市名称获取天气信息
参数:
city_name(string): 城市名称,如 "杭州市"、"北京市"
返回: 实时天气和 4 天预报数据
2. get_weather_by_city_code
按城市行政代码获取天气信息
参数:
city_code(string): 城市行政代码,如 "110100"(北京市朝阳区)
返回: 实时天气和 4 天预报数据
3. search_city
搜索城市(支持精确和模糊匹配)
参数:
city_name(string): 要搜索的城市名称
返回: 匹配的城市列表及其代码
4. get_city_by_adcode
按 adcode 获取城市信息
参数:
adcode(string): 行政代码,如 "110000"(北京市)
返回: 城市信息对象
5. list_all_cities
列出所有可用城市
参数:
limit(integer): 返回结果数量限制,默认 50,最大 200
返回: 城市列表,包括总数量
项目结构
amap-weather-mcp/
├── main.py # 主程序文件
├── city_codes.json # 城市代码数据库
├── requirements.txt # 项目依赖
├── .gitignore # Git 忽略规则
└── README.md # 本文件
依赖包
httpx- 异步 HTTP 客户端requests- HTTP 库mcp- Model Context Protocol 实现
开发说明
项目特点
- 使用 Python
asyncio实现异步操作 - 集成 MCP 标准,支持与 Claude AI 无缝集成
- 高效的城市代码索引,支持快速查询
- 完善的错误处理和日志记录
日志
程序使用 Python 的 logging 模块记录信息,日志级别为 INFO。
许可证
MIT License
支持
如有问题或建议,欢迎提交 Issue 或 Pull Request。
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.