ntfy-notify

ntfy-notify

Lets you send push notifications to your phone via ntfy, enabling alerts from scheduled tasks or direct messages.

Category
访问服务器

README

ntfy-notify

CI License: MIT Python 3.10+

A tiny Model Context Protocol (MCP) server that lets Claude / Cowork push notifications to your phone via ntfy. Point a scheduled task at it and the results land on your lock screen instead of waiting in a log somewhere.

Why I built this: I run a scheduled daily job-search inbox sweep, and I wanted the summary on my phone the moment it finishes instead of having to go check on it. ntfy is a dead-simple pub/sub-over-HTTP service, so the whole thing is one HTTP POST behind an MCP tool.

What it does

Exposes two MCP tools over stdio:

Tool Purpose
send_notification(message, title="", priority="default", tags="", click_url="") Send any push notification to your configured ntfy topic.
send_job_alert(summary) Convenience wrapper: title "Job sweep", high priority, briefcase tag.

priority accepts min / low / default / high / urgent (or "1".."5"). tags is a comma-separated list of emoji shortcodes, e.g. tada,computer. click_url opens when you tap the notification.

How ntfy works (30-second version)

ntfy is pub/sub over HTTP. You pick a topic — any string — and subscribe to it in the phone app. Anyone who knows the topic name can publish to it with a single HTTP POST, and it shows up on every subscribed device. There's no account or auth for public topics, which means the topic name is the only secret, so make it long and random.

How it works

There's no daemon and no always-on process. A stdio MCP server is launched by the client (Claude/Cowork) as a child process when a session starts, speaks JSON-RPC over stdin/stdout, stays idle until a tool is called, and is shut down when the session ends.

Claude / Cowork session
        │  (launches as subprocess, JSON-RPC over stdio)
        ▼
   server.py  ──►  @mcp.tool() functions
        │              send_notification / send_job_alert
        │  builds one HTTP POST:
        │    body    = message text
        │    headers = Title / Priority / Tags / Click / Authorization
        ▼
   https://ntfy.sh/<NTFY_TOPIC>
        │  (pub/sub fan-out)
        ▼
   ntfy app on your phone

Key design points:

  • The topic is read from the environment, never hardcoded (_config()). Since the topic name is the only secret in ntfy, this is what makes the repo safe to be public — and it fails loudly with a clear error if NTFY_TOPIC is unset.
  • @mcp.tool() turns a plain function into a tool. The function name, type hints, and docstring become the schema and description that Claude reads to decide when and how to call it.
  • ntfy has no JSON payload. The message is the raw request body; everything else (title, priority, tags, click URL, auth token) rides along as HTTP headers.
  • Every call returns an OK: / FAILED: status string so the model knows whether the push actually went out. Network errors and non-2xx responses are caught and reported rather than raised.

Development

Run the test suite (pure logic + header construction, no network calls):

pip install -e ".[dev]"
pytest

1. Install the ntfy app and pick a topic

  1. Install ntfy on your phone:
  2. Generate a long, random topic name so nobody else can guess it:
    openssl rand -hex 16
    
  3. In the app, tap + and subscribe to that exact string.

2. Install the server

Requires Python 3.10+.

git clone https://github.com/Gardner-Programs/ntfy-notify.git
cd ntfy-notify
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

3. Configure environment variables

Copy the example and fill it in:

cp .env.example .env
Variable Required Default Notes
NTFY_TOPIC yes — Your long, random topic. Never hardcoded.
NTFY_BASE_URL no https://ntfy.sh Set to your own host if self-hosting.
NTFY_TOKEN no — Bearer token for protected / self-hosted topics.

The server reads these from the process environment. The MCP config below sets them directly, so a .env file is only needed for the curl test / manual runs.

4. Register the server with Cowork / Claude

Add an entry to your MCP client config. For Claude Desktop (claude_desktop_config.json) or Cowork, point it at the cloned repo:

{
  "mcpServers": {
    "ntfy-notify": {
      "command": "python",
      "args": ["/absolute/path/to/ntfy-notify/server.py"],
      "env": {
        "NTFY_TOPIC": "your-long-random-topic",
        "NTFY_BASE_URL": "https://ntfy.sh",
        "NTFY_TOKEN": ""
      }
    }
  }
}

For Claude Code, the equivalent one-liner:

claude mcp add ntfy-notify \
  --env NTFY_TOPIC=your-long-random-topic \
  -- python /absolute/path/to/ntfy-notify/server.py

If you installed into a virtualenv, use that interpreter's absolute path (e.g. /absolute/path/to/ntfy-notify/.venv/bin/python) as the command.

Restart the client and the send_notification / send_job_alert tools will appear.

5. Verify with curl

You don't need this server to test ntfy itself — confirm your topic works first:

curl \
  -H "Title: Hello from ntfy" \
  -H "Priority: high" \
  -H "Tags: tada" \
  -d "It works!" \
  https://ntfy.sh/your-long-random-topic

With a token (protected / self-hosted):

curl \
  -H "Authorization: Bearer tk_yourtoken" \
  -d "It works!" \
  https://ntfy.example.com/your-long-random-topic

You should get a push on your phone within a second or two.

Integration: daily job-inbox-sweep

Once the server is registered, update the scheduled daily-job-inbox-sweep task so its final step calls the tool with the run's summary, e.g.:

At the end of the run, call send_job_alert with a one-paragraph summary of what was found (new postings, replies, anything needing action).

send_job_alert already sets a sensible title and high priority, so a single call with the summary text is all the task needs.

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选