Skip to content

Keep Claude's MCP approval keys out of the Codex hooks file - #15

Open
anessbelbati wants to merge 1 commit into
Openpod:mainfrom
anessbelbati:fix/codex-hooks-file
Open

anessbelbati wants to merge 1 commit into
Openpod:mainfrom
anessbelbati:fix/codex-hooks-file

Conversation

@anessbelbati

Copy link
Copy Markdown

What problem does this fix, and what changes for the user?

Setup builds .claude/settings.json and .codex/hooks.json with the same function, so both get enableAllProjectMcpServers and enabledMcpjsonServers, which only Claude Code reads. Codex accepts only description and hooks at the top of a hooks file, and with any other key it loads no hooks from it:

failed to parse hooks config <project>/.codex/hooks.json: unknown field `enableAllProjectMcpServers`, expected `description` or `hooks`

So under Codex the context hook never runs, on macOS too, and every prompt goes out without the Video FS context.

The two keys now go into Claude's file only. Setup also removes them from a .codex/hooks.json the app wrote earlier, so an existing project recovers when it's opened again. A hooks file the user wrote is left alone.

How was it tested?

Real Codex against a stand-in model server, in a project prepared by setupAgentProject:

.codex/hooks.json macOS Linux
as main writes it 0 hooks loaded, no context in the request 0 hooks loaded, no context in the request
as this branch writes it 1 hook loaded and ran, context in the request 1 hook loaded and ran, context in the request

Codex 0.160.1 on Oct 7 and 0.162.0 on Oct 9 (run: https://github.com/anessbelbati/impractical-video/actions/runs/37915846873), started with --dangerously-bypass-hook-trust in place of a user who approved the project's hooks, as the README asks. Claude Code still gets the context and the video-fs tools. A new test covers the cleanup, and the compatibility test now checks the file has no top-level key besides hooks.

CI (verify), unchanged, passes on this branch on today's main: https://github.com/anessbelbati/impractical-video/actions/runs/38231933543

Any remaining limitations or migration steps?

  • No migration step.
  • On a fresh Linux runner Codex once stopped the hook at the 5-second timeout setup writes, so that prompt went out without the context. In other runs the hook took 1.4 s and 0.3 s.
  • On Linux, Codex still gets none of the app's tools. That has a different cause and is the next pull request.

Setup wrote the same JSON to .claude/settings.json and .codex/hooks.json,
including enableAllProjectMcpServers and enabledMcpjsonServers. Codex accepts
only "description" and "hooks" at the top of a hooks file, and with any other
key it loads no hooks from the file at all:

    failed to parse hooks config .../.codex/hooks.json: unknown field
    `enableAllProjectMcpServers`, expected `description` or `hooks` at
    line 2 column 30

So the context hook never ran under Codex, and every prompt went out without
the Video FS context. Measured with Codex 0.160.1 against a stand-in model
server, on macOS and on Linux: 0 hooks loaded from the file as written and
no context in the model request; with the two keys gone, 1 hook loaded, it
ran, and the context was in the request.

The two keys now go into Claude's file only. Setup also removes them from a
.codex/hooks.json that is the desktop's own earlier output, under the same
ownership test enableProjectMcpServers already uses, so an existing project
recovers the next time it is opened. A file the user wrote is left alone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant