article
README
🚀 MCP 天气服务器
MCP 天气服务器是一个简单的服务器,借助 AccuWeather API 为用户提供每小时的天气预报,满足对天气信息的实时需求。
🚀 快速开始
📦 安装指南
- 使用
uv安装依赖:
uv venv
uv sync
- 创建包含您的 AccuWeather API 密钥的
.env文件:
ACCUWEATHER_API_KEY=your_api_key_here
您可以在AccuWeather API注册以获取 API 密钥。
运行服务器
{
"mcpServers": {
"weather": {
"command": "uvx",
"args": ["--from", "git+https://github.com/adhikasp/mcp-weather.git", "mcp-weather"],
"env": {
"ACCUWEATHER_API_KEY": "your_api_key_here"
}
}
}
}
💻 使用示例
基础用法
获取每小时天气预报
响应:
{
"location": "Jakarta",
"location_key": "208971",
"country": "Indonesia",
"current_conditions": {
"temperature": {
"value": 32.2,
"unit": "C"
},
"weather_text": "Partly sunny",
"relative_humidity": 75,
"precipitation": false,
"observation_time": "2024-01-01T12:00:00+07:00"
},
"hourly_forecast": [
{
"relative_time": "+1 hour",
"temperature": {
"value": 32.2,
"unit": "C"
},
"weather_text": "Partly sunny",
"precipitation_probability": 40,
"precipitation_type": "Rain",
"precipitation_intensity": "Light"
}
]
}
API 提供以下信息:
- 当前天气状况,包括温度、天气描述、湿度和降水状态
- 12 小时预报,包含每小时数据:
- 自当前时间起的相对时间
- 摄氏温度值
- 天气描述
- 降水概率、类型和强度
微信扫一扫