使用说明
MCP气象服务器
模型上下文协议(MCP)服务器,提供来自美国国家气象局API的实时天气预报和警报。
特性
可用工具:
get_alerts(state)-获取美国任何州的活跃天气警报get_forecast(latitude, longitude)-获取特定坐标的详细5天天气预报
安装
先决条件
安装UV包管理器:
macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
窗户:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
设置
- 克隆存储库:
git clone https://github.com/yourusername/mcp-weather-server
cd mcp-weather-server
- 安装依赖项:
uv sync
或手动:
uv add mcp httpx
用法
本地运行
测试服务器:
uv run weather.py
服务器将在stdio模式下运行,并等待MCP客户端连接。
连接到克劳德桌面
-
打开Claude Desktop配置文件:
macOS:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
窗户:
code $env:AppData\Claude\claude_desktop_config.json
- 添加天气服务器:
{
"mcpServers": {
"weather": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/mcp-weather-server",
"run",
"weather.py"
]
}
}
}
重要提示: 替换 /ABSOLUTE/PATH/TO/mcp-weather-server 你的实际路径。
-
重新启动克劳德桌面
现在你应该看到天气工具了(🔌 图标)。
连接到Cursor IDE
- 打开光标设置→ MCP
- 添加以下配置:
{
"mcpServers": {
"weather": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/mcp-weather-server",
"run",
"weather.py"
]
}
}
}
- 重新启动游标
查询示例
试着问克劳德或Cursor:
- “加利福尼亚州的天气警报是什么?”
- 给我纽约市的天气预报(纬度40.7128,经度-74.0060)
- “得克萨斯州有任何恶劣天气预警吗?”
需求
- Python 3.12+
- httpx
- 主控程序
许可证
麻省理工学院
贡献
欢迎拉取请求!对于重大更改,请先打开一个问题。