ntfy-mcp-server
Version:
An MCP (Model Context Protocol) server designed to interact with the ntfy push notification service. It enables LLMs and AI agents to send notifications to your devices with extensive customization options.
82 lines (81 loc) • 2.56 kB
TypeScript
import { NtfySubscriptionHandlers, NtfySubscriptionOptions } from './types.js';
/**
* NtfySubscriber class for subscribing to ntfy topics
*/
export declare class NtfySubscriber {
private handlers;
private abortController?;
private cleanupFn?;
private connectionActive;
private lastKeepaliveTime;
private reconnectAttempts;
private keepaliveCheckInterval?;
private logger;
private subscriberId;
private currentTopic?;
/**
* Creates a new NtfySubscriber instance
* @param handlers Event handlers for the subscription
*/
constructor(handlers?: NtfySubscriptionHandlers);
/**
* Subscribe to a ntfy topic
* @param topic Topic to subscribe to (can be comma-separated for multiple topics)
* @param options Subscription options
* @returns Promise that resolves when the subscription is established
* @throws NtfyInvalidTopicError if the topic name is invalid
* @throws NtfyConnectionError if the connection fails
*/
subscribe(topic: string, options?: NtfySubscriptionOptions): Promise<void>;
/**
* Unsubscribe from the current topic
*/
unsubscribe(): void;
/**
* Start a subscription to a topic
* @param topic Topic to subscribe to
* @param format Format to subscribe in (json, sse, raw, ws)
* @param options Subscription options
*/
private startSubscription;
/**
* Process a JSON stream from ntfy
* @param reader ReadableStreamDefaultReader to read from
* @param requestId Request ID for logging
*/
private processJsonStream;
/**
* Handle a message from ntfy
* @param message Message from ntfy
* @param requestId Request ID for logging
*/
private handleMessage;
/**
* Handle a parse error
* @param error Error that occurred
* @param rawData Raw data that caused the error
* @param requestId Request ID for logging
*/
private handleParseError;
/**
* Handle a subscription error
* @param error Error that occurred
* @param requestId Request ID for logging
*/
private handleSubscriptionError;
/**
* Start the keepalive check interval
*/
private startKeepaliveCheck;
/**
* Stop the keepalive check interval
*/
private stopKeepaliveCheck;
/**
* Schedule a reconnection attempt
* @param topic Topic to reconnect to
* @param format Format to reconnect with
* @param options Subscription options
*/
private scheduleReconnect;
}