
基于高德地图 API 的中国城市天气查询 MCP Server
基于高德地图 API 的中国城市天气查询 MCP Server
·
基于高德地图 API 的中国城市天气查询 Model Context Protocol (MCP) 服务。该服务允许用户通过简单的请求获取中国各城市的实时天气状况和未来几天的天气预报。
uv venv
source .venv/bin/activate
uv add "mcp[cli]" httpx如果你需要自行创建客户端测试该 MCP 服务,请手动启动。 在终端中执行以下命令启动 MCP 服务:
uv run weather.py如果想在 Claude Desktop 中使用,请添加服务器配置:
请在文本编辑器中打开 Claude for Desktop App 配置,路径参考如下 ~/Library/Application Support/Claude/claude_desktop_config.json
如果文件不存在,请确保创建该文件。
{
"mcpServers": {
"amap-weather-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
"run",
"weather.py"
],
"env": {
"AMAP_API_KEY": "YOUR_API_KEY_HERE"
}
}
}
}如下图所示配置即可:
MCP 服务提供了三个主要工具函数用于天气查询:
get_current_weather: 获取城市当前天气状况get_weather_forecast: 获取未来几天的天气预报search_city: 搜索城市名称使用 MCP 客户端调用示例:
from mcp.client import Client
# 连接到服务
client = Client("amap-weather-mcp-server")
# 查询实时天气
current_weather = await client.get_current_weather("北京市")
print(current_weather)
# 查询天气预报
forecast = await client.get_weather_forecast("上海市")
print(forecast)
# 搜索城市名称
cities = await client.search_city("广州")
print(cities)获取指定城市的实时天气数据。
参数:
city: 中国城市名称,需要包含省/市/县等行政区划标识,如"北京市"、"上海市"、"海珠区"等返回: 格式化的城市实时天气信息字符串,包括:
获取指定城市的天气预报(未来3-4天)。
参数:
city: 中国城市名称,需要包含省/市/县等行政区划标识,如"北京市"、"上海市"、"浙江省杭州市"等返回: 格式化的城市天气预报信息字符串,包括:
根据关键词搜索匹配的城市名称。
参数:
keyword: 城市名称关键词,建议包含省/市/县等行政区划标识,如"广州市"、"海珠区"等返回: 包含匹配城市名称列表的字符串。
本服务使用高德地图开放平台提供的天气数据 API:
Pick your client and paste the snippet. Each one is the same server, written the way that client expects it.
claude mcp add amap-weather-mcp-server -- uv --directory /ABSOLUTE/PATH/TO/PARENT/FOLDER/weather run weather.py{
"mcpServers": {
"amap-weather-mcp-server": {
"env": {
"AMAP_API_KEY": ""
},
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
"run",
"weather.py"
],
"command": "uv"
}
}
}code --add-mcp '{"name":"amap-weather-mcp-server","env":{"AMAP_API_KEY":""},"args":["--directory","/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather","run","weather.py"],"command":"uv"}'[mcp_servers.amap-weather-mcp-server]
command = "uv"
args = ["--directory", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather", "run", "weather.py"]Runs locally on your device. Your client starts the server itself, so nothing has to be hosted.
Paste this prompt into your agent. It reads this page and does the setup for you.
Read https://aiagentslisting.com/mcp/mcp-2 to learn what the "中国城市天气查询 MCP 服务" MCP server does and how to install it. Add it to my coding agent's MCP configuration as documented on that page, then confirm the server connects and list the tools it exposes.Agents can also browse this directory over MCP at https://aiagentslisting.com/api/mcp
This server runs locally, so we can't read its tool list over the web yet.
We could not run this server: it ships no npx package for our sandbox and no public endpoint. The four checks that need a live server are left out, and the grade tops out at B until one exists.
Maintain this server? Claiming proves you own the listing and earns the last 4 points.
Claim this listingPaste this line near the top of your repository's README. The badge always renders the current score.
[](https://aiagentslisting.com/mcp/mcp-2)Nothing comparable is listed yet.
No tagged releases on record.
Connect to the AI Agents Listing MCP server at https://aiagentslisting.com/api/mcp using the HTTP transport and complete the sign-in when it asks. Then call the submit_review tool for the listing "mcp-2" with a rating from 1 to 5 and a short note on what worked and what did not.No reviews yet
Be the first to share your experience with this tool.
One email a week. New agents, MCP servers and skills, and what is actually getting traction.