Skip to main content

Cross-platform notification system for AI agents (Claude Code, Gemini CLI) with ntfy.sh support

Project description

Agent Notifier

Cross-platform notification system for AI coding agents with ntfy.sh push notification support.

Supported Agents

Agent Config Location Hook Event
Claude Code ~/.claude/settings.json Notification
Gemini CLI ~/.gemini/settings.json Notification
OpenCode ~/.config/opencode/plugins/agent-notifier.mjs Event-based
Cursor CLI ~/.cursor/hooks.json stop
Codex CLI ~/.codex/config.toml notify

Features

  • Terminal Notifications: OSC 9 protocol for Ghostty, iTerm2, Kitty, VSCode, Windows Terminal
  • OS-Native Notifications: BurntToast (Windows), osascript (macOS), notify-send (Linux)
  • ntfy.sh Push Notifications: Get notifications on your phone, desktop, or any device
  • Multiple Channels: All channels attempted in parallel for maximum reach
  • Self-Contained: No external plugin dependencies required

Installation

pip install agent-notifier

Quick Start

# 1. Initialize configuration
agent-notifier-setup --init

# 2. Edit config to add your ntfy.sh topic (see ntfy.sh Setup below)
notepad $env:USERPROFILE\.agent-notifier\config.json

# 3. Install hooks for your agents
agent-notifier-setup --all

ntfy.sh Setup

ntfy.sh is a free, open-source notification service. You can use the public server or self-host.

Option 1: Public ntfy.sh (Quickest)

  1. Choose a topic name - Any unique string like my-agent-notify or maravedi-dev
  2. Add to config - Edit ~/.agent-notifier/config.json:
    {
      "ntfy_topic": "my-agent-notify",
      "ntfy_enabled": true
    }
    
  3. Subscribe on your devices:
    • iOS/Android: Install the ntfy app, tap "Subscribe", enter your topic name
    • Desktop: Open https://ntfy.sh/my-agent-notify in your browser
    • CLI: curl -s ntfy.sh/my-agent-notify/json | jq

Option 2: Self-Hosted ntfy Server

  1. Run your own ntfy server (see ntfy.sh docs)

  2. Add server URL to config:

    {
      "ntfy_topic": "my-agent-notify",
      "ntfy_server": "https://ntfy.example.com",
      "ntfy_enabled": true
    }
    

Option 3: Private Topic with Access Token

  1. Create a topic at ntfy.sh or your self-hosted server
  2. Generate an access token in the topic settings
  3. Add to config:
    {
      "ntfy_topic": "my-agent-notify",
      "ntfy_server": "https://ntfy.sh",
      "ntfy_token": "tk_your_token_here",
      "ntfy_enabled": true
    }
    

ntfy.sh Configuration Options

{
  "ntfy_topic": "your-unique-topic-name",
  "ntfy_server": "https://ntfy.sh",
  "ntfy_token": "tk_optional_access_token",
  "ntfy_priority": "default",
  "ntfy_tags": ["robot", "notification"],
  "ntfy_enabled": true
}
Option Default Description
ntfy_topic (required) Unique topic identifier
ntfy_server https://ntfy.sh ntfy server URL
ntfy_token none Access token for private topics
ntfy_priority default Priority: low, default, high, urgent
ntfy_tags ["robot"] Tags shown in notifications
ntfy_enabled true Enable/disable ntfy notifications

Configuration

Configuration file: ~/.agent-notifier/config.json

{
  "ntfy_topic": "your-topic-name",
  "ntfy_server": "https://ntfy.sh",
  "ntfy_enabled": true,
  "terminal_enabled": true,
  "os_native_enabled": true,
  "log_level": "INFO"
}

Environment Variables

Override any config setting:

export AGENT_NOTIFY_NTFY_TOPIC=my-topic
export AGENT_NOTIFY_NTFY_SERVER=https://ntfy.sh
export AGENT_NOTIFY_NTFY_ENABLED=true
export AGENT_NOTIFY_TERMINAL_ENABLED=true
export AGENT_NOTIFY_OS_NATIVE_ENABLED=true

CLI Commands

agent-notify

# Send a notification
agent-notify --title "Claude Code" --message "Task complete!"

# Send via stdin (JSON)
echo '{"title":"Alert","message":"Error occurred"}' | agent-notify

# Disable specific channels
agent-notify --title "Silent" --message "No sound" --no-ntfy

# Test your setup
agent-notify --title "Test" --message "agent-notifier is working!"

agent-notifier-setup

# Initialize config (creates ~/.agent-notifier/config.json)
agent-notifier-setup --init

# Install all agent hooks
agent-notifier-setup --all

