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 実装
インストール
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
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/akdrione/weather-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server