Codex MCP Call Rendering#
As of schema v22 and the current ingest pipeline, Decant parses MCP tool invocations from Codex event_msg records into first-class tool blocks with proper mcp__<server>__<base> naming, tool_kind = "mcp", and populated mcp_server fields. Earlier Codex rollouts logged native mcp_tool_call response items, while current rollouts emit only mcp_tool_call_end events โ both formats are now fully supported.
Codex sessions can record MCP tool calls in two ways:
-
Native MCP event calls โ Current Codex versions (0.15x+) can emit these as distinct tool blocks. Each MCP tool appears as its own
mcp_tool_call_endevent in the transcript, parsed into a separate tool block withmcp__<server>__<base>naming. -
MCP calls nested inside
execprograms โ Recent Codex CLI versions (0.15x) also run many actions through a singleexectool whose input is a JavaScript program that callstools.exec_command(...),tools.apply_patch(...),tools.update_plan(...), AND MCP tools. These nested MCP calls don't appear as separate tool blocks in the transcript.
Both patterns exist in recent Codex versions (0.15x). While nested MCP calls don't appear as separate tool blocks in the transcript UI, the analytics layer uses AST-based inspection of the JavaScript program inside exec calls to detect nested MCP tool calls for proper activity bucketing and classification. The nested invocation is visible only inside the raw tool_input JSON.
How Codex Logs MCP Calls#
Codex session files consist of newline-delimited JSON records. Tool invocations appear in two places:
response_itemrecords whosepayload.typeis one offunction_call,custom_tool_call,tool_search_call, ormcp_tool_call. Nativemcp_tool_callitems carrynamespaceandnamefields that identify the MCP server and base tool name directly.event_msgrecords whosepayload.typeismcp_tool_call_end. Current Codex rollouts record MCP calls only as these end events; there is no matchingresponse_itemdurable copy and no begin event. Each event carries aninvocationobject (server, tool, arguments), acall_id, aduration, and aresult(Ok or Err).
Recent logs (0.15x) also route many tool calls โ including MCP invocations โ through a custom_tool_call with name = "exec", embedding the actual tool invocations inside a JavaScript program in the input field. This exec pattern is common in current Codex versions and is not legacy.
Decant's Ingest Behavior#
parseCodexSession in src/sources/codex.ts converts both response_item and event_msg records into flat NormalizedBlock structures:
MCP Event Parsing (Current)#
When the parser encounters an event_msg record whose payload.type is mcp_tool_call_end, it synthesizes a linked pair of messages:
- An assistant
tool_usemessage timestamped at the event timestamp minus the reportedduration, carrying themcp__<server>__<tool>name and the call arguments. - A tool
tool_resultmessage timestamped at the event itself, carrying the result text extracted viacontentText()and error state (isError = truewhenresult.Erris present orresult.Ok.isError === true). ThecontentText()function extracts the text content the model actually read: for string outputs it returns the string unchanged, for content arrays it joins text items with newlines, and anything else (images, structured items) is kept as canonical JSON. This means structured tool outputs with content arrays now store the extracted text rather than the full JSON-serialized content array.
The parser normalizes MCP names: if the server does not already start with mcp__, the prefix is added. Dotted and hyphenated tool names (e.g., slack.slack_read_thread) remain intact. Malformed events missing server, tool, or call_id are silently skipped as stream noise.
Response Item Parsing (Native MCP Calls and Exec Programs)#
Native mcp_tool_call response items follow the mcp__<server>__<base> convention and are classified as tool_kind = "mcp" with the server and base name split out .
Exec-wrapped tool calls (including MCP invocations) are ingested with tool_name = "exec", tool_kind = "builtin", and mcp_server = NULL in the tool_call table. The nested tool calls (e.g., tools.apply_patch(...), tools.exec_command(...), or mcp__<server>__<base> invocations) and their arguments survive only in the raw input column. The analytics layer uses Acorn and acorn-walk for AST-based inspection of these JavaScript programs to extract and classify nested calls for activity bucketing, phase classification, and search counting. Raw programs, JSON-encoded programs, and {input: ...} objects receive the same attribution. Tool examples inside strings, regex literals, and comments are ignored; template interpolations and literal commands are inspected through the syntax tree. Dynamic commands that cannot be statically resolved stay unknown and follow the conservative code-bucket policy. Unparseable programs stay in context.
Rendering in the UI#
classifyTool() in src/tools.ts inspects the tool name prefix: names starting with mcp__ become { kind: "mcp" }; everything else (including "exec") becomes { kind: "builtin" }. This classification drives how the transcript is displayed.
presentationForTool() in src/ui/transcript-rendering.ts renders MCP tools as highlighted JSON with source: "mcp".
Native MCP event calls: MCP calls parsed from mcp_tool_call_end events are named mcp__<server>__<tool>, classified as tool_kind = "mcp", and rendered with the MCP server and tool name visible in the UI. Error state (both transport and tool errors) is surfaced in the transcript.
Exec-wrapped tool calls: These are classified as "builtin" and fall through to the shell or generic JSON presentation path โ the tool row label shows exec, not the nested tool names. There is no distinct UI affordance for the inner tools. The only visible trace of the nested invocations (including any MCP calls) is the raw JSON in the tool input/output area. However, the analytics layer correctly attributes these nested calls through AST-based inspection of the JavaScript program, so activity bucketing, phase classification, and search counting reflect the inner tool calls rather than treating all exec programs uniformly as context.
Inspecting MCP Calls in a Session#
Native MCP event calls: MCP calls appear as distinct tool blocks in the transcript with names like mcp__dosu__read_knowledge, mcp__codex_apps__slack.slack_read_thread, etc. The tool row label shows the server and tool name. Error state is visible inline.
To search programmatically, query the tool_call table filtering on tool_kind = 'mcp' or mcp_server IS NOT NULL. The tool_name, mcp_server, and tool_base_name columns are all populated for event-based MCP calls.
Exec-wrapped tool calls: Look for tool blocks labeled exec. Expand the tool input โ the nested tool calls (including any mcp__<server>__<base> invocations) and their arguments are embedded in the raw JSON payload. There is no separate tool row for these nested calls. Query with tool_name = 'exec' and inspect the input column for mcp__ strings or other tool patterns; mcp_server will be NULL. The analytics layer attributes these nested calls correctly through AST-based inspection, so session activity summaries reflect the inner tool behavior even though the transcript UI shows only the exec wrapper.
Tool Call and Result Pairing#
When a tool call ID recurs in the source logs, Decant pairs each call occurrence with the corresponding result occurrence in one-to-one order. This preserves accurate trajectory fidelity: each call is linked to its own result, capturing the authoritative outcome, duration, output volume, and activity bucket for that specific invocation.
Earlier behavior linked every call with a reused ID to the final result for that ID, which doubled output volume, changed outcomes, and shifted activity attribution. The ingest pipeline revision has been incremented, so existing logs will be reprocessed with the corrected pairing logic on the next decant sync, which may change the rendering and analytics for previously ingested Codex executions that reused tool call IDs.
Unmatched results (those that precede a call or arrive after all existing calls with that ID are answered) remain in the transcript but stay unlinked and cannot shift the outcome of later calls that reuse the same ID.
Automatic Archive Enrichment#
Schema v22 introduced an ingest pipeline revision checkpoint. When you upgrade, existing ingest_source rows start at revision 0, so the next decant sync transactionally re-ingests each unchanged source file once, applying updated parsers and pairing logic to your archive. Subsequent syncs skip the unchanged source again. Future parser improvements that need backfill will increment the pipeline revision; no manual archive deletion is required.