Weather MCP Server
Weather MCP Server
OpenAPIサポートを備えた気象データ用のModel Context Protocol (MCP) サーバーです。このサーバーはOpenWeatherMap APIから気象情報を提供し、MCPを通じてLLMエージェントが利用できます。
機能
LLMエージェント統合のための MCP stdioトランスポート
OpenAPI 3.0仕様を備えた HTTP REST API
4つの気象ツール:
都市名による現在の天気の取得
座標による現在の天気の取得
天気予報の取得(5日間、3時間間隔)
気温範囲の概要取得
APIキーなしでテストするための モックデータサポート
完全な型安全性を備えた TypeScript 実装
Related MCP server: mcp-openweather
インストール
cd weather-mcp-server
npm install
npm run build使用方法
1. MCPサーバー (stdioトランスポート)
LLMエージェント用にMCPサーバーを実行します:
npm startまたは開発モードで実行:
npm run dev2. OpenAPI付きHTTPサーバー
REST APIを備えたHTTPサーバーを実行します:
npm run dev:httpサーバーは http://localhost:3000 で起動し、以下が利用可能です:
/health- ヘルスチェックエンドポイント/openapi- OpenAPI仕様/api/v1/weather/current/{city}- 都市名による現在の天気/api/v1/weather/current/coordinates- 座標による現在の天気/api/v1/weather/forecast/{city}- 天気予報
3. 設定
OpenWeatherMap APIキーを設定します(オプション - 指定しない場合はモックデータが使用されます):
export OPENWEATHER_API_KEY=your_api_key_hereまたは .env ファイルを作成します:
OPENWEATHER_API_KEY=your_api_key_hereMCPツール
サーバーは以下のMCPツールを提供します:
ツール名 | 説明 | パラメータ |
| 都市名による現在の天気の取得 |
|
| 座標による現在の天気の取得 |
|
| 天気予報の取得 |
|
| 気温範囲の概要取得 |
|
APIエンドポイント
HTTP REST API
すべてのエンドポイントは以下の構造のJSONを返します:
{
"success": true,
"data": { ... }
}1. 都市名による現在の天気
GET /api/v1/weather/current/{city}例:
curl http://localhost:3000/api/v1/weather/current/London2. 座標による現在の天気
GET /api/v1/weather/current/coordinates?lat={latitude}&lon={longitude}例:
curl "http://localhost:3000/api/v1/weather/current/coordinates?lat=51.5074&lon=-0.1276"3. 天気予報
GET /api/v1/weather/forecast/{city}?days={days}例:
curl "http://localhost:3000/api/v1/weather/forecast/New%20York?days=3"テスト
テストスイートを実行します:
npm testデバッグ用にMCPインスペクターを実行します:
npm run inspectプロジェクト構造
weather-mcp-server/
├── src/
│ ├── index.ts # MCP stdio server
│ ├── http-server.ts # HTTP server with OpenAPI
│ ├── types/
│ │ └── weather.ts # TypeScript types and Zod schemas
│ ├── utils/
│ │ └── weather-client.ts # OpenWeatherMap API client
│ └── tools/
│ └── weather-tools.ts # MCP tool definitions
├── dist/ # Compiled JavaScript
├── test/
│ └── test.js # Test suite
├── package.json
├── tsconfig.json
└── README.md依存関係
@modelcontextprotocol/sdk- TypeScript用MCP SDKexpress- HTTPサーバーフレームワークaxios- API呼び出し用HTTPクライアントzod- スキーマバリデーションtypescript- TypeScriptコンパイラ
ライセンス
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Unofficial OpenWeather MCP — wraps the OpenWeatherMap API (openweathermap.org)
Weather MCP — wraps Open-Meteo API (free, no auth)
Weather, code search, currency & Solana trust scoring as MCP tools. Free, no API key needed.
Hosted MCP server for Xweather weather data: conditions, forecasts, alerts, and more.
Related MCP Servers
- FlicenseBqualityDmaintenanceEnables AI agents to retrieve real-time weather conditions and forecasts via OpenWeatherMap API. Supports interactive weather queries and travel planning through MCP tools, resources, and prompts.2-
- AlicenseNot gradedqualityBmaintenanceWraps the OpenWeatherMap API to provide weather data through MCP, enabling AI agents to query current conditions, forecasts, and other weather information via natural language.256 npmMIT
- AlicenseNot gradedqualityCmaintenanceProvides weather data from WeatherAPI.com through MCP, enabling AI agents to query current conditions and forecasts via natural language.146 npmMIT
- FlicenseBqualityDmaintenanceProvides real-time weather information for cities worldwide using the OpenWeatherMap API, accessible through natural language queries via the MCP protocol.1-