weather-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")— 同时比较两个城市的天气
Related MCP server: Weather MCP Server
安装
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 进行快速验证(无需 mock,无需 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"]
}
}
}重启你的客户端,然后直接问它类似 “今天在金奈需要带伞吗?” 这样的问题。
项目结构
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 同样提供免费的接口)
多日出行规划(本周最适合户外活动的日子)
恶劣天气警报
如果新工具是在原始数据之上增加推理,就放在 weather_advice.py 中;如果只是纯数据获取,就放在 weather_core.py 中——然后用新的 @mcp.tool() 把它们接入 server.py。
许可证
MIT — 请参阅 LICENSE。
This server cannot be deployed
Maintenance
Related MCP Connectors
Global weather via Open-Meteo: forecast, historical, marine, air quality, geocoding, elevation.
Get current weather for any city and create images from your prompts. Streamline planning, reports…
Current weather and forecasts for any coordinates, backed b… — paid per call (x402/credits), 1 tools
OpenWeather data for AI agents: list feeds, sign up, check balance, get a top-up link, fetch data.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to fetch current weather conditions and forecasts for any city using the Open-Meteo API. Provides temperature, precipitation, and hourly forecast data through natural language queries.-
- FlicenseNot gradedqualityCmaintenanceProvides real-time weather data via 12 tools (current weather, forecasts, air quality, umbrella advice, etc.) using Open-Meteo and FastMCP, enabling LLMs to answer weather-related queries.1-
- AlicenseNot gradedqualityDmaintenanceProvides live weather data (current conditions, forecasts) and city geocoding through Open-Meteo API, enabling AI assistants to answer weather queries without an API key.MIT
- FlicenseNot gradedqualityCmaintenanceProvides real-time weather data, forecasts, and explainable predictions (umbrella, travel, city comparisons) via natural language, powered by Open-Meteo.-