使用说明
气象MCP服务器
一种模型上下文协议(MCP)服务器,提供天气信息、日出/日落时间,并管理最喜欢的城市。
特性
工具
- get_weather -获取任何城市的当前天气和温度
- get_sunse_and_sunset_in_EST -获取EST时区的日出/日落时间
- add_favorite_city -将城市添加到收藏夹列表
资源
- 天气历史 -查看所有过去的天气查询
- 最喜欢的城市 -访问您保存的喜爱城市
提示
- 天气报告 -生成包含服装建议的详细天气报告
- 比较城市 -比较多个城市的天气
设置
- 安装依赖项:
pip install mcp httpx python-dotenv
-
获取API密钥:
- 注册于 OpenWeatherMap
- 获取免费的API密钥
-
创建
.env文件:
OPENWEATHER_API_KEY=your_key_here
- 创建数据目录:
mkdir -p weather_data
echo "[]" > weather_data/history.json
echo "[]" > weather_data/favorites.json
配置
添加到Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"weather": {
"command": "python3",
"args": ["/full/path/to/weather_mcp.py"]
}
}
}
文件结构
.
├── weather_mcp.py # Main MCP server
├── weather_data/
│ ├── history.json # Weather query history
│ └── favorites.json # Favorite cities list
└── .env # API key (not committed)
构建于
- MCP-SDK -模型上下文协议
- OpenWeatherMap API -天气数据
- Python 3.x
许可证
麻省理工学院