
OpenWeather 免费 API 的 MCP 服务器
概览
一个简单的MCP服务,利用免费的OpenWeatherMap API提供当前天气和5天预报。 - 当前天气状况 - 5天天气预报 - 可配置单位(摄氏/华氏/开尔文) - 多语言支持 - 简单MCP集成 1. 从 https://openweathermap.org/api 获取 OpenWeatherMap API 密钥 2.克隆仓库: 通过Smithery自动安装MCP气象服务用于Claude Desktop: 缺少API密钥:致命:OWM_API_KEY环境变量未设置 无效城市:当前天气错误:未能获取当前天气:未找到城市 网络问题:未能获取预报:上下文截止时间已逾 欢迎投稿!请按照以下步骤操作:
概述(AI 翻译)
一个简单的MCP服务,利用免费的OpenWeatherMap API提供当前天气和5天预报。
特色
- 当前天气状况
- 5天天气预报
- 可配置单位(摄氏/华氏/开尔文)
- 多语言支持
- 简单MCP集成
先修条件
- Go 1.20+
- OpenWeatherMap API 密钥
安装
-
从 https://openweathermap.org/api 获取 OpenWeatherMap API 密钥。
-
克隆仓库:
-
构建:
通过Smithery安装
通过Smithery自动安装MCP气象服务用于Claude Desktop:
配置
设置所需环境变量:
用途
MCP参数
示例回应
错误处理
常见错误情景:
缺少API密钥:致命:OWM_API_KEY环境变量未设置
无效城市:当前天气错误:未能获取当前天气:未找到城市
网络问题:未能获取预报:上下文截止时间已逾
发展
欢迎投稿!请按照以下步骤操作:
分支仓库
创建功能分支
提交变更
推向分支
创建拉取请求
许可证
麻省理工学院许可——详情请参见许可
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MCP Weather Service
A simple MCP service that provides current weather and 5-day forecast using the free OpenWeatherMap API.
Features
- Current weather conditions
- 5-day weather forecast
- Configurable units (Celsius/Fahrenheit/Kelvin)
- Multi-language support
- Simple MCP integration
Prerequisites
- Go 1.20+
- OpenWeatherMap API key
Installation
-
Get OpenWeatherMap API key from https://openweathermap.org/api
-
Clone repository:
git clone https://github.com/mschneider82/mcp-openweather.git cd mcp-openweather -
Build:
go build -o mcp-weather
Installing via Smithery
To install MCP Weather Service for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @mschneider82/mcp-openweather --client claude
Configuration
Set required environment variable:
export OWM_API_KEY="your_api_key_here"
Usage
"mcpServers": {
"mcp-openweather": {
"command": "/home/YOURUSER/git/mcp-openweather/mcp-openweather",
"env": {
"OWM_API_KEY": "PUT_API_KEY_HERE"
}
}
}
MCP Parameters
{
"tool": "weather",
"params": {
"city": "Berlin", // Required
"units": "c", // Optional (c|f|k)
"lang": "en" // Optional (en|de|fr|...)
}
}
Example Response
Current weather for München:
Conditions: Klarer Himmel
Now: 17.78 metric
High: 18.66 metric
Low: 17.36 metric
Pressure: 1017
Humidity: 40
FeelsLike: 16.66
Wind Speed: 1.79
Wind Degree: 61
Sunrise: 1747107429 Unixtime
Sunset: 1747161784 Unixtime
Weather Forecast for München:
Date & Time: 2025-05-13 12:00:00 +0000 UTC
Conditions: Clear Klarer Himmel
Temp: 17.78
High: 18.93
Low: 17.78
Date & Time: 2025-05-13 15:00:00 +0000 UTC
Conditions: Clear Klarer Himmel
Temp: 18.33
High: 19.44
Low: 18.33
Date & Time: 2025-05-13 18:00:00 +0000 UTC
Conditions: Clear Klarer Himmel
Temp: 16.32
High: 16.32
Low: 15.59
Date & Time: 2025-05-13 21:00:00 +0000 UTC
Conditions: Clear Klarer Himmel
Temp: 9.18
High: 9.18
Low: 9.18
...
Error Handling
Common error scenarios:
Missing API key: FATAL: OWM_API_KEY environment variable not set
Invalid city: current weather error: failed to fetch current weather: city not found
Network issues: failed to fetch forecast: context deadline exceeded
Development
Contributions welcome! Please follow these steps:
安装
npx -y @smithery/cli install @mschneider82/mcp-openweather --client claude配置
"mcpServers": {
"mcp-openweather": {
"command": "/home/YOURUSER/git/mcp-openweather/mcp-openweather",
"env": {
"OWM_API_KEY": "PUT_API_KEY_HERE"
}
}
}