Skip to content

Codex MCP usage is missing from recent lookback windows #478

Closed

Description

@chr-evensen

I’m seeing Codex MCP usage show up in long lookback ranges, but not in recent ones like today, week, or month.

I believe this is a parsing issue in the Codex provider. Recent Codex sessions still contain MCP activity, but the MCP completion event now appears as event_msg with type: "mcp_tool_call_end". Codeburn appears to be counting the surrounding token usage, but not attributing the MCP tool call itself.

What I see:

  • Codex sessions are detected normally.
  • Token usage is recorded.
  • MCP usage is missing from recent windows.
  • Older history still includes MCP usage.

What I expect:

  • MCP calls from recent Codex sessions should be attributed the same way as older sessions.

I have a local session example that reproduces this, but I’m not attaching the raw JSONL publicly because it contains workspace and session details. I can share a redacted excerpt if that helps.

If useful, I can also help turn this into a minimal repro snippet with just the relevant event shapes.

Activity

  1. iamtoruk commented on Jun 18, 2026

    @iamtoruk
    Member

    Fixed in #513 (merged to main).

    Root cause: recent Codex sessions report a completed MCP call as an event_msg with type: "mcp_tool_call_end" rather than a function_call item. The parser only built its tool list from function_call and patch_apply_end events, so the surrounding token usage was still counted but the MCP tool itself was dropped, exactly as you described. Older sessions emitted MCP as function_call items carrying the mcp__ prefix, which is why long windows still showed it.

    The fix reads invocation.server / invocation.tool from the event and rebuilds the canonical mcp__<server>__<tool> name. I validated it against real local Codex data: 5 mcp_tool_call_end events that were dropped before are now attributed (with no change to the total call count or token figures).

    One note for when you pick up the build: the Codex result cache is bumped (v3 -> v4) as part of this, so previously scanned recent sessions re-parse automatically and the missing MCP usage reappears, no manual cache clear needed.

    Thanks for the precise report, the event-shape detail made this quick to pin down.

  2. added a commit that references this issue on Jun 18, 2026
    80e3de3
  3. chr-evensen commented on Jul 2, 2026

    @chr-evensen
    Author

    Hello, @iamtoruk :)

    I still can not get this to work. My assumption is that I am using a CLI approach for MCP lookup, via https://github.com/philschmid/mcp-cli, to save tokens and the context window. With this, I am not activating all my MCP servers in Codex for Codex to see every tool instruction and schema. Only when Codex needs MCP server XYZ will it use the CLI to look up the relevant tool and then fire up the server. A nice and handy way to keep context windows clean, by the way :)

    I just wanted you to know, as I see that many MCP CLI tools like this are becoming increasingly popular.

    Have a nice summer,
    Christian

  4. added a commit that references this issue on Jul 10, 2026
    b78e862
  5. iamtoruk commented on Jul 10, 2026

    @iamtoruk
    Member

    Hi @-christian, this is now fixed on main via #656 (following up on #513).

    The root cause was exactly what you described: with a CLI-based MCP setup like philschmid/mcp-cli, Codex never emits a native mcp_tool_call_end event, it just runs a shell command. #513 only handled the native path, so your CLI-wrapped calls stayed invisible in the MCP breakdown.

    What #656 does:

    • Recognizes mcp-cli [options] call <server> <tool> invocations (including the bash -lc "..." wrapper and flags like -c ./config) and attributes them as mcp__<server>__<tool>, so they now appear in the MCP breakdown. The command still counts as a shell command too, since it genuinely is one, no double-counting of tokens.
    • Forces a re-parse of your already-cached Codex sessions, so the missing MCP usage reappears automatically. No manual cache clear needed. (This same change also retroactively picks up any native MCP calls that were cached before fix(codex): attribute MCP calls emitted as event_msg/mcp_tool_call_end (#478) #513 shipped.)

    One heads-up: it's currently scoped to the mcp-cli binary specifically. If you (or others) use a different CLI-MCP wrapper, let us know the exact command shape and we can add it. As you noted, these tools are getting popular, so this is a pattern we want to support well.

    Thanks again for the precise report and for sticking with it, the detail about the CLI approach was what pinned it down. Enjoy the rest of your summer.

  6. chr-evensen commented on Aug 22, 2026

    @chr-evensen
    Author

    Good morning, @iamtoruk 😄

    Still reproducible in Codeburn 0.9.20 with current Codex desktop sessions.

    I ran this successful, read-only command:
    mcp-cli call optimizely-cms-mcp help '{}'

    Immediately after, codeburn report --period today --format json returned:
    "mcpServers": []

    The command is persisted in the session as:

    • outer event: event_msg
    • payload type: item_completed
    • nested item type: CommandExecution
    • command: ["/bin/zsh", "-lc", "mcp-cli call optimizely-cms-mcp help '{}'"]

    It is counted under Bash, but not under MCP. Which kinda makes sense, of course. The #656 mcp-cli call matcher appears present, but this current item_completed/CommandExecution event path is not being passed through it.

    The same current Codex event shape also prevents Skills attribution. Skill instructions/files are accessed through response_item → custom_tool_call with name: "exec" (often reading a SKILL.md), rather than an explicit Skill tool call or native read item. Codeburn counts these as Bash, and skills remains empty.

    Please consider extracting Skills from current custom_tool_call / item_completed records as well, or otherwise recognize exec reads of SKILL.md.

    PS! Using Codex to debug this so I hope it makes sense 😄

    Have a great weekend!

  7. added a commit that references this issue on Aug 22, 2026
  8. iamtoruk commented on Aug 22, 2026

    @iamtoruk
    Member

    Hi @chr-evensen — verified both, fixed on main via #1092 (merged). Thanks for the event-shape detail again; it made this a short investigation.

    The skills half reproduced immediately, and your diagnosis was precise. A custom_tool_call payload has no arguments field at all — it carries input. The #656 mcp-cli matcher sits inside the branch that parses arguments, so for every exec custom tool it never ran, along with the command/file extraction. On a local 1,397-rollout corpus that's 4,687 exec records skipping the matcher entirely, and Codex skills was empty across all of history.

    The item_completed / CommandExecution shape isn't in my rollouts (0 occurrences in those 1,397 files, Codex Desktop and CLI, 0.111 through 0.147-alpha), so I verified it against the shipped Codex binary instead: EventMsg::ItemCompleted → item_completed, and an internally-tagged TurnItem::CommandExecution → CommandExecutionItem { command, cwd, parsed_cmd, exit_code, … }. That's exactly what you described, down to the PascalCase item tag and the argv command. Your setup emits it, mine doesn't — which is why the CLI-wrapped call never reached the matcher for you even after #656.

    What #1092 does: all three shapes Codex uses to record a shell command — function_call arguments, the exec custom tool's input program, and the item model's CommandExecution — now feed a single classification pipeline, so mcp-cli call <server> <tool> can't be visible to one and invisible to another again. mcp-cli call optimizely-cms-mcp help '{}' inside ["/bin/zsh","-lc",...] attributes to mcp__optimizely-cms-mcp__help and still counts as Bash, same as before.

    Skills: since Codex has no skill tool, a skill load is recognized as a shell read of a SKILL.md — the command must start with a file-reading binary (cat/sed/head/tail/less/more/bat) and the path must end in <name>/SKILL.md. The skill is <name>, the same key the Pi parser uses (#588) and the same vocabulary the Claude parser records, so the Skills breakdown reads the same across providers. A grep that merely mentions a SKILL.md is a search, not a load, and stays Bash. On my corpus that turned an empty Skills dimension into 7 skills over 35 turns, with Bash unchanged at 42,170 and cost, tokens, calls and every daily rollup byte-identical — this is purely a classification change.

    Your cached sessions re-parse automatically on upgrade (the Codex result cache and parse version both move), so no manual cache clear.

    One caveat worth naming: I could only test the item_completed path against fixtures and the Codex schema, not a real rollout of my own. If it still comes back empty for you after upgrading, a redacted excerpt of just the item_completed line would settle it in minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions