Token导航 LogoToken导航TokenDH.com
MCP Weather Alert Tool logo
AI代理stdio官方级别未说明来源级核验

MCP Weather Alert Tool

MCP Server

一个基于FastMCP和Claude Desktop的天气警报工具,通过api.weather.gov API获取美国各州的实时天气警报信息。

工具数

1

提示词数

0

GitHub Stars

1

资源数

0
天气警报API集成PythonClaudeClaude DesktopClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

nahilahmed

提供方

nahilahmed

最后核验

2026/5/17 20:22

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run mcp dev server/weather.py

详细介绍

🌩️ 使用FastMCP+Claude桌面的MCP天气警报工具

该项目演示了如何构建 MCP(模型上下文协议) 使用官方工具 FastMCP Python SDK。它与 克劳德桌面 使AI助手能够检索 天气警报 美国各州通过 api.weather.gov API

______________________________________________________________________

🚀 这个项目做什么

  • ✅ 实现自定义MCP服务器 FastMCP
  • 🌐 用途 httpx 从以下位置调用实时天气警报 api.weather.gov
  • 📦 返回结构化信息:事件、严重性、描述和指令
  • 🧠 与Claude Desktop集成
  • 🌈 可以通过MCP Inspector进行交互式测试

______________________________________________________________________

🧱 技术栈

工具/库目的
mcp[cli]带CLI工具的MCP服务器工具包
httpx异步HTTP客户端
uv现代Python包/依赖管理器
Claude DesktopLLM+MCP的人工智能界面
MCP检查器调试MCP端点的UI

______________________________________________________________________

📁 项目结构

mcpcrashcourse/
├── server/
│   └── weather.py         # MCP server logic (get_alerts)
├── pyproject.toml         # Project metadata + dependencies
├── uv.lock                # Locked versions (auto-generated by uv)
└── README.md              # You're reading it!

______________________________________________________________________

🧠 工具逻辑: get_alerts

@mcp.tool()
async def get_alerts(state: str) -> list[dict]:
    # Fetch weather alerts for a given U.S. state (e.g., 'CA')
    url = "https://api.weather.gov/alerts/active"
    params = {"area": state.upper()}
    async with httpx.AsyncClient() as client:
        response = await client.get(url, params=params)
        data = response.json()

    return [
        {
            "event": alert.get("event"),
            "severity": alert.get("severity"),
            "description": alert.get("description"),
            "instruction": alert.get("instruction"),
        }
        for alert in data.get("features", [])
        if alert.get("properties")
    ]

______________________________________________________________________

🛠️ 安装和设置

1.创建和配置项目

pipx install uv               # install uv if you haven't
uv init mcpcrashcourse        # start new project
cd mcpcrashcourse
uv add "mcp[cli]" httpx       # add dependencies

2.添加您的工具

放置您的 weather.pyserver/ 文件夹,包含以下逻辑 get_alerts.

______________________________________________________________________

🧪 运行和检查

使用MCP Inspector启动

uv run mcp dev server/weather.py

然后打开 http://localhost:6757 致:

  • 查看您的 get_alerts 工具
  • 尝试使用输入调用它,如下所示 "TX"

______________________________________________________________________

🤖 Claude桌面集成

  1. 更新您的 claude_desktop_config.json:
{
  "mcpServers": {
    "weather": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "/server/weather.py"
      ]
    }
  }
}
  1. 重新启动克劳德桌面
  2. 提示:

> “德克萨斯州的天气警报是什么?”

Claude将调用您的MCP工具并显示结构化输出。

______________________________________________________________________

💡 什么是MCP?

模型上下文协议 规范应用程序的发送方式 上下文 (数据、工具、提示)发送给LLM。它将 “上下文提供程序” 从LLM层开始。

三个核心图元:

类型用例类比
工具执行函数POST端点
资源提供静态数据GET端点
提示可重用交互LLM模板

______________________________________________________________________

📎 鸣谢

______________________________________________________________________

📄 许可证

这个项目是在MIT许可证下开源的。

目录标签

目录标签

天气警报API集成PythonClaudeClaude Desktop本地部署MCP工具AI助手

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

1

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP