天气数据MCP服务器

一个专业的模型上下文协议(MCP)服务器,通过集成OpenWeatherMap API提供实时天气数据。

  • by abdirashid-dv
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Abdirashid-dv/kingkong-weather-mcp

使用说明

🦍 金刚气象MCP服务器

一个专业的模型上下文协议(MCP)服务器,通过OpenWeatherMap API集成提供实时天气数据。

特性

🌤️ 实时天气数据 -来自OpenWeatherMap API的实时天气
🌍 多种查询方法 -按城市名称、坐标或国家代码搜索
🌡️ 温度单位 -支持摄氏度、华氏度和开尔文温度
🛡️ 错误处理 -优雅的错误处理和有用的消息
📊 丰富的数据 -温度、湿度、风、大气压等
🔧 MCP标准 -完全符合MCP协议的工具和资源

快速开始

1.获取API密钥

  1. 访问 OpenWeatherMap
  2. 注册一个免费帐户
  3. 从仪表板获取API密钥

2.配置

在Smithery上部署时,系统将提示您输入:

  • API密钥:您的OpenWeatherMap API密钥(必需)
  • 默认单位:温度单位(摄氏度/华氏度/开尔文)
  • 超时:API请求超时(秒)

3.可用工具

get_current_weather

获取任何城市的当前天气

{
  "city": "London",
  "country_code": "GB",
  "units": "celsius"
}

get_weather_by_coordinates

通过地理坐标获取天气

{
  "latitude": 40.7128,
  "longitude": -74.0060,
  "units": "fahrenheit"
}

get_weather_summary

获取简明的天气摘要

{
  "city": "Tokyo"
}

check_api_status

验证API连接和配置

{}

4.资源

  • config://weather-api -API配置和功能
  • data://supported-cities -热门测试城市列表

示例用法

// Get London weather
await callTool("get_current_weather", {
  city: "London",
  country_code: "GB",
  units: "celsius"
});

// Get weather by coordinates (NYC)
await callTool("get_weather_by_coordinates", {
  latitude: 40.7128,
  longitude: -74.0060,
  units: "fahrenheit"
});

构建于

  • FastMCP -MCP服务器框架
  • OpenWeatherMap API -气象数据提供者
  • Python 3.11 -运行时环境

车间项目

该服务器是作为MCP研讨会演示的一部分构建的,展示了:

  • 真正的API集成模式
  • 专业错误处理
  • MCP协议最佳实践
  • 生产部署技术

🦍 由金刚为MCP社区建造!