ctermiii/weather-mcp-metro
3.2
If you are the rightful owner of weather-mcp-metro and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Weather MCP Server is a real-time weather query service for LLMs, based on the Open-Meteo API.
Tools
1
Resources
0
Prompts
0
Weather MCP Server
基于 Open-Meteo API 的 MCP (Model Context Protocol) 天气服务器,为 LLM 大模型提供实时天气查询功能。
功能特性
- 支持中英文城市名称查询
- 自动地理编码(城市名→坐标)
- 获取7天天气预报
- 详细的天气信息包括:
- 温度: 最高/最低温度、体感温度
- 风力: 风速、阵风、风向
- 舒适度: 基于温度和湿度的舒适度评估
- 天气状况: 晴、雨、雪等详细描述
- 降水信息: 降水量、降雨量、降雪量
- 其他: 日出日落时间、湿度等
安装
npm install
使用方法
1. 配置 MCP 客户端
在 Claude Desktop 或其他 MCP 客户端的配置文件中添加:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/Users/wanli/.config/mcp/weather-mcp-metro/index.js"]
}
}
}
2. 启动服务器
npm start
3. 在 LLM 中使用
服务器提供了一个工具 get_weather,可以通过以下方式调用:
请帮我查询北京的天气
或
What's the weather like in Shanghai?
API 说明
get_weather
获取指定城市的天气预报信息。
参数:
city(string, 必需): 城市名称,支持中英文
返回示例:
{
"城市信息": {
"名称": "Beijing",
"国家": "China",
"坐标": "39.9075, 116.39723",
"时区": "Asia/Shanghai"
},
"当前天气": {
"时间": "2025-10-17T10:00",
"温度": "18°C",
"体感温度": "16°C",
"湿度": "65%",
"天气状况": "部分多云",
"风速": "12 km/h",
"风向": "东北",
"舒适度": "舒适"
},
"七天预报": [
{
"日期": "2025-10-17",
"最高温度": "22°C",
"最低温度": "14°C",
"天气状况": "部分多云",
"降水量": "0mm",
"降雨量": "0mm",
"降雪量": "0cm",
"最大风速": "15 km/h",
"最大阵风": "25 km/h",
"主导风向": "东",
"日出": "2025-10-17T06:30",
"日落": "2025-10-17T18:15",
"舒适度": "舒适"
}
// ... 其余6天
]
}
技术细节
数据来源
- 地理编码 API:
https://geocoding-api.open-meteo.com/v1/search - 天气数据 API:
https://api.open-meteo.com/v1/forecast
天气参数
temperature_2m_max/min: 最高/最低温度weathercode: 天气代码(自动转换为中文描述)precipitation_sum: 总降水量rain_sum: 降雨量snowfall_sum: 降雪量windspeed_10m_max: 最大风速windgusts_10m_max: 最大阵风winddirection_10m_dominant: 主导风向sunrise/sunset: 日出日落时间relative_humidity_2m: 相对湿度apparent_temperature: 体感温度
舒适度评级
基于体感温度和湿度计算:
- 非常寒冷 (< 0°C)
- 寒冷 (0-10°C)
- 凉爽 (10-16°C)
- 舒适 (16-24°C)
- 温暖 (24-28°C)
- 炎热 (28-32°C)
- 酷热 (> 32°C)
同时考虑湿度影响(高湿度/干燥提示)
依赖项
@modelcontextprotocol/sdk: MCP SDK
许可证
MIT
注意事项
- Open-Meteo API 是免费开源的,无需 API 密钥
- 数据更新频率取决于 Open-Meteo 服务
- 建议合理使用,避免过于频繁的请求