Skip to main content
This documentation covers MCP client logging—sending messages from your server to MCP clients. For standard server-side logging (e.g., writing to files, console), use fastmcp.utilities.logging.get_logger() or Python’s built-in logging module.
Server logging allows MCP tools to send debug, info, warning, and error messages back to the client. Unlike standard Python logging, MCP server logging sends messages directly to the client, making them visible in the client’s interface or logs.

Basic Usage

Use the context logging methods within any tool function:

Log Levels

Structured Logging

All logging methods accept an extra parameter for sending structured data to the client. This is useful for creating rich, queryable logs.

Server-Side Logs

Messages sent to clients via ctx.log() and its convenience methods are also logged to the server’s log at DEBUG level. Enable debug logging on the fastmcp.server.context.to_client logger to see these messages:

Client Handling

Log messages are sent to the client through the MCP protocol. How clients handle these messages depends on their implementation—development clients may display logs in real-time, production clients may store them for analysis, and integration clients may forward them to external logging systems. See Client Logging for details on how clients handle server log messages.