MCP开放气象服务器
用于访问Open Meteo天气数据和服务的综合模型上下文协议(MCP)服务器。该服务器提供多种工具与各种Open Meteo API进行交互,包括当前天气、预报、历史数据、空气质量、海洋天气和气候数据。
特性
🌤️ 气象服务
- 当前天气 -任何位置的实时天气状况
- 天气预报 -长达16天的详细小时和每日预报
- 历史天气 -过去的天气数据和综合统计数据
🌍 定位服务
- 地理编码 -搜索位置并获取坐标
- 反向地理编码 -从坐标中获取位置详细信息
🌊 环境数据
- 空气质量 -空气污染数据与空气质量指数(欧洲和美国)
- 海洋天气 -波高、洋流和海洋条件
- 气候数据 -长期气候预测和历史气候数据
📊 数据特征
- 多个温度单位(摄氏/华氏)
- 综合天气统计
- 空气质量健康建议
- 海上安全信息
- 气候模型比较
安装
地方发展
# Clone the repository
git clone
cd mcp-open-meteo
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm startDocker使用
构建并运行
# Build the Docker image
npm run docker:build
# Run the container
npm run docker:run使用Docker Compose
# Build and start with compose
npm run docker:up
# Stop the service
npm run docker:down
# View logs
npm run docker:logs用法
MCP配置
本地Node.js
将此服务器添加到MCP客户端配置中:
{
"mcpServers": {
"open-meteo": {
"command": "node",
"args": ["path/to/mcp-open-meteo/dist/index.js"]
}
}
}码头工人
{
"mcpServers": {
"open-meteo": {
"command": "docker",
"args": ["run", "--rm", "-i", "open-meteo-mcp-server"]
}
}
}Docker Compose
{
"mcpServers": {
"open-meteo": {
"command": "docker-compose",
"args": ["run", "--rm", "open-meteo-mcp"]
}
}
}可用工具
1.获取当前天气
获取任何位置的实时天气状况。
{
"name": "get_current_weather",
"arguments": {
"latitude": 40.7128,
"longitude": -74.0060,
"units": "celsius"
}
}参数:
latitude(必填):纬度坐标(-90到90)longitude(必填):经度坐标(-180至180)units(可选):温度单位(“摄氏”或“华氏”,默认值:“摄氏”)
2.获取天气预报
获取详细的天气预报,包括每小时和每天的数据。
{
"name": "get_weather_forecast",
"arguments": {
"latitude": 40.7128,
"longitude": -74.0060,
"days": 7,
"hourly": true,
"daily": true,
"units": "celsius"
}
}参数:
latitude(必填):纬度坐标(-90到90)longitude(必填):经度坐标(-180至180)days(可选):预测天数(1-16,默认值:7)hourly(可选):包括每小时预测(默认值:true)daily(可选):包括每日预测(默认值:true)units(可选):温度单位(默认值:“摄氏度”)
3.获取历史天气
检索历史天气数据进行分析。
{
"name": "get_historical_weather",
"arguments": {
"latitude": 40.7128,
"longitude": -74.0060,
"start_date": "2023-01-01",
"end_date": "2023-01-31",
"daily": true,
"hourly": false,
"units": "celsius"
}
}参数:
latitude(必填):纬度坐标(-90到90)longitude(必填):经度坐标(-180至180)start_date(必填):开始日期,格式为YYYY-MM-DDend_date(必填):YYYY-MM-DD格式的结束日期daily(可选):包括每日数据(默认值:true)hourly(可选):包括小时数据(默认值:false)units(可选):温度单位(默认值:“摄氏度”)
4.搜索地点
按名称查找位置并获取其坐标。
{
"name": "search_locations",
"arguments": {
"name": "New York",
"count": 10,
"language": "en"
}
}参数:
name(必填):要搜索的位置名称count(可选):最大结果数(1-100,默认值:10)language(可选):结果语言(默认值:“en”)
5.获得空气质量
检索空气质量数据和预报。
{
"name": "get_air_quality",
"arguments": {
"latitude": 40.7128,
"longitude": -74.0060,
"days": 3,
"current": true
}
}参数:
latitude(必填):纬度坐标(-90到90)longitude(必填):经度坐标(-180至180)days(可选):预测天数(1-5,默认值:3)current(可选):包括当前空气质量(默认值:true)
6.获取海洋天气
获取海洋天气预报,包括海浪和海洋状况。
{
"name": "get_marine_weather",
"arguments": {
"latitude": 40.7128,
"longitude": -74.0060,
"days": 7
}
}参数:
latitude(必填):纬度坐标(-90到90)longitude(必填):经度坐标(-180至180)days(可选):预测天数(1-7,默认值:7)
7.获取气候数据
获取气候变化情景和长期气候数据。
{
"name": "get_climate_data",
"arguments": {
"latitude": 40.7128,
"longitude": -74.0060,
"start_date": "2020-01-01",
"end_date": "2020-12-31",
"models": ["EC_Earth3P_HR", "FGOALS_f3_H"]
}
}参数:
latitude(必填):纬度坐标(-90到90)longitude(必填):经度坐标(-180至180)start_date(必填):开始日期,格式为YYYY-MM-DDend_date(必填):YYYY-MM-DD格式的结束日期models(可选):要使用的气候模型阵列
可用气候模型
EC_Earth3P_HR-EC-Earth3P-HR(高分辨率欧洲中心)FGOALS_f3_H-FGOALS-f3-H(中国科学院)HiRAM_SIT_HR-HiRAM SIT HR(美国国家海洋和大气管理局高分辨率)MRI_AGCM3_2_S-MRI-AGCM3-2-S(日本气象研究所)EC_Earth3P-EC-Earth3P(欧洲中心标准)FGOALS_f3-FGOALS-f3(中国科学院标准)MPI_ESM1_2_HR-MPI-ESM1-2-HR(马克斯·普朗克研究所高分辨率)MRI_AGCM3_2-MRI-AGCM3-2(日本气象研究所标准)
示例工作流
1.完成城市天气分析
# 1. First, search for the location
search_locations: {name: "London, UK"}
# 2. Get current weather
get_current_weather: {latitude: 51.5074, longitude: -0.1278}
# 3. Get 7-day forecast
get_weather_forecast: {latitude: 51.5074, longitude: -0.1278, days: 7}
# 4. Check air quality
get_air_quality: {latitude: 51.5074, longitude: -0.1278}2.历史天气分析
# Compare weather patterns between years
get_historical_weather: {
latitude: 40.7128,
longitude: -74.0060,
start_date: "2022-06-01",
end_date: "2022-08-31"
}
get_historical_weather: {
latitude: 40.7128,
longitude: -74.0060,
start_date: "2023-06-01",
end_date: "2023-08-31"
}3.航海海洋天气
# Check marine conditions before sailing
get_marine_weather: {latitude: 36.1699, longitude: -5.3543, days: 3}
get_weather_forecast: {latitude: 36.1699, longitude: -5.3543, days: 3}4.气候研究
# Long-term climate analysis
get_climate_data: {
latitude: 59.3293,
longitude: 18.0686,
start_date: "1990-01-01",
end_date: "2020-12-31",
models: ["EC_Earth3P_HR", "MPI_ESM1_2_HR"]
}数据源
此服务器使用以下Open Meteo API:
- 天气API -当前天气和预报
- 历史天气API -过去的天气数据
- 地理编码API -位置搜索和坐标
- 空气质量API -污染和空气质量数据
- API海洋天气 -海洋和波浪条件
- 气候API -长期气候数据和预测
发展
项目结构
src/
├── index.ts # Main MCP server
├── types/
│ └── openmeteo.ts # TypeScript types and schemas
└── tools/
├── current-weather.ts # Current weather tool
├── weather-forecast.ts # Weather forecast tool
├── historical-weather.ts # Historical weather tool
├── geocoding.ts # Location search tool
├── air-quality.ts # Air quality tool
├── marine-weather.ts # Marine weather tool
└── climate-data.ts # Climate data tool构建命令
# Install dependencies
npm install
# Build TypeScript
npm run build
# Start development server
npm run dev
# Watch for changes
npm run watch
# Clean build directory
npm run clean添加新工具
- 在中创建新的工具文件
src/tools/ - 导出一个处理工具逻辑的异步函数
- 将该工具添加到中的导入中
src/index.ts - 将工具定义添加到
ListToolsRequestSchema处理器 - 将工具箱添加到
CallToolRequestSchema处理器
API费率限制
Open Meteo API有以下速率限制:
- 免费套餐:每天10000个API调用
- 商业层:可用更高的限制
对于高容量使用,请考虑:
- 实施缓存机制
- 使用商业API进行更高的速率限制
- 尽可能分批处理请求
错误处理
服务器包括全面的错误处理:
- 所有参数的输入验证
- API错误响应处理
- 网络超时和重试逻辑
- 信息性错误消息
贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 如果适用,添加测试
- 提交拉取请求
许可证
MIT许可证-有关详细信息,请参阅许可证文件
致谢
支持
对于问题和疑问:
- 检查 打开Meteo文档
- 查看错误消息以获取具体指导
- 在此存储库中打开一个问题,以查找错误或功能请求
