Skip to main content
Glama
tengzhijian

Weather MCP

by tengzhijian

Weather MCP

CI npm version License: MIT

シンプルで使いやすい天気予報MCPツールで、CLIコマンドラインとMCPサーバーの両方の使用方法をサポートしています。

機能特性

  • 🌤️ リアルタイム天気照会 - 世界中のあらゆる都市の現在の天気を取得

  • 🔧 CLIサポート - コマンドラインから直接天気を照会

  • 🤖 MCPプロトコル - Claude、CursorなどのAIクライアントをサポート

  • 🌍 グローバル対応 - 中国語、英語など多言語の都市名に対応

  • ⚡ 無料API - Open-Meteoの無料天気サービスを使用、APIキー不要

  • 📝 型安全性 - TypeScript + Zodによる完全な型サポート

Related MCP server: Weather MCP Server

インストール

方法1:npmグローバルインストール(推奨)

npm install -g weather-mcp

方法2:npxで直接使用

npx weather-mcp weather 北京

方法3:ソースコードからインストール

git clone https://github.com/tengzhijian/weather-mcp.git
cd weather-mcp
npm install
npm run build

CLIの使用方法

# 查询天气
weather-mcp weather 北京
weather-mcp weather Shanghai

# 查看帮助
weather-mcp --help
weather-mcp --version

出力例

{
  "ok": true,
  "data": {
    "city": "北京 (中国)",
    "temperature": 22,
    "humidity": 70,
    "description": "多云",
    "windSpeed": 9.3,
    "updatedAt": "2024-01-15T08:30:00.000Z"
  }
}

MCPサーバーの設定

Claude Desktop

%APPDATA%/Claude/settings.json(Windows)または ~/Library/Application Support/Claude/settings.json(Mac)を編集します:

{
  "mcpServers": {
    "weather": {
      "command": "npx",
      "args": ["-y", "weather-mcp", "--mcp"]
    }
  }
}

Cursor

Cursorの Settings → MCP に以下を追加します:

{
  "mcpServers": {
    "weather": {
      "command": "npx",
      "args": ["-y", "weather-mcp", "--mcp"]
    }
  }
}

ローカル開発バージョン

ソースコードから実行する場合:

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["/path/to/weather-mcp/dist/index.js", "--mcp"]
    }
  }
}

利用可能なツール

getWeather

指定した都市の天気情報を照会します。

パラメータ:

  • city (string, 必須): 都市名。例:北京、上海、広州、London、Tokyo

戻り値:

  • city: 都市名(国名を含む)

  • temperature: 気温(摂氏)

  • humidity: 湿度(パーセント)

  • description: 天気の説明(晴れ、曇りなど)

  • windSpeed: 風速(km/h)

  • updatedAt: データ更新時刻

listSupportedCities

照会可能な都市リストの例を取得します。

戻り値:

  • cities: 一般的な都市リストの例

  • note: 備考(実際には世界中のあらゆる都市をサポートしています)

AIクライアントでの使用例

設定完了後、ClaudeやCursorなどのクライアントで直接質問できます:

"北京の今日の天気はどうですか?" "上海は明日雨が降りますか?" "ニューヨークの天気を調べて"

AIが自動的に getWeather ツールを呼び出して天気情報を取得します。

開発

# 安装依赖
npm install

# 开发模式
npm run dev weather 北京

# 运行测试
npm test

# 类型检查
npm run typecheck

# 构建
npm run build

技術スタック

プロジェクト構造

weather-mcp/
├── src/
│   ├── index.ts           # 入口文件
│   ├── cli.ts             # CLI 命令
│   ├── mcp-server.ts      # MCP Server
│   ├── weather-gateway.ts # 天气 API 封装
│   └── version.ts         # 版本号
├── tests/                 # 测试文件
├── .github/workflows/     # GitHub Actions
├── package.json
├── tsconfig.json
└── README.md

CI/CD

プロジェクトはGitHub Actionsを使用して自動化されています:

  • CI: PRおよびPushのたびにテストを自動実行(Node.js 18/20/22)

  • Release: 手動トリガーによるnpmへの公開

ライセンス

MIT

謝辞

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that provides real-time weather data, hourly forecasts, and daily summaries using the free Open-Meteo API with no API key required. It enables users to search for weather conditions by specific coordinates or city names across multiple measurement units.
    2
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A production-ready MCP server that provides real-time weather information, forecasts, and alerts to LLM clients using the Open-Meteo API, with support for 26+ global cities, dual transport (STDIO/HTTP), and Docker deployment.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    A no-API-key-required MCP server that wraps Open-Meteo APIs to provide geocoding and weather forecast data, enabling city lookups and multi-day forecasts through tools, resources, and prompts.
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A minimal MCP server that provides current weather and forecasts for any city using the free Open-Meteo API, no API key required.
    7 npm
    -