Basic Usage
Use the context logging methods within any tool function:Log Levels
Structured Logging
All logging methods accept anextra parameter for sending structured data to the client. This is useful for creating rich, queryable logs.
Minimum Level
Messages below the minimum level are dropped before they reach the client. Set a server-wide default withFastMCP(client_log_level=...) or the FASTMCP_CLIENT_LOG_LEVEL setting. On handshake-era connections a client can override it for its session with the MCP logging/setLevel request; the modern protocol has no session to hold that level, so a modern client filters in its own log handler instead. With no minimum set, every level is sent.
ctx.debug() and ctx.info() send nothing, while ctx.warning() and ctx.error() reach the client.
Server-Side Logs
Messages sent to clients viactx.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: