Back to MCP directory
publicPublicdnsLocal runtime

weather-mcp-server-tuo

该项目实现了一个与NWS API交互的MCP服务器,为AI助手提供实时天气警报和预报功能。

article

README

🚀 模型上下文协议(MCP)天气服务器

本项目实现了一个模型上下文协议(MCP)服务器,该服务器可让AI助手(如Claude)与美国国家气象局(NWS)API进行交互,从而为用户提供指定位置的实时天气警报和预报,极大地提升了获取天气信息的便捷性。

🚀 快速开始

运行本项目前,您需要完成一系列的准备工作,包括安装必要的依赖和配置服务器。以下是详细步骤:

先决条件

在运行本项目之前,请确保安装了以下内容:

  • Python(推荐版本3.11.6或更高)
  • uv包管理器(pip install uv)
  • httpx安装(pip install httpx)
  • fastmcp安装(pip install fastmcp)
  • Claude桌面应用程序

uv包管理器安装:

# 适用于macOS和Linux。
curl -LsSf https://astral.sh/uv/install.sh | sh
# 适用于Windows。
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

将路径添加到系统环境变量中

安装与配置

  1. 克隆仓库:
    git clone https://github.com/ankushmehta123/weather-mcp-server.git
    
  2. 安装依赖项:
    pip install -r requirements.txt
    
  3. 配置您的MCP服务器,将以下内容添加到 claude_desktop_config.json 文件中:
    {
     "mcpServers": {
         "weather": {
             "command": "C:/Users/your_username/.local/bin/uv.exe",
             "args": [
                 "--directory",
                 "main.py所在的目录位置",
                 "run",
                 "main.py"
             ]
         }
     }
    }
    

使用方法

运行 main.py

python main.py

可用的API工具

在Claude桌面应用程序中,您会看到右侧搜索栏旁有2个MCP工具可用。

图像描述

现在您可以向Claude提出与天气相关的问题了。

✨ 主要特性

  • 获取特定美国州份的活跃天气警报:用户可以通过该服务器获取美国特定州份当前的活跃天气警报,及时了解当地的天气异常情况。
  • 拉取指定纬度和经度的天气预报:支持根据用户指定的纬度和经度,精准拉取当地的天气预报信息。
  • 实现FastMCP框架以公开AI交互工具:借助FastMCP框架,将AI交互工具公开,方便用户与服务器进行交互。

🔧 技术细节

本项目使用了以下技术来构建和运行:

  • Python:作为主要的开发语言,提供了丰富的库和工具,方便进行服务器开发和数据处理。
  • FastMCP:实现了模型上下文协议(MCP),为AI助手与服务器之间的交互提供了基础框架。
  • httpx:用于异步HTTP请求,提高了服务器与美国国家气象局(NWS)API之间的数据交互效率。
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