Back to MCP directory
publicPublicdnsLocal runtime

MCP-Server-Weather-Alerts

一个基于MCP框架的天气服务器项目,提供美国特定地区的天气警报和预报功能,通过NWS API获取数据。

article

README

🚀 MCP 天气服务器

MCP 天气服务器基于 MCP(模型上下文协议)框架构建,借助美国国家气象局(NWS)API,可获取美国特定位置的天气警报与预报,为用户提供便利的天气信息服务。

🚀 快速开始

启动服务器

运行 MCP 天气服务器:

python weather.py

若服务器和客户端在同一台机器上,使用 stdio 传输:

uv run weather.py

✨ 主要特性

  • 获取天气警报:可检索特定美国州的活跃天气警报。
  • 获取天气预报:能获取特定纬度和经度位置的详细天气预报。

📦 安装指南

  1. 克隆仓库:
    git clone <repository-url>
    
  2. 进入项目目录:
    cd MCP Server/weather
    
  3. 安装依赖项:
    pip install -r requirements.txt
    

💻 使用示例

基础用法

1. 获取天气警报

使用 get_alerts 工具获取特定美国州的活跃天气警报。 参数

  • state:两位字母的美国州代码(例如,CA 表示加利福尼亚,NY 表示纽约)。 示例
{
  "tool": "get_alerts",
  "args": {
    "state": "CA"
  }
}

2. 获取天气预报

使用 get_forecast 工具获取特定位置的详细天气预报。 参数

  • latitude:位置的纬度(例如,34.0522 表示洛杉矶)。
  • longitude:位置的经度(例如,-118.2437 表示洛杉矶)。 示例
{
  "tool": "get_forecast",
  "args": {
    "latitude": 34.0522,
    "longitude": -118.2437
  }
}

高级用法

这些工具设计为由语言模型(LLM)通过客户端自动调用,当需要时与服务器交互以获取天气警报或预报。

🤝 贡献

欢迎提交问题或拉取请求来改进该项目。

📄 许可证

此项目遵循 MIT 许可证。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client