Skip to main content
Glama
akdrione

Weather MCP Server

by akdrione

Weather MCP Server

OpenAPIサポートを備えた気象データ用のModel Context Protocol (MCP) サーバーです。このサーバーはOpenWeatherMap APIから気象情報を提供し、MCPを通じてLLMエージェントが利用できます。

機能

  • LLMエージェント統合のための MCP stdioトランスポート

  • OpenAPI 3.0仕様を備えた HTTP REST API

  • 4つの気象ツール:

    1. 都市名による現在の天気の取得

    2. 座標による現在の天気の取得

    3. 天気予報の取得(5日間、3時間間隔)

    4. 気温範囲の概要取得

  • APIキーなしでテストするための モックデータサポート

  • 完全な型安全性を備えた TypeScript 実装

インストール

cd weather-mcp-server
npm install
npm run build

使用方法

1. MCPサーバー (stdioトランスポート)

LLMエージェント用にMCPサーバーを実行します:

npm start

または開発モードで実行:

npm run dev

2. 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_here

MCPツール

サーバーは以下のMCPツールを提供します:

ツール名

説明

パラメータ

weather_get_current_by_city

都市名による現在の天気の取得

city: string

weather_get_current_by_coords

座標による現在の天気の取得

latitude: number, longitude: number

weather_get_forecast

天気予報の取得

city: string, days?: number (1-10, デフォルト: 5)

weather_get_temperature_range

気温範囲の概要取得

city: string

APIエンドポイント

HTTP REST API

すべてのエンドポイントは以下の構造のJSONを返します:

{
  "success": true,
  "data": { ... }
}

1. 都市名による現在の天気

GET /api/v1/weather/current/{city}

例:

curl http://localhost:3000/api/v1/weather/current/London

2. 座標による現在の天気

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 SDK

  • express - HTTPサーバーフレームワーク

  • axios - API呼び出し用HTTPクライアント

  • zod - スキーマバリデーション

  • typescript - TypeScriptコンパイラ

ライセンス

MIT

-
security - not tested
F
license - not found
-
quality - not tested

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