Skip to main content
Glama
RashJrEdmund

weather-mcp

by RashJrEdmund

プレビュー画像

weather-mcp

OpenWeatherMapをバックエンドとする天気ツールを公開するTypeScript製MCPサーバーです。

ツール

ツール

説明

get_current_weather

都市名または緯度/経度による現在の天気

get_forecast

緯度/経度による5日間/3時間ごとの予報

トランスポート

モード

環境変数

使用場面

stdio(デフォルト)

TRANSPORT=stdio

ローカルのCursor / Claude Desktop

Streamable HTTP

TRANSPORT=http

デプロイ(Renderなど)/ リモートURL

公式MCPドキュメント:https://modelcontextprotocol.io/docs/

ライブリモート(Render)

Renderの無料枠にデプロイされています:

Cursor設定(リモート)

これを設定 → MCPまたは~/.cursor/mcp.jsonに追加してください:

{
  "mcpServers": {
    "weather": {
      "url": "https://weather-mcp-ts.onrender.com/mcp"
    }
  }
}

CursorでのローカルビルドやAPIキーは不要です。キーはRenderの環境変数にあります。

Renderの無料枠: サービスは非アクティブ状態が約15分続くとシャットダウンします。次のリクエストはコールドスタートとなり、MCPが応答するまで最大約50秒かかることがあります。Cursorツールが起動中に固まっているように見える場合は、/healthに一度アクセスしてください。

Related MCP server: mcp-weatherapi

前提条件(ローカルのみ)

セットアップ(ローカル)

pnpm install
cp .env.example .env

.envを編集してキーを設定してください:

OPEN_WEATHER_MAP_API_KEY=your_key_here
TRANSPORT=stdio

サーバーをビルドします:

pnpm run build

これにより、実行可能なエントリーポイントがdist/index.jsに書き込まれます。

Cursorへの追加(ローカルstdio)

Cursorはデフォルトではプロジェクトルートからこのプロセスを起動しないため、envファイルが読み込まれません。Node.jsの--env-fileフラグを使用してenvファイルを絶対パスで指定してください。

  1. Cursorの設定 → MCPを開くか、~/.cursor/mcp.jsonを編集します。

  2. mcpServersの下にweatherエントリを追加します:

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": [
        "--env-file",
        "/ABSOLUTE/PATH/TO/weather-mcp/.env",
        "/ABSOLUTE/PATH/TO/weather-mcp/dist/index.js"
      ]
    }
  }
}

/ABSOLUTE/PATH/TO/weather-mcpを実際のプロジェクトパスに置き換えてください(例:リポジトリのルートでpwdを実行)。.envではTRANSPORT=stdioのまま(または未設定のまま)にしてください。

別の方法:envのインライン指定

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": [
        "/ABSOLUTE/PATH/TO/weather-mcp/dist/index.js"
      ],
      "env": {
        "OPEN_WEATHER_MAP_API_KEY": "your_key_here",
        "TRANSPORT": "stdio"
      }
    }
  }
}

キーがmcp.jsonに含まれないようにするため、.env + --env-fileの使用を推奨します。

  1. 保存してから、設定 → MCPでサーバーをオフ/オンに切り替えてください(またはCursorを再起動)。

  2. サーバーが接続済みと表示され、get_current_weatherget_forecastが一覧に表示されることを確認してください。

コード変更後

pnpm run build

その後、CursorでMCPサーバーをリロードしてください。

Streamable HTTP(ローカル)

HTTPモードでは、MCPをPOST/GET /mcp(設定可能)で提供し、さらにGET /healthも提供します。Streamable HTTPは公式SDKのcreateMcpHandler + toNodeHandlerを介して設定されます。

pnpm run build
TRANSPORT=http PORT=3000 pnpm run start
# or
pnpm run start:http

次のような表示が確認できるはずです:

Weather MCP Server running on http://0.0.0.0:3000/mcp (Streamable HTTP)

Renderへのデプロイ

  1. このリポジトリ(プロジェクトのルート)からWeb Serviceを作成します。

  2. ビルド:pnpm install && pnpm run build(またはnpm相当のコマンド)

  3. 起動:node dist/index.js(またはpnpm run start

  4. 環境変数:

    • TRANSPORT=http

    • OPEN_WEATHER_MAP_API_KEY=...

    • PORTはRenderが自動的に設定します

  5. MCP URL:https://<your-service>.onrender.com/mcp
    このデプロイ:https://weather-mcp-ts.onrender.com/mcp

HTTPエンドポイントは認証なしです。URLを知っている人は誰でもツールを呼び出せます。広く共有する前に認証を追加してください。

手動スモークテスト(OpenWeatherMap)

.envが設定されていれば:

node --env-file=.env -e "
import { getApiKey, buildCurrentWeatherUrl, makeOWMRequest, formatCurrentWeather } from './dist/utils.js';
const apiKey = getApiKey();
const data = await makeOWMRequest(buildCurrentWeatherUrl({ apiKey, city: 'Yaounde,CM', units: 'metric' }));
console.log(data ? formatCurrentWeather(data, 'metric') : 'failed');
"

リモートのヘルスチェック:

curl -s https://weather-mcp-ts.onrender.com/health

リポジトリ構成

weather-mcp/
├── README.md
├── package.json
├── tsconfig.json
├── .env.example
└── src/
    ├── index.ts      # stdio + Streamable HTTP entry
    ├── server.ts     # tool registration
    ├── types.ts
    └── utils.ts

注意事項

  • .envは絶対にコミットしないでください(gitignoreされています)。

  • StdioサーバーはMCP JSON-RPC以外をstdoutに書き出してはいけません。ログはstderr(console.error)に出力します。

  • OpenWeatherMapの無料プランには、ここで使用している現在の天気と5日間/3時間ごとの予報が含まれています。

ライセンス

ISC

F
license - not found
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • OpenWeather MCP — wraps the OpenWeatherMap API (openweathermap.org)

  • WeatherAPI.com MCP — wraps WeatherAPI.com (api.weatherapi.com)

  • Visual Crossing Weather MCP — wraps the Visual Crossing Weather Timeline API

View all MCP Connectors

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/RashJrEdmund/Weather-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server