KNMI-MCP 荷兰气象查询工具
一个FastMCP服务器,提供来自荷兰皇家气象局(KNMI)气象站的实时天气数据,允许用户通过自然语言查询访问荷兰任何地点的温度、湿度、风速及其他天气指标。
可用工具 (4 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
get_location_weather 1 个参数 需填 1 项
Get current weather data for a location
必填参数:location
search_location 1 个参数 需填 1 项
Search for locations in the Netherlands Args: query: Search term for location
必填参数:query
get_nearest_station 2 个参数 需填 2 项
Find the nearest KNMI weather station to given coordinates Args: latitude: Latitude in degrees longitude: Longitude in degrees
必填参数:latitude、longitude
what_is_the_weather_like_in 1 个参数 需填 1 项
Get and interpret weather data for a location in the Netherlands Args: location: City or place name in the Netherlands Returns: A natural language interpretation of the current weather conditions
必填参数:location
服务介绍
KNMI 天气 MCP
一个 FastMCP 服务器,提供来自荷兰皇家气象研究所(KNMI)气象站的实时天气数据。此应用程序获取荷兰境内任何地点最近气象站的最新10分钟测量数据。
功能
- 获取荷兰境内任何地点的天气数据
- 自动找到最近的 KNMI 气象站
- 提供实时测量数据,包括:
- 温度
- 湿度
- 风速和风向
- 降水量
- 能见度
- 气压
- 天气状况的自然语言解释
- 地点搜索功能
- 详细的日志记录
前提条件
- Python 3.10 或更高版本
- KNMI API 密钥(从 KNMI 数据平台 获取)
uv包管理器
安装
-
克隆仓库:
git clone <repository-url> cd knmi-mcp -
在项目根目录下创建一个
.env文件:KNMI_API_KEY=your_api_key_here
运行服务器
使用 Claude AI
要与 Claude AI 一起使用此应用程序,请在项目文件夹中运行以下命令:
uv run fastmcp install src/knmi_weather_mcp/server.py
这会将以下配置添加到您的 Claude 配置文件中(通常位于 ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"KNMI Weather": {
"command": "uv",
"args": [
"run",
"--with",
"fastmcp",
"--with",
"httpx",
"--with",
"netCDF4",
"--with",
"numpy",
"--with",
"pandas",
"--with",
"pydantic",
"--with",
"python-dotenv",
"--with",
"xarray",
"fastmcp",
"run",
"/Users/<username>/<git location>/knmi-mcp/src/knmi_weather_mcp/server.py"
]
}
}
注意:如果您看到如下错误:
spawn uv ENOENT
请将 uv 命令替换为 uv 命令的完整路径。在 *nix 系统上,可以使用 which uv 命令找到该路径。
手动运行
对于开发或独立使用:
uv run fastmcp run src/knmi_weather_mcp/server.py
可用工具
1. what_is_the_weather_like_in
获取荷兰境内任何地点当前天气状况的自然语言解释。
示例:
await what_is_the_weather_like_in("Amsterdam")
2. get_location_weather
获取某个地点的原始天气数据。
示例:
await get_location_weather("Rotterdam")
3. search_location
搜索荷兰境内的地点。
示例:
await search_location("Utrecht")
4. get_nearest_station
查找给定坐标最近的 KNMI 气象站。
示例:
await get_nearest_station(52.3676, 4.9041)
日志
应用程序的日志存储在 logs/knmi_weather.log 文件中,提供以下详细信息:
- API 请求和响应
- 天气数据处理
- 错误消息
- 调试信息
数据来源
此应用程序使用 KNMI 数据平台 API 从 "Actuele10mindataKNMIstations" 数据集中获取数据,该数据集提供荷兰所有 KNMI 气象站每10分钟一次的测量数据。
错误处理
应用程序包括针对以下情况的强大错误处理:
- 无效位置
- API 认证问题
- 网络问题
- 数据解析错误
- 缺失测量值