使用说明
MCP气象服务器
按照以下步骤构建的简单MCP服务器 MCP官方快速入门教程.
显示两个工具:
get_alerts--获取美国某个州的活跃天气警报(两个字母的代码,例如。CA,TX)get_forecast--获取纬度/经度坐标的天气预报
数据来源于 美国国家气象局API (仅限美国地区)。
设置
# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create venv and install deps
uv venv
source .venv/bin/activate
uv add "mcp[cli]" httpx
# Run the server
uv run weather.py
Claude桌面配置
添加 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"weather": {
"command": "uv",
"args": ["--directory", "/ABSOLUTE/PATH/TO/mcp-weather-server", "run", "weather.py"]
}
}
}
查询示例
- “萨克拉门托的天气怎么样?”
- “德克萨斯州的活跃天气警报是什么?”