天气数据服务器

DWD MCP Server是一个通过Bright Sky API提供德国气象局天气数据的模型上下文协议服务器,支持实时天气、天气预报、天气警报和气象站查询功能。

  • by jimimatt
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 jimimatt/dwd-mcp-server

使用说明

DWD MCP服务器

MCP服务器(模型上下文协议),用于通过以下方式从德国气象局(DWD)获取天气数据 蓝天API.

特性

  • 当前天气 (get_current_weather)-温度、风、降水、云量等。
  • 天气预报 (get_weather_forecast)-每小时预测和每日总结
  • 天气警报 (get_weather_alerts)-官方DWD警告(风暴、雷暴、霜冻等)
  • 气象站 (find_weather_station)-查找最近的DWD站

安装

紫外线(推荐)

# Clone repository
git clone https://github.com/your-username/dwd-mcp-server.git
cd dwd-mcp-server

# Install dependencies
uv sync

# Development dependencies (optional)
uv sync --extra dev

使用pip

pip install -e .

# With development dependencies
pip install -e ".[dev]"

用法

以MCP服务器身份启动

# With uv
uv run dwd-mcp-server start

# Or directly with Python
python -m dwd_mcp_server.cli start

与Claude Desktop集成

将以下配置添加到您的Claude桌面 config.json:

{
  "mcpServers": {
    "dwd-weather": {
      "command": "uv",
      "args": ["--directory", "/path/to/dwd-mcp-server", "run", "dwd-mcp-server", "start"]
    }
  }
}

与Claude Code集成

claude mcp add dwd-weather -- uv --directory /path/to/dwd-mcp-server run dwd-mcp-server start

MCP工具

get_current_weather

获取某个地点的当前天气。

参数:

  • location (字符串,必填):城市名称(例如“亚琛”、“慕尼黑”)或坐标(例如“50.7753,6.0839”)

示例响应:

{
  "timestamp": "Sat, 15.02.2026 14:00",
  "temperature_c": 8.2,
  "feels_like_c": 5.5,
  "humidity_percent": 78,
  "wind_speed_kmh": 22.3,
  "wind_direction": "W",
  "precipitation_mm": 0.0,
  "cloud_cover_percent": 75,
  "condition": "cloudy",
  "station_name": "Aachen-Orsbach"
}

get_weather_forecast

获取某个地点的天气预报。

参数:

  • location (字符串,必填):城市名称或坐标
  • days (整数,可选):天数(1-10,默认值:3)

退货: 每小时数据和每日总结,包括最低/最高温度。

get_weather_alerts

获取官方天气警报。

参数:

  • location (字符串,可选):城市名称或坐标。如果省略:所有针对德国的警报。

退货: 活动警报列表,包括类型、严重性、描述和有效期。

find_weather_station

查找最近的DWD气象站。

参数:

  • location (字符串,必填):城市名称或坐标

退货: 包含名称、ID和距离的站点列表。

地理编码

服务器接受各种位置输入:

  1. 直接坐标: "50.7753,6.0839" 或 "50.7753, 6.0839"
  2. 德国城市: "Aachen", "Munich", "Cologne" (包括约100个城市)
  3. 提名回退: 对于未知位置,查询OpenStreetMap/Nomingim

测试

# With uv
uv run pytest

# With pytest directly
pytest

技术栈

  • MCP框架: mcp Python SDK (快速MCP)
  • HTTP客户端: httpx(异步)
  • 数据来源: 蓝天API (DWD开放数据)
  • 地理编码: 内置城市表+提名回退

许可证

麻省理工学院

数据源