# Install specific agents
agent-notifier-setup --install-claude    # Claude Code
agent-notifier-setup --install-gemini     # Gemini CLI
agent-notifier-setup --install-opencode  # OpenCode
agent-notifier-setup --install-cursor    # Cursor CLI
agent-notifier-setup --install-codex     # Codex CLI

# Check prerequisites
agent-notifier-setup --check

# Uninstall all hooks
agent-notifier-setup --uninstall

Programmatic API

from agent_notifier import notify

# Simple notification
notify(title="Claude Code", message="Task complete!")

# Custom topic
notify(title="Alert", message="Error!", ntfy_topic="my-custom-topic")

# Self-hosted server
notify(title="Alert", message="Error!", ntfy_topic="my-topic", ntfy_server="https://ntfy.example.com")

Agent-Specific Notes

Claude Code

Uses Notification hook in ~/.claude/settings.json. Notifies when the agent needs user input or completes work.

Gemini CLI

Uses Notification hook in ~/.gemini/settings.json. Notifies on tool permission requests.

OpenCode

Uses a local plugin at ~/.config/opencode/plugins/agent-notifier.mjs. Handles: session.idle, session.error, permission.asked, subagent.complete

Cursor CLI

Uses stop hook in ~/.cursor/hooks.json. Notifies when a task completes.

Codex CLI

Uses notify command in ~/.codex/config.toml. Notifies on agent-turn-complete and approval-requested events.

Architecture

┌─────────────────────────────────────────────────────────┐
│              AI Agent (any supported)                  │
└─────────────────────────┬───────────────────────────────┘
                          │ Hook/Event
                          ▼
┌─────────────────────────────────────────────────────────┐
│                   agent-notify                          │
│  (CLI entry point for all notifications)                │
└──────────┬──────────────────────┬──────────────────────┘
           │                      │
           ▼                      ▼
┌──────────────────┐    ┌─────────────────────────────┐
│ Terminal (OSC 9) │    │   ntfy.sh Push              │
│ Supported:        │    │   ┌─────────────────────┐   │
│ • Ghostty        │    │   │ Your Devices        │   │
│ • iTerm2         │    │   │ • Phone (app)       │   │
│ • Kitty          │    │   │ • Browser           │   │
│ • VSCode         │    │   │ • CLI (curl)        │   │
│ • Windows Terminal│   │   └─────────────────────┘   │
└──────────────────┘    └─────────────────────────────┘
           │
           ▼
┌──────────────────┐
│ OS Native        │
│ • Windows: BurntToast
│ • macOS: osascript
│ • Linux: notify-send
└──────────────────┘

Requirements

  • Python 3.11+
  • python-ntfy (installed automatically)
  • For OS notifications:
    • Windows: BurntToast PowerShell module (Install-Module BurntToast)
    • macOS: Built-in osascript
    • Linux: notify-send (apt install libnotify-bin)

Troubleshooting

Notifications not working?

# Check prerequisites
agent-notifier-setup --check

# Test manually
agent-notify --title "Test" --message "Hello!"

# Enable verbose logging
agent-notify --title "Test" --message "Debug" --verbose

# Check log file
cat ~/.agent-notifier/notifier.log

ntfy not receiving notifications?

  1. Verify your topic name is correct in config
  2. Make sure your topic isn't rate-limited (try a different name)
  3. For private topics, verify your access token

License

MIT

Project details


Download files

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

Source Distribution

agent_ntfy-0.1.7.tar.gz (31.6 kB view details)

Uploaded Source

Built Distribution

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

agent_ntfy-0.1.7-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file agent_ntfy-0.1.7.tar.gz.

File metadata

  • Download URL: agent_ntfy-0.1.7.tar.gz
  • Upload date:
  • Size: 31.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for agent_ntfy-0.1.7.tar.gz
Algorithm Hash digest
SHA256 2984360006b1093aecbd7a5c476cbdb055e021f110ba7c944ee2ba03f4a4b9c6
MD5 1b322db5054a4d983f3a80edd916a0bd
BLAKE2b-256 a7ded96d114428089de2271d9af30173e44566b33fd9d6caae90726fd03c850b

See more details on using hashes here.

File details

Details for the file agent_ntfy-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: agent_ntfy-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for agent_ntfy-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a83f2c2a7971378db9ad3a0d9b6e37ddfe10a138ec138bcdcc906f56a140daa4
MD5 533293f4bb01542bcca0ecc71bf11387
BLAKE2b-256 e5016934bc87fd5bdab0aa7c25facb9d3b1e7265f84be4cb29831739d4e34b1d

See more details on using hashes here.

Supported by

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