mcp-agent ships with a structured logger that captures context-rich events from apps, workflows, agents, and Temporal workers. Logs are automatically correlated with traces and forwarded to MCP clients using the Model Context Protocol logging utility.Documentation Index
Fetch the complete documentation index at: https://lastmileai-94a5811a-server-deployment-docs.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Logger entry points
app.logger– application-scoped logger, ideal for tools and startup messages.context.logger– request-specific logger with access to the active session, token counter, and upstream MCP connection.agent.logger– automatically bound when you callasync with agent:; perfect for per-agent instrumentation.
Event that can be routed to multiple transports. Span IDs and workflow IDs are injected automatically when tracing is enabled.
Configure transports and levels
Thelogger section in mcp_agent.config.yaml controls transports, batching, and formatting:
| Transport | Description |
|---|---|
console | Rich-formatted output to stdout (colours, nested JSON blocks). |
file | JSON Lines file writer with optional timestamp/session-based file rotation. |
http | Batch POST events to an HTTP endpoint (Elasticsearch, Datadog intake, etc.). |
none | Disable external transports (events still flow through the async event bus). |
Structured events
Logs accept amessage plus an optional data payload. The payload is serialised as JSON and preserved end-to-end:
MCP logging to upstream clients
When your app runs as an MCP server, the logger automatically forwards events to connected clients using the MCP logging channel. MCP-compatible tools (Claude Desktop, Cursor, etc.) will display your messages in their native consoles.mcp_forward_log) so events appear in the client even while the workflow is suspended.
Tips for production setups
- Pair logging with tracing (
otel.enabled: true) so every event carries span metadata. - Use
progress_display: truewhen running CLI tools to get live status bars for long flows. - Tune
batch_size/flush_intervalfor high-volume agents; the defaults (100 events / 2 seconds) work well for most workloads. - HTTP transports can carry filters—attach an
EventFilterif you only want to forward warnings and errors.
Reference implementations
examples/tracing/agent– shows log + trace correlation and human input callbacks.examples/tracing/mcp– demonstrates MCP logging surfaced inside a connected client.examples/mcp_agent_server/temporal– Temporal workflow logs, approvals, and nested MCP servers.examples/temporal– durable workflows emitting structured log events alongside spans.
