返回市场
MCP天气服务器

MCP天气服务器

作者:adhikasp25 星标更新:2025-01-01

项目介绍

MCP Weather Server

一个简单的MCP服务器,使用AccuWeather API提供每小时天气预报。

配置

  1. 使用uv安装依赖项:
uv venv
uv sync
  1. 创建一个包含您的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"
            }
        }
    }
}

API 使用

获取每小时天气预报

响应:

{
    "location": "Jakarta",
    "location_key": "208971",
    "country": "Indonesia",
    "current_conditions": {
        "temperature": {
            "value": 32.2,
            "unit": "C"
        },
        "weather_text": "部分晴朗",
        "relative_humidity": 75,
        "precipitation": false,
        "observation_time": "2024-01-01T12:00:00+07:00"
    },
    "hourly_forecast": [
        {
            "relative_time": "+1 小时",
            "temperature": {
                "value": 32.2,
                "unit": "C"
            },
            "weather_text": "部分晴朗",
            "precipitation_probability": 40,
            "precipitation_type": "雨",
            "precipitation_intensity": "轻度"
        }
    ]
}

API 提供:

  • 当前天气状况,包括温度、天气描述、湿度和降水状态
  • 12小时预报,每小时数据包括:
    • 相对于当前时间的时间
    • 摄氏温度
    • 天气描述
    • 降水概率、类型和强度