关于 weather-mcp
weather-mcp 是一个为 AI 助手提供实时天气问答的 MCP 服务,使用 Open-Meteo 数据且无需 API 密钥。除天气状况和预报外,它还可依据降雨、风和温度给出户外活动建议。
主要功能
- 01查询当前天气与当日预报
- 02根据降雨判断是否带伞
- 03综合天气评估户外条件
- 04比较两个城市的天气
- 05天气数据与推理逻辑分离
适用场景
- 01询问某地当前天气和预报
- 02判断出门是否需要带伞
- 03评估当天是否适合户外活动
- 04比较两座城市的天气
MCP 相关
向 MCP 客户端提供天气查询、带伞建议、户外条件评估和城市天气比较工具。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://weather-mcp-2yhb.onrender.com/mcpclaude mcp add --transport http darshan0548-weather https://weather-mcp-2yhb.onrender.com/mcp{"mcpServers":{"darshan0548-weather":{"type":"http","url":"https://weather-mcp-2yhb.onrender.com/mcp"}}}在 Cursor 中打开{"servers":{"darshan0548-weather":{"type":"http","url":"https://weather-mcp-2yhb.onrender.com/mcp"}}}在 VS Code 中打开{"mcpServers":{"darshan0548-weather":{"type":"http","url":"https://weather-mcp-2yhb.onrender.com/mcp"}}}{"mcpServers":{"darshan0548-weather":{"serverUrl":"https://weather-mcp-2yhb.onrender.com/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
工具
详细介绍
weather-mcp
一个 MCP(Model Context Protocol)服务,让 AI 助手(Claude、Gemini CLI 或任何兼容 MCP 的客户端)能够利用实时数据回答实际的天气问题,而不只是获取原始数值。
由 Open-Meteo 提供支持——免费使用,无需 API 密钥。
为什么它不只是一个原始天气 API 封装
大多数天气集成只会返回 temperature: 22°C。这个工具在此基础上增加了推理层,因此你可以询问普通 API 无法直接回答的问题:
get_weather("Bangalore")— 当前天气状况和今日预报should_i_carry_umbrella("Mumbai")— 给出有理由的“是”或“否”答案,而不只是降雨概率is_good_for_outdoors("Delhi")— 综合检查降雨、风力和气温,判断是否适合户外活动compare_weather("Bangalore", "Delhi")— 同时比较两个城市
设置
git clone https://github.com/darshan0548/weather-mcp.git
cd weather-mcp
python3 -m venv venv
source venv/bin/activate # on Windows: venv\Scripts\activate
pip install -r requirements.txt
运行测试
通过真实 API 快速进行完整性检查(不使用模拟,无需 API 密钥):
python test_weather.py
将其连接到 Claude Desktop
将以下内容添加到 Claude Desktop 配置文件(claude_desktop_config.json)中:
{
"mcpServers": {
"weather": {
"command": "python",
"args": ["/absolute/path/to/weather-mcp/server.py"]
}
}
}
将其连接到 Gemini CLI
将以下内容添加到 ~/.gemini/settings.json:
{
"mcpServers": {
"weather": {
"command": "python",
"args": ["/absolute/path/to/weather-mcp/server.py"]
}
}
}
重启客户端,然后直接询问类似 “我今天在 Chennai 需要带伞吗?” 的问题。
项目结构
weather_core.py # talks to the Open-Meteo API, no MCP-specific code
weather_advice.py # reasoning layer built on top of raw weather data
server.py # MCP server — wires the above into tools
test_weather.py # sanity tests against the real API
刻意将文件分开保存——weather_core.py 和 weather_advice.py 完全不依赖 MCP,因此易于单独测试或复用。
贡献
欢迎提交 PR。如果你想添加工具,可以考虑以下方向:
- 按小时拆分预报,而不只是提供今日摘要
- 空气质量数据(Open-Meteo 也为此提供免费的 API 端点)
- 多日行程规划(找出本周最适合举办户外活动的一天)
- 恶劣天气预警
如果新工具是在原始数据的基础上增加推理,请将其放在 weather_advice.py 中;如果只是获取数据,则放在 weather_core.py 中——然后在 server.py 中将其接入,作为新的 @mcp.tool()。
许可证
MIT——详见 LICENSE。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。