天气数据协议服务器

一个用于访问以色列气象局天气数据的模型上下文协议服务器,提供天气监测站信息、天气预报数据、天气警报等功能。

  • by GuyKh
  • Python
  • 混合部署
  • 1 星标
  • 更新于
在 GitHub 查看 GuyKh/ims-mcp

使用说明

IMS MCP服务器

用于访问以色列气象局(IMS)天气数据的模型上下文协议(MCP)服务器。

特性

  • 获取天气监测站的位置信息
  • 获取特定地点的天气预报数据
  • 检索当前天气警报
  • 访问当前天气分析
  • 获取风向映射
  • 检索天气状况代码描述
  • 访问综合城市门户信息

安装

使用紫外线(推荐)

# Clone the repository
git clone <repository-url>
cd ims-mcp-server

# Install using UV
uv pip install -e .

使用pip

pip install -e .

用法

运行服务器

服务器作为HTTP服务器运行,采用StreamableHttp传输:

# Run the server directly
python -m ims_mcp.server

# Or using uvicorn directly
uvicorn ims_mcp.server:app --host 0.0.0.0 --port 8000

# Or using the installed script
ims-mcp-server

码头工人

# Build the image
docker build -t ims-mcp-server .

# Run the container
docker run -p 8000:8000 ims-mcp-server

服务器端点

  • 职位/ -所有JSON-RPC通信的主MCP端点
  • GET/健康 -健康检查端点
  • 获取/信息 -服务器信息和可用端点

连接到服务器

服务器使用StreamableHttp传输进行MCP通信:

  1. MCP端点:通过POST将所有MCP消息发送到 http://localhost:8000/
  2. 内容类型: application/json
  3. 协议:JSON-RPC 2.0

MCP客户端配置示例:

{
  "name": "ims-weather",
  "type": "http",
  "url": "http://localhost:8000/"
}

示例用法

# Initialize connection
curl -X POST http://localhost:8000/ \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}'

# List available tools
curl -X POST http://localhost:8000/ \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}'

# Call a tool
curl -X POST http://localhost:8000/ \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "get_location_info", "arguments": {"language": "en"}}}'

可用工具

get_location_info

获取以色列可用天气监测位置的信息。

参数:

  • language (可选):语言代码(希伯来语“he”,英语“en”,默认:“he”)

获取预报数据

获取特定位置的天气预报数据。

参数:

  • location_id:位置信息中的位置ID
  • language (可选):语言代码(默认:“he”)

get_ims_alerts

从IMS获取当前天气警报。

参数:

  • language (可选):语言代码(默认:“he”)

get_weather_analysis

获取特定位置的当前天气分析。

参数:

  • location_id:当前天气分析的位置ID
  • language (可选):语言代码(默认:“he”)

get_wind_directions

获取风向代码及其方位映射。

参数:

  • language (可选):语言代码(默认:“he”)

get_weather_codes

获取天气状况代码及其完整描述。

参数:

  • language (可选):语言代码(默认:“he”)

get_city_portal

获取包括天气数据在内的全面位置信息。

参数:

  • location_id:完整位置信息的位置ID
  • language (可选):语言代码(默认:“he”)

API终点

服务器与以下IMS API端点交互:

  • https://ims.gov.il/{language}/locations_info -位置信息
  • https://ims.gov.il/{language}/forecast_data/{location_id} -预测数据
  • https://ims.gov.il/{language}/ims_alerts -天气警报
  • https://ims.gov.il/{language}/now_analysis/{location_id} -当前天气分析
  • https://ims.gov.il/{language}/wind_directions -风向图
  • https://ims.gov.il/{language}/weather_codes -天气状况代码
  • https://ims.gov.il/{language}/city_portal/{location_id} -完整位置信息

发展

安装开发依赖项

uv pip install -e ".[dev]"

运行测试

pytest

代码格式化

black src/
isort src/

类型检查

mypy src/

许可证

MIT许可证