Skip to main content

cwa-mcp-server

MCP server,包中央氣象署(CWA)開放資料 API,讓 agent 能查天氣預報、地震報告、天氣特報、颱風警報,並產生避難建議。

功能

  • Tool get_weather_forecast(county) — 縣市未來 36 小時天氣預報
  • Tool get_earthquake_report(limit) — 最近 N 筆顯著有感地震報告
  • Tool get_weather_warning(county) — 縣市目前生效中的天氣特報(豪雨、強風等)
  • Tool get_typhoon_warning(limit) — 最近 N 筆颱風警報
  • Resource cwa://counties — 合法縣市名稱清單
  • Prompt evacuation_advisory(county) — 根據即時天氣/特報/地震/颱風資料生成避難建議的提示模板

申請 API Key

  1. 氣象資料開放平台 註冊會員(email + 密碼即可,免審核)
  2. 登入後點「API 授權碼」→「取得授權碼」,立即產生 key

安裝(一般使用者)

已發布到 PyPI,不需要 clone 這個 repo。在 Claude Desktop / Claude Code 的 MCP 設定裡指定 uvx 執行即可,會自動抓套件:

{
  "mcpServers": {
    "cwa-weather": {
      "command": "uvx",
      "args": ["cwa-mcp-server"],
      "env": { "CWA_API_KEY": "你申請到的授權碼" }
    }
  }
}

或用 Claude Code CLI:

claude mcp add cwa-weather -e CWA_API_KEY=你申請到的授權碼 -- uvx cwa-mcp-server

開發(改這個 repo 原始碼)

git clone https://github.com/gary2376/cwa-mcp-server
cd cwa-mcp-server
uv sync
cp .env.example .env   # 填入 CWA_API_KEY

uv run python tests/test_client.py   # 最小自我檢查(不打真網路)
uv run mcp dev src/cwa_mcp/server.py # 本地用 inspector 手動測試 tools

狀態

四個 tool(天氣預報、地震報告、天氣特報、颱風警報)都已用真實 key 打過線上 API 驗證,也已接上 Claude Code 實測對話流程,能正確判斷風險等級並給出具體建議。已發布到 PyPI 與 MCP Server Registry。

已知修過的坑:v0.1.0 最初上傳的 wheel 因為 uv_build 預設用 project.name 猜模組名(cwa_mcp_server),跟實際原始碼目錄 src/cwa_mcp/ 對不上,打包出一個空殼套件,uvx cwa-mcp-server 會直接 ModuleNotFoundError。已在 pyproject.toml[tool.uv.build-backend] module-name = "cwa_mcp" 修正,重新 build 驗證過 wheel 內容正確。

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cwa_mcp_server-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cwa_mcp_server-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file cwa_mcp_server-0.1.1.tar.gz.

File metadata

  • Download URL: cwa_mcp_server-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cwa_mcp_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e04f778ff2d9ce5720f510b67f3586efc671f381449ca9d90a0245280dd9f570
MD5 aa571f9a52409205b95ce3c7e09ebcc2
BLAKE2b-256 c91035c60809bb997275dcba618dcd6cae4cca96fd056df9064aad69d6b3cb92

See more details on using hashes here.

File details

Details for the file cwa_mcp_server-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cwa_mcp_server-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cwa_mcp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8b518fb8911a395428c768c440315c269d8586d280e189818f63c50ca4754ad
MD5 bb1a6ab6ec03c26abb541b1b91c33420
BLAKE2b-256 53d8f7ad6d505935c027ffc1b8fd7e8d70ffbb430b9ea5638be2c05b039c1c0e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page