/** * Logger utility for the MCP server * Outputs formatted JSON logs to stderr or a file to avoid interfering with MCP's stdio transport * Also supports sending logs as MCP notifications according to the protocol */ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; export declare enum LogLevel { DEBUG = "debug", INFO = "info", NOTICE = "notice", WARNING = "warning",// MCP protocol standard name WARN = "warning",// Alias for WARNING (both map to 'warning' for MCP compliance) ERROR = "error", CRITICAL = "critical", ALERT = "alert", EMERGENCY = "emergency" } export interface LogEntry { timestamp: string; level: LogLevel; message: string; context?: Record; } /** * Logger class that outputs formatted JSON logs to stderr or a file * to avoid interfering with MCP's stdio transport */ export declare class Logger { private logLevel; private mcpServer?; constructor(); /** * Get the current log level */ getLogLevel(): LogLevel; /** * Set the log level */ setLogLevel(level: LogLevel): void; /** * Determine if a log level should be output based on the current log level */ private shouldLog; /** * Format a log entry as JSON */ private formatLogEntry; /** * Write directly to stderr (bypasses JSON formatting) */ private writeToStderr; /** * Write a log entry to the configured output (stderr or file) */ private writeLogEntry; /** * Set the MCP server instance for sending log notifications */ setMcpServer(server: McpServer): void; /** * Send a log message as an MCP notification * @param level Log level * @param message Log message * @param data Optional structured data * @param loggerName Optional logger name (defaults to 'fluent-mcp') */ private sendMcpNotification; /** * Send a dedicated notification with custom logger name * Use this for domain-specific notifications (e.g., authentication) * @param level Log level * @param message Log message * @param data Structured data to include * @param loggerName The logger name (e.g., 'authentication') */ sendNotification(level: LogLevel, message: string, data: Record, loggerName: string): void; /** * Set up logging request handlers on the MCP server */ setupLoggingHandlers(): void; /** * Core logging method - logs a message at the specified level * All level-specific methods delegate to this */ private logAtLevel; /** * Log a message at the debug level */ debug(message: string, context?: Record): void; /** * Log a message at the info level */ info(message: string, context?: Record): void; /** * Log a message at the notice level */ notice(message: string, context?: Record): void; /** * Log a message at the warn level */ warn(message: string, context?: Record): void; /** * Log a message at the warning level */ warning(message: string, context?: Record): void; /** * Log a message at the error level * Always logs regardless of log level, with optional error object for stack trace */ error(message: string, error?: Error, context?: Record): void; /** * Log a message at the critical level */ critical(message: string, context?: Record): void; /** * Log a message at the alert level */ alert(message: string, context?: Record): void; /** * Log a message at the emergency level */ emergency(message: string, context?: Record): void; /** * Log a message with an object for additional context at any level */ log(level: LogLevel, message: string, obj?: unknown): void; } declare const logger: Logger; export { logger }; export default logger; //# sourceMappingURL=logger.d.ts.map