Skip to main content
MCP provides a dedicated logging channel for servers to send structured log messages to clients. This enables proper debugging, monitoring, and observability without cluttering the main notification stream.
TypeScript Support Coming SoonLogging callbacks are currently under development for the TypeScript client. The Python version has full support. See the Python Logging documentation for reference.

Understanding Logging

The MCP logging system provides:
  • Structured messages: Level-based logging (debug, info, warning, error)
  • Separate channel: Dedicated logging path independent of notifications
  • Server diagnostics: Debug server behavior without main protocol interference
  • Client-side handling: Process logs according to your application needs

Logging Levels

MCP defines standard log levels:
  • debug: Detailed diagnostic information
  • info: General informational messages
  • warning: Warning messages for potential issues
  • error: Error messages for failures

Future API

When implemented, the TypeScript client will support logging through a callback:
// ⚠️ Logging callbacks are not yet supported in the TypeScript library.
// Support is coming soon! If you need this feature now, please open an issue:
// https://github.com/mcp-use/mcp-use

// When supported, the API will look similar to:
/*
import { MCPClient, types } from 'mcp-use'

// A dedicated handler for log messages
async function handleLogs(logParams: types.LoggingMessageNotificationParams) {
    console.log(`LOG [${logParams.level.toUpperCase()}]: ${logParams.message}`)
}

async function testLogging(primitiveServer: string) {
    const config = { mcpServers: { PrimitiveServer: { url: `${primitiveServer}/mcp` } } }
    // Pass the callback to the client
    const client = new MCPClient(config, { loggingCallback: handleLogs })

    try {
        await client.createAllSessions()
        const session = client.getSession('PrimitiveServer')

        // This tool will trigger the loggingCallback
        const result = await session.callTool('logging_tool', {})
        console.assert(result.content[0].text === 'Logging tool completed')
    } finally {
        await client.closeAllSessions()
    }
}
*/
By using the logging_callback, you can easily route server-side logs to your client’s logging system, display them in a debug console, or handle them in any other way that suits your application’s needs.