weather-alert-mcp-v2
weather-alert-mcp v2 — 1つのMCPツール、2つの実装
米国国立気象局のリアルタイムの気象警報を呼び出し可能なツールとして公開するMCP(Model Context Protocol)サーバー。Claude Desktop、Claude Code、SDKクライアントなど、あらゆるMCPクライアントが州別にアクティブな気象警報を照会できます。
2回実装されています。1回はPython、もう1回はTypeScriptで、同じツール契約に基づいています。クライアントはどちらと通信しているかを区別できません。これがAPIではなくプロトコルに基づいて構築する意味であり、この2つの実装こそがMCPの興味深い部分です。
v1(Pythonのみ)はweather-alert-mcpにあり、変更されていません。このリポジトリはその続きです。
ツール
ツール | 引数 | 戻り値 |
|
| 最大5件のアクティブな警報:イベント、深刻度、影響地域、見出し |
データソース:https://api.weather.gov/alerts/active — 公開、APIキー不要、サインアップ不要。
同じ契約、2つの方法で導出
Python( | TypeScript( | |
スキーマソース | 型ヒントから生成 |
|
引数検証 | クライアントのスキーマ準拠を信頼 | 境界で検証し、HTTP呼び出しの前に拒否 |
トランスポート | stdio | stdio |
オフラインモード |
|
|
ツール契約 |
|
|
どちらも、クライアントが見るJSONスキーマを別途保守するのではなく、実装から導出するため、契約がコードから乖離することはありません。
TypeScriptサーバーはさらに、プロトコル境界で検証します。{"state": "Illinois"}はネットワークリクエストが行われる前にプロトコルレベルのエラーとして返されるため、不正なツール呼び出しはコストがかかりません:
MCP error -32602: Input validation error: Invalid arguments for tool get_alertsPython
pip install -r requirements.txt
python server.py # speaks MCP over stdio; a client launches this検証 — test_client.pyは実際のMCPクライアントです。サーバーをサブプロセスとして起動し、initializeハンドシェイクを完了し、アドバタイズされたツールを一覧表示し、1つを呼び出します。
python test_client.py # live
WX_MOCK=1 python test_client.py # protocol only, no networkTOOLS: ['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 CDTTypeScript
cd ts
npm install
npm run build
node build/index.js # speaks MCP over stdio検証 — ts/test-client.mjsは同じラウンドトリップを実行し、さらに不正な引数が拒否されることを検証します:
cd ts
WX_MOCK=1 node test-client.mjs # protocol only, no network
node test-client.mjs TX # live NWS dataTOOLS: [ '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 errorTypeScript実装の詳細はts/README.mdを参照してください。
Claude Desktopから使用する
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"]
}
}
}どちらも同じツール名を登録するため、比較しない限りは一度に1つずつ実行してください。
メモ
stdoutはプロトコルチャネルです。 ここに何かを書き込むとJSON-RPCストリームが破損するため、起動ログはstderrに出力されます。エラーは握りつぶさずに表面化されます。 上流のAPI障害は「警報なし」を返すのではなくクライアントに通知されます。「警報なし」は実際に静かな状態と区別がつかないためです。
WX_MOCK=1はネットワーク呼び出しなしで完全なパスを実行します — CIで役立ち、問題発生時にプロトコル障害と上流API障害を切り分けるのに役立ちます。警報は最初の5フィーチャーに切り詰められ、ツール出力が妥当なコンテキスト予算内に収まるようにしています。
既知の制限事項
読み取り専用ツールが1つ。リソース、プロンプト、サンプリングはありません。ツール登録以外のMCPの部分はここでは使用されていません。
stdioトランスポートのみ。HTTP/SSEトランスポートはありません。
NWSエンドポイントは
User-Agentを必要とします。APIの規定ポリシーに従い、両実装で連絡先文字列に設定されています。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Get US weather forecasts, active alerts, and current observations.
US weather, alerts, earthquakes and elevation for AI agents, from NWS/NOAA and USGS. No API keys.
US weather & geo for AI agents: forecasts, alerts, earthquakes, elevation, geocoding. No keys.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rainygold25/weather-alert-mcp-v2'
If you have feedback or need assistance with the MCP directory API, please join our Discord server