天气数据服务

一个基于美国国家气象局API的天气数据服务,提供美国各州的实时天气警报和详细天气预报功能。

  • by iwm57
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 iwm57/mcp-weather-server

使用说明

MCP气象服务器

模型上下文协议(MCP)服务器,使用美国国家气象局API提供天气数据工具。

特性

  • 获取警报:获取美国任何州的活跃天气警报
  • 获取预测:获取任何位置(纬度/经度)的详细天气预报

安装

# Clone the repository
git clone https://github.com/iwm57/mcp-weather-server.git
cd mcp-weather-server

# Install dependencies
uv add "mcp[cli]" httpx

用法

运行服务器

uv run weather.py

可用工具

获取警报(状态)

获取美国某个州的天气警报。

参数:

  • state (str):两个字母的美国州代码(例如CA、NY、TX)

例子:

await get_alerts("CA")

get_forecast(纬度、经度)

获取某个地点的天气预报。

参数:

  • latitude (浮动):位置的纬度
  • longitude (浮动):位置的经度

例子:

await get_forecast(38.5816, -121.4944)  # Sacramento, CA

Claude用于桌面配置

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "weather": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/mcp-weather-server",
        "run",
        "weather.py"
      ]
    }
  }
}

API

此服务器使用 美国国家气象局API 其是免费的并且不需要API密钥。

注: 此服务仅提供美国地区的天气数据。

许可证

麻省理工学院