天气 MCP 服务器是一个提供天气信息的模型上下文协议(MCP)服务器,它集成于桌面版的 Claude 中。该服务器借助国家气象局 API,能为美国境内的任意位置提供天气预报和警报服务。此项目是作为 MIT MCP 黑客马拉松活动的一部分于 2025 年 4 月创建的。
get_forecast:可使用经纬度获取任何美国位置的详细天气预报。get_alerts:能根据州代码检索特定州内的活跃天气警报。确保已安装 uv,可使用以下命令进行安装:
curl -LsSf https://astral.sh/uv/install.sh | sh
使用以下命令创建并激活虚拟环境,同时安装所需依赖项:
# 创建并激活虚拟环境
uv venv
source .venv/bin/activate
# 安装依赖项
uv add "mcp[cli]" httpx
~/Library/Application Support/Claude/claude_desktop_config.json,内容如下:{
"mcpServers": {
"weather": {
"command": "/path/to/uv",
"args": [
"--directory",
"/absolute/path/to/weather",
"run",
"weather.py"
]
}
}
}
/path/to/uv 替换为您实际的 uv 可执行文件路径(可使用 which uv 查找)。/absolute/path/to/weather 替换为该项目的绝对路径。~/Library/Logs/Claude/mcp*.log。uv run weather.py)。该服务器使用国家气象局 API,具体信息如下:
| 属性 | 详情 |
|---|---|
| 基础 URL | https://api.weather.gov |
| 使用的端点 | /alerts/active/area/{state} - 根据州获取警报信息;/points/{lat},{lon} - 获取预测网格数据;/forecast - 获取详细预报 |
该项目遵循原始教程的许可声明:模型上下文协议
文档中未提供具体的屏幕截图内容。