Repository navigation
Codex CLI ignores "read-only" mode and approval policy by executing MCP edit tools #4152
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingmcpIssues related to the use of model context protocol (MCP) serversIssues related to the use of model context protocol (MCP) servers
Description
What version of Codex is running?
0.40.0
Which model were you using?
gpt-5-codex
What platform is your computer?
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
- Configure Codex CLI with the following config.toml (note sandbox_mode = "read-only" and approval_policy = "on-request"):
model = "gpt-5-codex"
sandbox_mode = "read-only" # <=== SAID READ-ONLY MODE
approval_policy = "on-request"
[mcp_servers.webstorm]
command = "<...>/.cache/JetBrains/RemoteDev/dist/808494ac93c79_WebStorm-252.25557.32/jbr/bin/java"
args = ["-classpath", "<...>/.local/share/JetBrains/WebStorm2025.2/mcpserver/lib/mcpserver-frontend.jar:<...>/.cache/JetBrains/RemoteDev/dist/808494ac93c79_WebStorm-252.25557.32/lib/util-8.jar", "com.intellij.mcpserver.stdio.McpStdioRunnerKt"]
env = { "IJ_MCP_SERVER_PORT" = "64342" }- Verify the CLI status (note again that sandbox mode is reported as read-only):
/status
📂 Workspace
• Path: ~/Workspace/<...>
• Approval Mode: on-request
• Sandbox: read-only # <=== SAID READ-ONLY MODE
• AGENTS files: AGENTS.md
🧠 Model
• Name: gpt-5-codex
• Provider: OpenAI
• Reasoning Effort: None
• Reasoning Summaries: Auto
💻 Client
• CLI Version: 0.40.0
...
- Run a command asking to edit files
▌ > I want to see the diff before any edit application
• Ran git diff -- <...>/file.component.ts # <=== DOES NOTHING, NO VALIDATION GIVEN
tool running...
webstorm.replace_text_in_file({"pathInProject":"<...>/file.component.ts","oldText":" .map((_value: number, index: number):
WeekLabel => ({\n","newText":" .map((_value: number, index: number) => ({\n"})
tool success, duration: 38ms
webstorm.replace_text_in_file({"pathInProject":"<...>/file.component.ts","oldText":" .map((_value: number, index: number):
WeekLabel => ({\n","newText":" .map((_value: number, index: number) => ({\n"})
[success]Result:
Even though both the config and status report read-only mode with approval on-request, the CLI uses MCP tools (webstorm.replace_text_in_file) to bypass the restrictions and apply file edits without asking for validation or confirmation.
What is the expected behavior?
The Codex CLI should always prompt for permission and receive confirmation before making any edits to the file, even when using MCP tools.
What do you see instead?
When running the Codex CLI, it uses MCP tools to edit the file automatically without asking for validation or confirmation :
▌ > I want to see the diff before any edit application
• Ran git diff -- <...>/file.component.ts # <=== DOES NOTHING, NO VALIDATION GIVEN
tool running...
webstorm.replace_text_in_file({"pathInProject":"<...>/file.component.ts","oldText":" .map((_value: number, index: number):
WeekLabel => ({\n","newText":" .map((_value: number, index: number) => ({\n"})
tool success, duration: 38ms
webstorm.replace_text_in_file({"pathInProject":"<...>/file.component.ts","oldText":" .map((_value: number, index: number):
WeekLabel => ({\n","newText":" .map((_value: number, index: number) => ({\n"})
[success]Additional information
Webstorm version :
WebStorm 2025.2.1
Build #JBC-252.25557.32, built on August 14, 2025
Runtime version: 21.0.8+1-b1038.68 amd64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmcpIssues related to the use of model context protocol (MCP) serversIssues related to the use of model context protocol (MCP) servers
Activity
[-]Codex CLI bypass "Read-only" mode and approval with MCP edit tools[/-][+]Codex CLI ignores "read-only" mode and approval policy by executing MCP edit tools[/+]gpeal commentedon Oct 18, 2025
MCPs operate outside of the Codex exec sandbox. If you need to guarantee that the sandbox is fully respected, you'll need to disable MCPs or add the desired functionality to the MCP. Codex has no way to control what commands a MCP server runs.
NekoGryphou commentedon Oct 21, 2025
Other CLI tools can figure out MCP tools just fine ; you’re just being lazy about adding those controls.
fix(launcher): codex review leg runs against a staged copy, not the l…
docs(keeper): record what the read-only write-path note was checked a…
docs(keeper): record what the read-only write-path note was checked a…