Repository navigation
Conversation
…or exact lookups Replace the Codex integration, which appended a "MANDATORY / NEVER use grep" skill to ~/.codex/AGENTS.md and registered an MCP server without tools. Codex then stopped searching any other way. The integration is now a native Codex plugin from the same repository marketplace as the Claude plugin: - MCP server (`mgrep mcp --expose-tools`) with one read-only `search` tool. It runs outside Codex's network sandbox, so searches need no approval prompt, and it syncs the session directory in the background for the lifetime of the session. - SessionStart hook that only adds neutral guidance: mgrep for conceptual questions, rg/grep for exact strings and symbols. - Short neutral skill. - `install-codex` adds the marketplace and installs the plugin; `uninstall-codex` reverses it. Both clean up the legacy AGENTS.md block and MCP registration. Supporting changes the MCP tool needs: search logic extracted to src/lib/search.ts and shared by the CLI and the tool, non-interactive store creation for the MCP server, version read from package.json, and startWatch no longer calls process.exit and reports whether watching started.
F0rce
marked this pull request as ready for review
October 6, 2026 17:33
This was referenced Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mgrep install-codexappends a full skill file ("MANDATORY ... NEVER use grep") to the global~/.codex/AGENTS.md. With it, Codex stops using any other way of searching. Without it, Codex ignores mgrep. The install also registerscodex mcp add mgrep mgrep mcp, a server that exposes no tools, returns an invalidCallToolresult and reports version0.1.3; it only exists to start the watcher. Searches go through the shell CLI inside Codex's network sandbox, so eachmgrep searchasks for approval.Expected: Codex uses mgrep where semantic search helps, keeps
rg/grepfor exact lookups, and searches without approval prompts.Change
The Codex integration becomes a native Codex plugin, published from the same repository marketplace as the Claude plugin (
.agents/plugins/marketplace.json,plugins/mgrep/.codex-plugin/plugin.json):mgrep mcp --expose-toolswith one read-onlysearchtool. Codex starts it in the session directory and stops it at session end. It syncs that directory in the background, so no watcher outlives the session. The first search waits up to 20 s for the initial sync, then searches the existing index and says so.rg/grepfor exact strings, symbols and regexes. Codex asks the user to review it once.mgrep install-codexadds the marketplace and installsmgrep@Mixedbread-Grep;mgrep uninstall-codexreverses it. Both remove the legacyAGENTS.mdblock and MCP registration.Changes outside
src/install/codex.tsthat the MCP tool needs: search logic moves tosrc/lib/search.tsso the CLI and the tool share it;createStore({ interactive: false })so the server never prompts; the version comes frompackage.json;startWatchno longer callsprocess.exitand reports whether watching started, so the server can wait for it. The Claude plugin is unchanged.Scope and approval
There is no prior issue or discussion. The direction matches the unmerged maintainer branch
chore/use-mcp-for-code(MCP tool instead of shell search). Happy to open a discussion first or split differently if you prefer.Verification
Selective use, measured with
codex exec(Codex CLI 0.160.1,gpt-6.1-sol, reasoninghigh) in freshCODEX_HOMEs on a private 853-file TypeScript monorepo. 10 questions: 6 conceptual (no identifiers named) and 4 exact (a symbol, a literal error string, a config key, an env var). 5 runs per question and variant, 100 runs, none failed. Correct = the answer cites at least one expected file.Cost index = uncached input + 0.1 × cached input + 8 × output tokens. With the hook Codex makes about one mgrep call per conceptual question, reads the returned ranges and confirms with
rg; it never uses mgrep for exact lookups. Cost and correctness stay within noise. This PR does not claim mgrep makes Codex cheaper on this repository.A single-run screen of stronger wordings: an explicit decision rule led to up to 17 mgrep calls on one question; "always start with mgrep" also used mgrep on exact lookups and doubled their cost, which is the current
AGENTS.mdbehaviour.Other checks:
test/codex.batscovers the exactcodexinvocations of install and uninstall, legacyAGENTS.mdcleanup with surrounding content kept, idempotent reinstall, and the hook output.test/mcp.batscovers the tool schema, root resolution, waiting for the watcher, the 20 s bound and the fallback sync. 92/92 pass.CODEX_HOME:codex mcp listshows the server and app-serverhooks/listshows the hook.codex execsessions the MCP server starts in the session directory,mgrep.searchruns without an approval prompt, and nothing keeps running after the session ends.Not checked: interactive Codex TUI on a machine without a previous mgrep install, and Windows.
Model and harness: Claude Opus 5.5 (1M context) in Claude Code for design, review and benchmarking; GPT-6.1-Sol in Codex for implementation.