weather-alert-mcp-v2

weather-alert-mcp-v2

Enables querying live U.S. National Weather Service alerts by state through MCP, with both Python and TypeScript implementations.

Category
访问服务器

README

weather-alert-mcp v2 — one MCP tool, two implementations

An MCP (Model Context Protocol) server that exposes live U.S. National Weather Service alerts as a callable tool, so any MCP client — Claude Desktop, Claude Code, or an SDK client — can query active weather alerts by state.

Implemented twice: once in Python, once in TypeScript, against the same tool contract. A client cannot tell which one it is talking to. That is the point of building against a protocol rather than an API, and the two implementations are where the interesting parts of MCP become visible.

v1 (Python only) lives at weather-alert-mcp and is left untouched. This repo is the continuation.

The tool

Tool Argument Returns
get_alerts state — two-letter US state code (e.g. IL) Up to 5 active alerts: event, severity, affected area, headline

Data source: https://api.weather.gov/alerts/active — public, no API key, no signup.

The same contract, derived two ways

Python (server.py) TypeScript (ts/src/index.ts)
Schema source generated from type hints generated from a zod schema
Argument validation trusts the client's schema conformance validates at the boundary, rejects before any HTTP call
Transport stdio stdio
Offline mode WX_MOCK=1 WX_MOCK=1
Tool contract get_alerts(state) get_alerts(state) — identical

Both derive the JSON Schema the client sees from the implementation rather than maintaining it separately, so the contract cannot drift from the code.

The TypeScript server additionally validates at the protocol boundary. {"state": "Illinois"} comes back as a protocol-level error before any network request is made, so a malformed tool call costs nothing:

MCP error -32602: Input validation error: Invalid arguments for tool get_alerts

Python

pip install -r requirements.txt
python server.py                    # speaks MCP over stdio; a client launches this

Verify — test_client.py is a real MCP client: it spawns the server as a subprocess, completes the initialize handshake, lists the advertised tools, and calls one.

python test_client.py               # live
WX_MOCK=1 python test_client.py     # protocol only, no network
TOOLS:   ['get_alerts']
DESC:    Get active National Weather Service alerts for a US state.
SCHEMA:  {'properties': {'state': {'title': 'State', 'type': 'string'}}, 'required': ['state'], ...}

RESULT for IL:
Severe Thunderstorm Warning (Severe) — Lake County, IL
Severe Thunderstorm Warning issued for Lake County until 7:15 PM CDT

TypeScript

cd ts
npm install
npm run build
node build/index.js                 # speaks MCP over stdio

Verify — ts/test-client.mjs drives the same round trip and additionally asserts that a malformed argument is rejected:

cd ts
WX_MOCK=1 node test-client.mjs      # protocol only, no network
node test-client.mjs TX             # live NWS data
TOOLS:   [ 'get_alerts' ]
SCHEMA:  {"type":"object","properties":{"state":{"type":"string","minLength":2,"maxLength":2,
          "pattern":"^[A-Za-z]{2}$","description":"Two-letter US state code, e.g. \"IL\" or \"CA\""}},
          "required":["state"],"additionalProperties":false}

RESULT:
Severe Thunderstorm Warning (Severe) — Lake County, IL
Severe Thunderstorm Warning issued for Lake County until 7:15 PM CDT

VALIDATION: rejected bad input as expected — MCP error -32602: Input validation error

See ts/README.md for detail on the TypeScript implementation.


Use from Claude Desktop

Add either (or both) to claude_desktop_config.json:

{
  "mcpServers": {
    "weather-alerts": {
      "command": "python",
      "args": ["/absolute/path/to/server.py"]
    },
    "weather-alerts-ts": {
      "command": "node",
      "args": ["/absolute/path/to/ts/build/index.js"]
    }
  }
}

Both register the same tool name, so run one at a time unless you want to compare them.

Notes

  • stdout is the protocol channel. Anything written there corrupts the JSON-RPC stream, which is why startup logging goes to stderr.
  • Errors surface rather than being swallowed. An upstream API failure is raised to the client instead of returning "no alerts", which would be indistinguishable from a genuinely quiet state.
  • WX_MOCK=1 runs the full path with no network call — useful in CI, and for separating a protocol failure from an upstream API failure when something breaks.
  • Alerts are truncated to the first 5 features to keep tool output inside a reasonable context budget.

Known limitations

  • One read-only tool. No resources, no prompts, no sampling — the parts of MCP beyond tool registration are not exercised here.
  • stdio transport only; no HTTP/SSE transport.
  • The NWS endpoint requires a User-Agent; it is set to a contact string in both implementations, per the API's stated policy.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选