Skip to main content
Glama

MCP-Notify-Phone

輕量、通用、邏輯與介面抽離的手機推播通知工具,專為 AI Agent 監督長時間執行的實驗/訓練腳本 而設計。

  • MCP 標準優先:原生提供標準 Model Context Protocol(MCP)Server(notify-phone-mcp),可直接接入 Antigravity、Claude Code / Desktop、Cursor、Windsurf 等支援 MCP 的工具。

  • 邏輯與介面抽離:推播核心(notifier.py + config.py)獨立於介面層,同時提供 MCP Server 與 CLI(notify-phone)。

  • 基於開源 Apprise(BSD-2-Clause 授權):預設以 ntfy.sh 為主,免改程式碼即可透過環境變數切換為 Discord、Telegram、Slack、Bark、Pushover 等 80+ 種通知管道。


專案架構

MCP-Notify-Phone/
├── pyproject.toml                  # 標準 Python 打包設定(支援 uvx / pipx / venv)
├── LICENSE                         # MIT License
├── .env.example                    # 環境變數範本
├── src/notify_phone/
│   ├── config.py                   # 環境變數與 URL 標準化(自動支援 https://ntfy.sh/... 與 ntfy://...)
│   ├── notifier.py                 # 核心推播邏輯層(封裝 Apprise)
│   ├── mcp_server.py               # MCP Server 介面層(notify-phone-mcp)
│   └── cli.py                      # CLI 介面層(notify-phone)
└── tests/                          # 單元測試

Related MCP server: notify-mcp

一、手機端設定說明(以 ntfy 為例)

ntfy 是免費開源的推播服務,不需註冊帳號即可開始使用:

  1. 在手機安裝 ntfy App

    • iOS:到 App Store 搜尋並安裝 ntfy(開發者:Philipp C. Heckel)。

    • Android:到 Google Play 或 F-Droid 安裝 ntfy。

    • 開啟 App 時請允許推播通知權限。

  2. 決定一個專屬且不易被猜到的頻道名稱(Topic)

    • 公開的 ntfy.sh 頻道沒有預設密碼,任何知道頻道名稱的人都能收發訊息,請勿使用 test、notify 等簡單名稱。

    • 建議格式:<你的代號>-exp-<隨機字串>,例如 my-exp-9f3k2m8x(長度 16 字元以上為佳)。

  3. 在手機 App 訂閱該頻道

    • 點擊 App 右下角 +(訂閱主題 / Subscribe to topic)。

    • 主題名稱填入剛取的頻道名稱,保留預設伺服器 https://ntfy.sh,點擊「訂閱(Subscribe)」。

  4. 進階提示(可選)

    • 實驗失敗時工具會送出 priority="high",可在手機系統設定中將 ntfy App 設為不受省電限制,確保能即時收到通知。

    • 若需要更高隱私,可搭配 ntfy.sh 帳號 Access Token 或自架 ntfy 伺服器(設定 NTFY_SERVER 與 NTFY_TOKEN)。


二、快速使用(從 GitHub 直接執行,免手動裝環境)

方式 A:使用 uvx(推薦,不污染主機 Python)

在你的 MCP 設定檔(例如 Antigravity 的 ~/.gemini/config/mcp_config.json)加入:

{
  "mcpServers": {
    "notify-phone": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/JohnnyDo0730/MCP-Notify-Phone",
        "notify-phone-mcp"
      ],
      "env": {
        "NOTIFY_URL": "ntfy://換成你的秘密頻道"
      }
    }
  }
}

也可以直接用 uvx 測試 CLI 推播:

NOTIFY_URL="ntfy://換成你的秘密頻道" uvx \
  --from git+https://github.com/JohnnyDo0730/MCP-Notify-Phone \
  notify-phone --title "測試通知" --message "從 GitHub 公開版發送成功!" --level success

方式 B:使用 pipx 安裝到隔離環境

pipx install git+https://github.com/JohnnyDo0730/MCP-Notify-Phone

安裝完成後,在 mcp_config.json 直接設定 "command": "notify-phone-mcp" 並透過 "env" 傳入 NOTIFY_URL 即可。

方式 C:使用標準 Python 獨立虛擬環境(venv)

python3 -m venv .venv
.venv/bin/pip install git+https://github.com/JohnnyDo0730/MCP-Notify-Phone

