中国天气MCP服务器

中国天气MCP服务器

提供中国城市实时天气信息的MCP服务器,基于高德天气API。

快速入门

安装

  1. 确保已安装 Python 3.12 或更高版本。
  2. 安装 uv 工具: curl -LsSf https://astral.sh/uv/install.sh | sh
  3. 克隆仓库: git clone https://github.com/DLYZZT/china-weather-mcp-server.git cd china-weather-mcp-server
  4. 使用 uv 安装依赖: uv pip install .

配置

  1. 高德开放平台 获取 API 密钥。
  2. 设置环境变量: export AMAP_API_KEY="你的API密钥"

使用

在 Claude Desktop 配置文件中添加以下内容:

Windows: %APPDATA%/Claude/claude_desktop_config.json MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{ "mcpServers": { "weather": { "command": "uv", "args": [ "--directory", "path/china-weather-mcp-server", "run", "weather.py" ], "env": { "AMAP_API_KEY": "你的API密钥" } } } }

启动后,使用 get_weather(city: str) 查询指定城市的天气信息。