使用说明
气象MCP服务器
模型上下文协议(MCP)服务器,提供来自加拿大政府天气API的天气预报数据。
特性
- 通过提供纬度和经度获取加拿大任何地点的天气预报
- 轻松与Claude Desktop或任何兼容MCP的客户端集成
安装
先决条件
- Python 3.13或更高版本
- 布置 或另一个Python版本管理器(可选)
安装步骤
-
克隆此存储库:
git clone https://github.com/seanlf/weather-mcp.git cd weather-mcp -
设置虚拟环境(可选但推荐):
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
安装软件包和依赖项:
pip install -e .
用法
作为独立服务器运行
直接运行服务器:
python weather.py
与Claude Desktop集成
要与Claude Desktop集成,请执行以下操作:
- 编辑您的Claude Desktop配置(通常在
~/Library/Application Support/Claude/claude_desktop_config.json在 macOS 上:
{
"mcpServers": {
"weather": {
"command": "/path/to/python",
"args": [
"/path/to/weather-mcp/weather.py"
]
}
}
}
- 重新启动Claude Desktop以应用更改
与其他MCP主机一起使用
要与其他MCP主机一起使用,请将主机配置为执行 weather.py 使用Python 3.13或更高版本。
api参考
get_forecast(纬度:float,经度:float)->str
获取指定位置的5天天气预报。
参数:
latitude:位置纬度longitude:位置经度
退货:
- 包含5天预测的格式化字符串
Claude中的示例用法:
Please get the weather forecast for Ottawa, Canada (45.4215, -75.6972)
发展
运行测试
pytest
贡献
欢迎投稿!请随时提交拉取请求。
许可证
此项目根据存储库中包含的许可条款获得许可。