Ntfy MCP Server
Table of Contents
- [Overview](#overview)
- [Features](#features)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [Configuration](#configuration)
- [Project Structure](#project-structure)
- [Tools](#tools)
- [Resources](#resources)
- [Use Cases](#use-cases)
- [Available Scripts](#available-scripts)
- [Contributing](#contributing)
- [License](#license)
Overview
Features
- **MCP Server Implementation:** Built using the `@modelcontextprotocol/sdk` for seamless integration with LLM agents.
- **Ntfy Integration:** Provides a tool (`send_ntfy`) to send notifications with support for: - Message prioritization (1-5 levels) - Emoji tags - Clickable actions and buttons - File attachments - Delayed delivery - Markdown formatting
- **Resource Exposure:** Exposes the configured default ntfy topic as an MCP resource.
- **TypeScript:** Modern, type-safe codebase with comprehensive type definitions.
- **Structured Logging:** Uses `winston` and `winston-daily-rotate-file` for detailed and rotatable logs.
- **Configuration Management:** Uses `dotenv` for easy environment-based configuration.
- **Utility Scripts:** Includes scripts for cleaning build artifacts and generating directory structure documentation.
- **Error Handling & Security:** Implements robust error handling, input sanitization (`sanitize-html`), and security filters (`xss-filters`).
Quick Start
- **Prerequisites:** - Node.js (v16+) - npm or yarn - An MCP-compatible client (Claude Desktop, Cline, etc.)
- **Install and Run:** ```bash # Option 1: Install via npm npm install -g ntfy-mcp-server # Option 2: Clone repository and build git clone https://github.com/cyanheads/ntfy-mcp-server.git cd ntfy-mcp-server npm install npm run build # Create .env file (optional but recommended) cp .env.example .env # Edit .env to set NTFY_DEFAULT_TOPIC # Start the server npm start ```
- **Add to MCP Client Settings:** Add the server to your MCP client settings file (see [Configuration](#configuration))
- **Use the tool:** Once connected, you can use the `send_ntfy` tool to send notifications.
Installation
Option 1: NPM Package (Recommended)
- **Install the package globally:** ```bash npm install -g ntfy-mcp-server ``` This will install the server globally, making it available as a command-line tool.
- **Or install locally in your project:** ```bash npm install ntfy-mcp-server ``` When installed locally, you can run it via npx or from node.
Option 2: From Source
- **Clone the repository:** ```bash git clone https://github.com/cyanheads/ntfy-mcp-server.git cd ntfy-mcp-server ```
- **Install dependencies:** ```bash npm install ```
- **Build the project:** ```bash npm run build ```
Configuration
Environment Variables
MCP Client Settings
For Cline VSCode Extension
For Claude Desktop App
Ntfy Setup
- **Install the ntfy app** on your devices from [ntfy.sh](https://ntfy.sh/app) or the app stores
- **Subscribe to your topic** in the app
- **Use the same topic** in your MCP server configuration
Project Structure
Tools
`send_ntfy`
Key Arguments:
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
[object Object] | [object Object] | [object Object] | [object Object] |
Example Usage:
Example Response:
Resources
Direct Resources
`ntfy://default`
- **Description:** Returns the default ntfy topic configured in the server's environment variables (`NTFY_DEFAULT_TOPIC`).
- **Usage:** Useful for clients to discover the primary topic without needing prior configuration.
- **Example:** An LLM agent can access this resource to automatically use the default topic when sending notifications.
- **Example Response:** ```json { "defaultTopic": "ATLAS", "timestamp": "2025-03-27T08:30:25.619Z", "requestUri": "ntfy://default", "requestId": "0da963d0-30e0-4dbc-bb77-4bf2dee14484" } ```
Resource Templates
`ntfy://{topic}`
- **Description:** Returns information about a specific ntfy topic.
- **Parameters:** `topic` - The name of the ntfy topic.
- **Usage:** For querying information about topics other than the default.
- **Example Response:** ```json { "topic": "ATLAS", "timestamp": "2025-03-27T08:30:30.038Z", "requestUri": "ntfy://ATLAS", "requestId": "31baf1df-278f-4fdb-860d-019f156a72b0" } ```
Use Cases
- **Long-running Task Notifications** - Get notified when tasks like database backups, code generation, or data processing complete.
- **Scheduled Reminders** - Set delayed notifications for future events or reminders.
- **Alert Systems** - Set up critical alerts for monitoring systems or important events.
- **Mobile Notifications from LLMs** - Allow LLMs to send notifications directly to your phone.
- **Multi-step Process Updates** - Receive updates as different stages of a complex process complete.
Usage Examples
Basic Notification
Rich Notification with Actions
Available Scripts
- `npm run build`: Compiles the TypeScript source code to JavaScript in the `dist/` directory.
- `npm run clean`: Removes the `dist/` directory and cleans the contents of the `logs/` directory.
- `npm run rebuild`: Runs `clean` and then `build`.
- `npm run tree`: Generates a directory tree representation in `docs/tree.md`.
- `npm start`: Runs the compiled server from the `dist/` directory using Node.js.
- `npm run watch`: Tails the combined log file (`logs/combined.log`) for real-time monitoring.
Contributing
- Fork the repository.
- Create a feature branch (`git checkout -b feature/your-feature`).
- Commit your changes (`git commit -m 'Add some feature'`).
- Push to the branch (`git push origin feature/your-feature`).
- Create a new Pull Request.
Development Best Practices
- Follow TypeScript best practices and maintain strong typing
- Write tests for new functionality
- Keep dependencies up to date
- Follow the existing code style and patterns
License
Acknowledgements
- [ntfy.sh](https://ntfy.sh/) for providing the notification service
- [Model Context Protocol](https://modelcontextprotocol.io/) for enabling LLM-to-tool connections
- All contributors and users of this project