Skip to main content
mcp-use supports this feature through a logging_callback function that can be passed to the MCPClient.

Server-Side: Sending Logs

On the server (using fastmcp), you can send log messages with different severity levels from within a tool’s context (ctx).
These log messages are sent as logging/message notifications to the client.

Client-Side: Handling Logs

While you can catch LoggingMessageNotification events within the general message_handler, the recommended approach is to use the dedicated logging_callback. This keeps your code clean by separating logging concerns from other notification handling. The logging_callback receives the parameters of the log notification directly, which include the level and message.
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.