使用说明
气象MCP服务器
概述
该项目实现了一个模型上下文协议(MCP)服务器,该服务器允许人工智能助手(如Claude)与美国国家气象局(NWS)API进行交互。服务器提供给定位置的实时天气警报和预报。
特性
- 检索美国特定州的活动天气警报。
- 获取指定纬度和经度的天气预报。
- 实现FastMCP框架,为AI交互提供工具。
使用的技术
- python
- FastMCP
- httpx(用于异步HTTP请求)
先决条件
在运行此项目之前,请确保您已经:
- 已安装Python(建议使用3.11.6或更高版本)
- uv包管理器(pip安装uv)
- 已安装httpx(pip安装httpx)
- 安装了fastmcp(pip安装fastmcp)
- 克劳德桌面应用程序
uv包管理器安装
# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh
# On Windows.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
添加到PATH
安装和设置
-
克隆存储库:
git clone https://github.com/ankushmehta123/weather-mcp-server.git -
安装依赖项:
pip install -r requirements.txt -
通过添加以下内容来配置MCP服务器
claude_desktop_config.json:"mcpServers": { "weather": { "command": "C:/Users/"enter_your_username"/.local/bin/uv.exe", "args": [ "--directory", "directory_location of main.py", "run", "main.py" ] } } }
用法
运行main.py
python main.py
可用的API工具
打开克劳德桌面,您会看到:2个可用的MCP工具(在搜索栏的右侧)
You can ask real-time weather-related questions to Claude now