这是一个借助国家气象局 API 来提供天气信息的 Model Context Protocol (MCP) 服务器。它能有效满足获取美国天气相关信息的需求,为用户提供便利。
uv
包管理器uv venv
source .venv/bin/activate # 在 Unix/macOS 上
# 或者
.venv\Scripts\activate # 在 Windows 上
uv pip install -e .
uv run weather-server
该服务器提供两个工具:
get_alerts(state)
: 获取某个美国州的天气警报
get_alerts("CA")
获取加利福尼亚州的警报信息get_forecast(latitude, longitude)
: 根据经纬度获取天气预报
get_forecast(38.5816, -121.4944)
获取萨克拉门托(CA)的预报信息要在 Claude for Desktop 中使用此服务器:
~/Library/Application Support/Claude/claude_desktop_config.json
文件{
"mcpServers": {
"weather": {
"command": "/Users/zhihaoouyang/.local/bin/uv",
"args": [
"--directory",
"/Users/zhihaoouyang/Desktop/code/weather",
"run",
"weather-server"
]
}
}
}
weather/
├── mcp-server/ # MCP 服务器实现
│ └── weather.py # 主程序代码
├── pyproject.toml # 项目配置和依赖
└── README.md # 本文件
此服务器使用国家气象局 API,仅支持获取美国境内的天气信息。