Basic Usage
Use the context logging methods within any tool function:Log Levels
| Level | Use Case |
|---|---|
ctx.debug() | Detailed execution information for diagnosing problems |
ctx.info() | General information about normal program execution |
ctx.warning() | Potentially harmful situations that don’t prevent execution |
ctx.error() | Error events that might still allow the application to continue |
Structured Logging
All logging methods accept anextra parameter for sending structured data to the client. This is useful for creating rich, queryable logs.
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:

