article
README
🚀 天气 MCP 服务器
一个使用 OpenWeatherMap API 提供天气信息的现代代码协议 (MCP) 服务器,能够帮助用户便捷地获取实时天气数据。
✨ 主要特性
- 实时数据检索:可实时获取最新的天气数据。
- 公制单位显示:温度采用公制单位进行显示。
- 详细天气信息:提供丰富的天气详情,涵盖温度、湿度、风速、日出/日落时间以及天气描述等内容。
📦 安装指南
使用 Smithery 安装
通过 Smithery 可自动安装 Weather MCP Server for Claude Desktop:
npx -y @smithery/cli install @CodeByWaqas/weather-mcp-server --client claude
手动安装
- 克隆仓库。
- 创建虚拟环境:
python -m venv .venv
source .venv/bin/activate # 在 Windows 上使用:.venv\Scripts\activate
- 安装依赖项:
pip install -e .
📚 详细文档
先决条件
- Python 3.12 或更高版本。
- OpenWeatherMap API 密钥。
设置说明
与 Claude Desktop 配合使用
# claude_desktop_config.json
# 可以通过以下位置找到位置:
# Claude -> Settings -> Developer -> Edit Config
{
"mcpServers": {
"mcp-weather-project": {
"command": "uv",
"args": [
"--directory",
"/<绝对路径>/weather-mcp-server/src/resources",
"run",
"server.py"
],
"env": {
"WEATHER_API_KEY": "YOUR_API_KEY"
}
}
}
}
本地/开发设置说明
- 克隆仓库:
git clone https://github.com/CodeByWaqas/weather-mcp-server
- 安装依赖项: 安装 MCP 服务器依赖:
cd weather-mcp-server
# 创建虚拟环境并激活它
uv venv
source .venv/bin/activate # MacOS/Linux
# 或者在 Windows 上
.venv/Scripts/activate
# 安装依赖
uv add "mcp[cli]" python-dotenv requests httpx
配置
- 复制
src/resources/env.example到src/resources/.env。 - 将你的 OpenWeatherMap API 密钥添加到
.env文件中:
WEATHER_API_KEY=your_api_key_here
使用方法
运行 Claude Desktop 并使用大语言模型(LLM)获取天气信息。
📄 许可证
此项目遵循 MIT 许可证 - 请查看 LICENSE 文件以获取详细信息。
Scan to contact