weather-mcp-server-js
🌤️ Weather MCP Server (Node.js)
Node.js / Express ベースのリモート MCP (Model Context Protocol) サーバーです。
Streamable HTTP transport を介して get_weather ツールを公開し、Claude Code などの MCP クライアントが任意の都市の現在の天気をリアルタイムに取得できるようにします。
天気データは wttr.in から取得します —— 無料、登録不要、API キー不要です。
✨ 機能特性
🛰️ リモート MCP サービス:公式
@modelcontextprotocol/sdkに基づく Streamable HTTP トランスポートを実装し、JSON と SSE の2つのレスポンスモードをサポート🌆 世界中の都市に対応:都市名(例:
Beijing、Tokyo、Paris)を直接渡すだけで現地の天気を取得できます🔌 完全なセッション管理:
Mcp-Session-Idを自動生成/検証し、セッションの確立、再利用、クローズ(DELETE)をサポート🧩 単一ファイルですぐ使える:データベース不要、設定ファイル不要、
server.js1つで起動できます
Related MCP server: MCP Weather Server — Demo
📦 環境要件
Node.js ≥ 18(
fetch内蔵、追加依存不要)
🚀 クイックスタート
# 1. 安装依赖
npm install
# 2. 启动服务(默认端口 3000)
npm start
# 后台运行(日志写入 logs/server.log)
npm run start:bg起動に成功すると、サービスアドレスは次のようになります:
http://localhost:3000/mcpよく使うスクリプト
命令 | 説明 |
| フォアグラウンドでサービスを起動 |
| バックグラウンドで起動し、ログを |
| 開発モード。ファイル変更で自動再起動 |
| 3000 番ポートでサービスが稼働しているか確認 |
| ログをリアルタイムで表示 |
| サービスを停止 |
| サービスを再起動 |
| バックグラウンドで再起動 |
🔌 MCP クライアントの設定
Claude Code または Streamable HTTP をサポートする他の MCP クライアントで、サービスをリモート MCP サーバーとして登録します。
Claude Code
MCP サーバーリストから追加します(/mcp → 追加 → HTTP):
{
"type": "http",
"url": "http://localhost:3000/mcp"
}JSON 設定ファイル方式
{
"mcpServers": {
"weather": {
"type": "http",
"url": "http://localhost:3000/mcp"
}
}
}🧰 提供されるツール
get_weather
指定された都市の現在の天気を取得します。
パラメータ
パラメータ | 型 | 必須 | 説明 |
| string | ✅ | 都市名。例: |
戻り値の例
当前 Beijing 的天气是晴(Sunny),温度 28°C(体感 30°C),湿度 45%,风速 12 km/h。⚙️ 実装の説明
セッション分離:各セッションは独立した
Server+transportインスタンスを保持します(SDK のconnect()は1つの transport のみサポート)。Mcp-Session-Idリクエストヘッダーで関連付けます。新規セッションフロー:
Mcp-Session-Idを含まない POST は初期化リクエストと見なされ、サーバーはセッション ID を生成してMcp-Session-Idレスポンスヘッダーで返します(CORS のexposedHeadersによりブラウザクライアントに明示的に公開されます)。互換性処理:セッション ID のない GET SSE プローブリクエストは、404/400 を返す代わりに開いた SSE ストリームを維持し、Claude Code などのクライアントが POST 初期化フローを続行できるようにします。
信頼性の高いエラー応答:天気 API の呼び出しに失敗した場合、リクエスト全体をクラッシュさせるのではなく、
isError: trueの結果を返します。
🗂️ プロジェクト構造
.
├── server.js # 全部服务逻辑(单文件)
├── package.json # 项目配置与脚本
├── logs/ # 运行时日志(已被 .gitignore 忽略)
└── LICENSE # MIT 许可证📄 ライセンス
This server cannot be deployed
Maintenance
Related MCP Connectors
Remote MCP server exposing SMI Aware tools, resources, and skills over Streamable HTTP.
Hosted MCP server for Xweather weather data: conditions, forecasts, alerts, and more.
Remote streamable-HTTP MCP server running on a single Cloudflare Worker. Your assistant gets live Airbnb, Amazon, Booking.com, Google Flights, Maps and Reddit data, social search on X, Instagram and TikTok, the Meta Ad Library, and image/video generation without any keys. Connect your own accounts to let it send WhatsApp or Telegram messages, work an IMAP inbox, manage Meta Ads campaigns and publish to X and LinkedIn. OAuth 2.1 with PKCE; stored credentials are AES-256-GCM encrypted.
The official Model Context Protocol server for Ambee. It gives any MCP-compatible AI assistant — Claude, ChatGPT, Cursor, VS Code, Ollama, and more direct access to live air quality, pollen, and weather data. To get started, including information on signing up and obtaining your Ambee key, check out the Ambee documentation on https://docs.ambeedata.com
Related MCP Servers
- FlicenseBqualityDmaintenanceA simple MCP server that provides a tool to fetch current weather information for cities using the Open-Meteo API, communicating through stdin/stdout.12-
- AlicenseNot gradedqualityDmaintenanceDemo MCP server that provides weather data for cities, with tools to get weather and list available cities.2MIT
- AlicenseAqualityDmaintenanceMCP server that provides current weather for any city using Open-Meteo APIs. It exposes a single tool 'get_weather' returning temperature, humidity, wind, and other weather data.19 npmMIT
- AlicenseAqualityDmaintenanceA simple MCP server that exposes a get_weather tool to fetch real-time weather for any GPS coordinates using the Open-Meteo API, no API key required.112 npmISC