Skip to main content
Glama
mcp-weather

mcp-weather

by Kaushik2105

🌤️ Kaushik 的天气 MCP 服务器

TypeScript Model Context Protocol Node.js ![Tests](https://img.shields.io/badge/Tests-Passing-brightgreen.svg Claude Verified License: ISC

一个生产就绪的 Model Context Protocol (MCP) 服务器,使用 TypeScript 构建,将 LLM(如 Claude Desktop、Cursor 和自定义 AI 代理)连接到美国国家气象局(NWS / NOAA)的实时气象数据。


🔗 集成实时证明

🚀 已验证可与 Claude Desktop 配合使用:查看展示实时预报检索、警报和健康诊断的实时聊天会话:
👉 查看实时 Claude AI 聊天证明


Related MCP server: mcp-weather

✨ 架构亮点

  • 🏗️ 模块化整洁架构:解耦为专用服务层(CacheService、RateLimiterService、NwsClient、Logger、Formatter)。

  • 📡 官方气象公告:带有标准化元数据和提供方归属的结构化天气报告。

  • ⚡ 内存缓存(5 分钟 TTL):线程安全的内存缓存,可将上游 API 流量减少高达 80%。

  • 🛡️ 零漏洞安全层:严格的输入清理、XSS 实体转义和客户端隔离的速率限制(100 次请求/分钟)。

  • 🔁 弹性与容错:针对 HTTP 5xx / 429 错误自动进行指数退避重试,并带有请求超时保护。

  • 🩺 可观测性与诊断:内置 health_check、get_metrics 和 clear_cache 工具,并带有结构化 JSON 日志。


📁 项目结构

weather/
├── src/
│   ├── config/          # Central configuration & runtime constants
│   ├── services/        # Core business logic (Cache, RateLimiter, NwsClient, Formatter, Logger)
│   ├── tools/           # MCP Tool handlers (alerts, forecast, diagnostics)
│   ├── types/           # Strongly typed TypeScript interfaces
│   ├── utils/           # Input sanitization and security helpers
│   └── index.ts         # Server bootstrap, transport initialization & graceful shutdown
├── tests/
│   ├── unit/            # Unit test suites (utils, sanitizer, cache)
│   ├── integration/     # Upstream NWS API integration & retry tests
│   ├── performance/     # Cache throughput & rate-limiting load tests
│   ├── security/        # XSS, injection prevention & boundary tests
│   └── basic.test.ts    # Comprehensive test runner
├── build/               # Compiled ES module JavaScript distribution
├── package.json
└── tsconfig.json

🛠️ MCP 工具

工具

参数

描述

get_forecast

latitude(数字)、longitude(数字)

检索美国坐标的实时时段预报(温度、风力、天气状况)。

get_alerts

state(2 个字母的美国州代码,例如 CA、NY、TX)

获取活跃的恶劣天气警报、警告和气象公告。

health_check

无

返回运行时健康状态、运行时间、堆内存使用量、缓存大小和 API 连接状态。

get_metrics

无

输出性能诊断信息和活跃的速率限制客户端桶。

clear_cache

无

刷新内存缓存并返回已清除的条目数。


🚀 快速开始

1. 克隆并安装

git clone https://github.com/Kaushik2105/mcp-weather.git
cd mcp-weather
npm install

2. 构建

npm run build

3. 运行测试套件

npm test

🔌 连接到 Claude Desktop

将此配置添加到你的 Claude Desktop 配置文件中:

  • Windows:%APPDATA%\Claude\claude_desktop_config.json

  • macOS:~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "kaushik-weather": {
      "command": "node",
      "args": [
        "c:/Workholic/LawSikho/POCs/weather/weather/build/index.js"
      ]
    }
  }
}

注意:保存配置后,请重启 Claude Desktop。


💬 给 Claude 的示例提示

  • "使用 Kaushik 的天气工具显示洛杉矶(纬度:34.0522,经度:-118.2437)的官方预报公告"

  • "佛罗里达州(FL)目前有活跃的天气警报吗?"

  • "对 Kaushik 的天气 MCP 服务器运行健康检查诊断。"


👨💻 作者

Kaushik Karmakar

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      D
      maintenance
      Provides real-time US weather alerts and forecasts by integrating with the National Weather Service API. It enables AI assistants to fetch state-specific alerts and detailed local forecasts using geographic coordinates.
      2
      1
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides real-time weather alerts and forecasts from the National Weather Service for US locations, integrating with AI assistants via the Model Control Protocol.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides real-time weather alerts and forecasts for US locations by integrating with the National Weather Service API. Supports both server and client interactions with optional LLM summarization.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides weather forecasts and alerts for US locations via the National Weather Service API, enabling AI assistants to deliver real-time weather information.
      ISC