MCP无天气
模型上下文协议(MCP)服务器,使用免费的Open-Meteo API提供天气数据。不需要API密钥!
特性
- 当前天气:获取实时天气状况,包括温度、湿度、风速和天气描述
- 逐时预报:24小时天气预报,每小时更新
- 每日预报:7天天气预报,每日摘要
- 城市搜索:使用自动地理编码按城市名称查找天气
- 动车组:支持不同的温度(摄氏度/华氏度)、风速(公里/小时、米/秒、英里/小时、节)和降水量(毫米、英寸)单位
安装
使用uvx(推荐)
uvx --from git+https://github.com/microagents/mcp-servers.git#subdirectory=mcp-weather-free mcp-weather-free使用pip
pip install git+https://github.com/microagents/mcp-servers.git#subdirectory=mcp-weather-free配置
将以下内容添加到MCP客户端配置中:
适用于克劳德桌面
更新您的 claude_desktop_config.json:
{
"mcpServers": {
"weather": {
"command": "uvx",
"args": ["--from", "git+https://github.com/microagents/mcp-servers.git#subdirectory=mcp-weather-free", "mcp-weather-free"]
}
}
}对于其他MCP客户端
{
"mcpServers": {
"weather": {
"command": "python",
"args": ["-m", "mcp_weather_free"]
}
}
}可用工具
get_weather
获取特定坐标的天气数据。
参数:
latitude(浮点数,必填):位置的纬度longitude(浮动,必填):位置的经度location_name(字符串,可选):位置的显示名称temperature_unit(字符串,可选):“celsius”(默认)或“fahrenheit”wind_speed_unit(字符串,可选):“公里小时”(默认)、“毫秒”、“英里小时”或“节”precipitation_unit(字符串,可选):“mm”(默认)或“英寸”
例子:
Get weather for latitude: 40.7128, longitude: -74.0060get_weather_by_city
按城市名称获取天气数据。
参数:
city(string,必填):城市名称country_code(字符串,可选):2个字母的国家代码(例如,“US”、“GB”)temperature_unit(字符串,可选):“celsius”(默认)或“fahrenheit”wind_speed_unit(字符串,可选):“公里小时”(默认)、“毫秒”、“英里小时”或“节”precipitation_unit(字符串,可选):“mm”(默认)或“英寸”
例子:
Get weather for city: "New York"资源
服务器还提供了一个资源端点:
weather://current/{latitude}/{longitude}-获取某个位置的格式化当前天气
响应格式
天气数据包括:
- 位置信息:坐标、时区、海拔
- 现状:温度、湿度、风、天气描述
- 每小时预报:未来24小时的天气数据
- 每日预测:未来7天天气摘要
许可证
该项目根据MIT许可证获得许可。
鸣谢
气象数据由 Open Meteo -免费天气API,无需API密钥。