# 測試發送通知
NOTIFY_URL="ntfy://換成你的秘密頻道" .venv/bin/notify-phone \
  --title "測試通知" \
  --message "透過獨立 venv 安裝成功!" \
  --level success

在 mcp_config.json 中將 command 指向該虛擬環境的 /path/to/.venv/bin/notify-phone-mcp 即可。

NOTIFY_URL 同時支援 ntfy://你的頻道 與 https://ntfy.sh/你的頻道(程式會自動正規化)。


三、本機開發與打包

git clone https://github.com/JohnnyDo0730/MCP-Notify-Phone.git
cd MCP-Notify-Phone

# 建立隔離虛擬環境並安裝開發依賴
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"

# 執行測試
.venv/bin/pytest -v

# 打包 Wheel (.whl) 與原始碼壓縮包 (.tar.gz)
.venv/bin/pip install build
.venv/bin/python -m build

四、環境變數與多通道支援(Apprise)

環境變數

說明

範例

NOTIFY_URL

單一推播目標(Apprise URL 或 https://ntfy.sh/...)

ntfy://my-secret-topic

NOTIFY_URLS

多個推播目標(逗號或換行分隔,優先於 NOTIFY_URL)

ntfy://topic1,discord://id/token

NTFY_TOPIC

ntfy 快捷設定(未設 NOTIFY_URL 時生效)

my-secret-topic

NTFY_SERVER

選填,自架 ntfy 伺服器網址

https://ntfy.example.com

NTFY_TOKEN

選填,ntfy Access Token

tk_xxxxxxxx

NOTIFY_DEFAULT_TITLE

選填,未傳入標題時的預設值

Lab Experiment Alert

切換其他推播平台只需修改 NOTIFY_URL,無需修改程式碼:

  • Discord Webhook:discord://<WebhookID>/<WebhookToken>

  • Telegram Bot:tgram://<BotToken>/<ChatID>

  • Slack Webhook:slack://<TokenA>/<TokenB>/<TokenC>

  • Bark (iOS):bark://<DeviceKey>@api.day.app

  • 更多支援清單請見 Apprise Wiki。


授權聲明

Available Tools

1 tool
send_phone_notificationA

發送推播通知到使用者的手機或指定通訊管道。

使用時機:

  • 僅在使用者明確要求「完成後通知我」、「發手機通知」,或長時間執行的實驗/訓練腳本結束 (成功或失敗中斷)需回報結果時,於所有主要工作結束後的「最後一步」呼叫此工具。

  • 一般簡短問答或使用者未要求通知的任務,請勿主動呼叫。

參數說明:

  • title: 簡短明確的通知標題(例如「實驗訓練完成」或「腳本異常中止」)。

  • message: 任務結果摘要,建議包含執行狀態、耗時、關鍵數據指標(如 loss/accuracy)或錯誤原因。

  • level: 通知類型,可選 "info"、"success"、"warning"、"failure"(預設 "info")。

  • priority: 推播優先級,可選 "min"、"low"、"default"、"high"、"max" (實驗失敗或需立即處理時建議使用 "high")。

Inputs: title (required), message (required), level, priority. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 1 tool

    Disambiguation5/5

    There is only one tool, so there is no possibility of selection ambiguity. Its purpose (send a phone notification at the end of a task) is clearly stated and scoped.

    Naming Consistency5/5

    The single tool follows a clear verb_noun pattern (send_phone_notification) in snake_case. With one tool there is no convention mixing to penalize.

    Tool Count4/5

    The server's purpose is deliberately narrow—one notification operation—so a single tool is nearly the right scope rather than a mismatch. It is slightly thin (no status check or channel listing), but each parameter earns its place.

    Completeness4/5

    The core lifecycle of 'compose and send a notification' is covered with title, message, level, and priority. Minor gaps exist—no delivery-status query, no batch send, and the description mentions a 'specified channel' without exposing a channel parameter—but agents can work around these.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Enables AI to send push notifications to your phone via a configurable gateway. It is a thin wrapper that posts to an Apprise push gateway.
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Send push notifications to mobile devices via ntfy.sh from AI assistants.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server that enables agents to send tagged notifications through Apprise, run one-off URL sends, and check upstream health via stdio or streamable HTTP.
      2
      AGPL 3.0