2.0.0
Use this when you need to capture or process log messages sent by the server.
MCP servers can emit log messages to clients. The client handles these through a log handler callback.
Log Handler
Provide alog_handler function when creating the client:
LogMessage object:
LogMessage
The log level
Structured Logs
Themessage.data attribute contains the serverβs JSON-serializable log payload. FastMCP servers commonly send a dictionary with msg and extra keys, which enables structured logging with rich contextual information.
Default Behavior
If you do not provide a customlog_handler, FastMCPβs default handler routes server logs to Pythonβs logging system through the fastmcp.client.from_server logger, at the matching severity. The MCP levels map as follows: notice becomes INFO; alert and emergency become CRITICAL.