Create a new McpNotificationLogger.
Optional configuration
Register a notification handler for receiving log notifications. Multiple handlers can be registered for multi-session scenarios.
The notification handler to register
Log an alert message
Optionaldata: Record<string, unknown>Clear all registered handlers.
Create a context-aware logger function for use in tool handlers. Returns a function that can be passed to LogContext.sendMcpLog.
The notification handler for this context
A function compatible with LogContext.sendMcpLog
Log a critical message
Optionaldata: Record<string, unknown>Log a debug message
Optionaldata: Record<string, unknown>Log an emergency message
Optionaldata: Record<string, unknown>Log an error message
Optionaldata: Record<string, unknown>Get the number of registered handlers.
Get the current minimum log level.
Log an info message
Optionaldata: Record<string, unknown>Check if logging is currently available (enabled and has servers).
Check if logging is enabled.
Send a log message to all connected MCP clients.
The MCP log level
The log message
Optionaldata: Record<string, unknown>Optional structured data to include
Promise that resolves when all sends complete
Log a notice message
Optionaldata: Record<string, unknown>Unregister a notification handler.
The notification handler to remove
Enable or disable MCP logging. When disabled, log methods become no-ops but still return resolved promises.
Whether to enable logging
Set the minimum log level. Messages below this level will not be sent.
The minimum log level
Log a warning message
Optionaldata: Record<string, unknown>Log a warning message (alias for warn)
Optionaldata: Record<string, unknown>
MCP Notification Logger
Sends structured log messages to MCP clients via the notifications/message protocol. Clients that support the logging capability will receive and display these messages.
Features:
Example