天气数据服务

一个基于Model Context Protocol (MCP)的服务器,提供实时天气警报和预报数据,支持AI助手交互。

  • by ankushmehta123
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 ankushmehta123/weather-mcp-server

使用说明

气象MCP服务器

概述

该项目实现了一个模型上下文协议(MCP)服务器,该服务器允许人工智能助手(如Claude)与美国国家气象局(NWS)API进行交互。服务器提供给定位置的实时天气警报和预报。

特性

  • 检索美国特定州的活动天气警报。
  • 获取指定纬度和经度的天气预报。
  • 实现FastMCP框架,为AI交互提供工具。

使用的技术

  • python
  • FastMCP
  • httpx(用于异步HTTP请求)

先决条件

在运行此项目之前,请确保您已经:

  • 已安装Python(建议使用3.11.6或更高版本)
  • uv包管理器(pip安装uv)
  • 已安装httpx(pip安装httpx)
  • 安装了fastmcp(pip安装fastmcp)
  • 克劳德桌面应用程序

uv包管理器安装

# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh
# On Windows.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

添加到PATH

安装和设置

  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/"enter_your_username"/.local/bin/uv.exe",
             "args": [
                 "--directory",
                 "directory_location of main.py",
                 "run",
                 "main.py"
             ]
         }
     }
    }
    
    

用法

运行main.py python main.py

可用的API工具

打开克劳德桌面,您会看到:2个可用的MCP工具(在搜索栏的右侧)

You can ask real-time weather-related questions to Claude now