Back to MCP directory
publicPublicdnsLocal runtime

weather-mcp-server-cyu

一个通过国家气象局API获取天气数据的MCP服务器,提供天气警报和短期预报功能。

article

README

🚀 天气 MCP 服务器

此 MCP 服务器可从国家气象局 API 处获取天气数据。它提供了两个实用工具,能帮助用户快速获取所需的天气信息:

  • get_alerts(state: str):可返回指定美国州(使用其两位字母代码)当前生效的天气警报。
  • get_forecast(latitude: float, longitude: float):能返回指定位置的短期天气预报。

✨ 主要特性

  • 从国家气象局 API 获取权威天气数据。
  • 提供获取天气警报和短期天气预报两个实用工具。

📦 安装指南

需求

  • Python 3.7+
  • httpx
  • MCP 框架 mcp[cli]

安装命令

使用以下命令进行安装:

uv add mcp[cli] httpx requests

💻 使用示例

基础用法

运行服务器

使用以下命令运行服务器:

uv run weather.py

该服务器通过标准输入输出进行通信。

MCP 客户端配置

你的 MCP 客户端配置示例(config.json)如下:

{
  "mcpServers": {
    "weather": {
      "command": "C:/path/to/your/uv",
      "args": [
        "--directory",
        "C:/path/to/your/project",
        "run",
        "weather.py"
      ]
    }
  }
}
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