UNPKG

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.

116 lines (115 loc) 3.27 kB
/** * Request context interface */ export interface RequestContext { /** Unique request identifier */ requestId: string; /** Request timestamp */ timestamp: string; /** Request path/endpoint */ path?: string; /** HTTP method */ method?: string; /** Request source IP */ ip?: string; /** Custom request properties */ [key: string]: unknown; } /** * Rate limiting configuration options */ export interface RateLimitConfig { /** Time window in milliseconds */ windowMs: number; /** Maximum number of requests allowed in the window */ maxRequests: number; /** Custom error message template */ errorMessage?: string; /** Whether to skip rate limiting in certain environments (e.g. development) */ skipInDevelopment?: boolean; /** Custom key generator function */ keyGenerator?: (identifier: string, context?: RequestContext) => string; /** How often to run cleanup of expired entries (in milliseconds) */ cleanupInterval?: number; } /** * Individual rate limit entry */ export interface RateLimitEntry { /** Current request count */ count: number; /** When the window resets (timestamp) */ resetTime: number; /** Key for this entry, stored for faster deletion */ key: string; } /** * Generic rate limiter that can be used across the application */ export declare class RateLimiter { private config; /** Map storing rate limit data */ private limits; /** Cleanup interval timer */ private cleanupTimer; /** Default configuration */ private static DEFAULT_CONFIG; /** * Create a new rate limiter * @param config Rate limiting configuration */ constructor(config: RateLimitConfig); /** * Start the cleanup timer to periodically remove expired entries */ private startCleanupTimer; /** * Clean up expired rate limit entries to prevent memory leaks */ private cleanupExpiredEntries; /** * Update rate limiter configuration * @param config New configuration options */ configure(config: Partial<RateLimitConfig>): void; /** * Get current configuration * @returns Current rate limit configuration */ getConfig(): RateLimitConfig; /** * Reset all rate limits */ reset(): void; /** * Check if a request exceeds the rate limit * @param key Unique identifier for the request source * @param context Optional request context * @throws {McpError} If rate limit is exceeded */ check(key: string, context?: RequestContext): void; /** * Get rate limit information for a key * @param key The rate limit key * @returns Current rate limit status or null if no record exists */ getStatus(key: string): { current: number; limit: number; remaining: number; resetTime: number; } | null; /** * Stop the cleanup timer when the limiter is no longer needed */ dispose(): void; } /** * Create and export a default rate limiter instance */ export declare const rateLimiter: RateLimiter; declare const _default: { RateLimiter: typeof RateLimiter; rateLimiter: RateLimiter; }; export default _default;