天气信息服务器

一个提供天气信息、日出日落时间和管理收藏城市的模型上下文协议(MCP)服务器。

  • by gautamrajur
  • Python
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 gautamrajur/MCP_Server

使用说明

气象MCP服务器

一种模型上下文协议(MCP)服务器,提供天气信息、日出/日落时间,并管理最喜欢的城市。

特性

工具

  • get_weather -获取任何城市的当前天气和温度
  • get_sunse_and_sunset_in_EST -获取EST时区的日出/日落时间
  • add_favorite_city -将城市添加到收藏夹列表

资源

  • 天气历史 -查看所有过去的天气查询
  • 最喜欢的城市 -访问您保存的喜爱城市

提示

  • 天气报告 -生成包含服装建议的详细天气报告
  • 比较城市 -比较多个城市的天气

设置

  1. 安装依赖项:
pip install mcp httpx python-dotenv
  1. 获取API密钥:

  2. 创建 .env 文件:

OPENWEATHER_API_KEY=your_key_here
  1. 创建数据目录:
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)

构建于

许可证

麻省理工学院