intellicrack.mcp.server_logs
Log messages MCP servers send, routed into Intellicrack’s own logging.
A server may send notifications/message log records: on a 2025-11-25 connection at or above the level logging/setLevel asked
for, and on a 2026-07-28 connection only for requests that opt in with a logLevel in their _meta. Every record is the server’s
own text, so it is cleaned of invisible characters and forged fence markers and bounded before it is logged. Each record goes to the
structlog pipeline – and so to the log files and the log viewer – with the server it came from, its level mapped onto structlog’s, and
is kept in a bounded per-server buffer the MCP settings show. A server that floods is rate limited per server; what it sends over the
limit is counted, not logged, and the count is reported once the limit allows.
- DEFAULT_RATE_PER_S: Final[float] = 20.0
Records per second a server may log once its burst is spent.
- class McpLogRecord[source]
Bases:
objectOne log message a server sent, cleaned for display.
- Variables:
- class McpServerLogBook[source]
Bases:
objectReceives every server’s log messages and keeps each server’s recent ones.
Callbacks are invoked on the MCP event loop and listeners are called there too; a GUI listener must hand the record to its own thread.
- __init__(*, capacity=500, rate_per_s=20.0, burst=100, clock=<built-in function monotonic>)[source]
Create an empty log book.
- callback_for(server_id)[source]
Build the SDK logging callback for one server.
- Parameters:
server_id (str) – The server the callback receives messages from.
- Returns:
The callback.
- Return type:
LoggingFnT
- receive(server_id, level, logger, data)[source]
Log, keep and announce one message, unless the server is over its rate.
- Parameters:
- Returns:
The record, or
Nonewhen it was rate limited.- Return type:
McpLogRecord | None
- records(server_id)[source]
Return a server’s recent records.
- Parameters:
server_id (str) – The server.
- Returns:
Its records, oldest first.
- Return type:
- suppressed(server_id)[source]
Report how many of a server’s records are being held back by its rate limit.
- add_listener(listener)[source]
Call a function for every record kept from now on.
- Parameters:
listener (Callable[[McpLogRecord], None]) – Receives each record, on the MCP event loop.
- Return type:
None
- remove_listener(listener)[source]
Stop calling a listener.
- Parameters:
listener (Callable[[McpLogRecord], None]) – A listener added earlier.
- Return type:
None