Skip to content

MCP filesystem tools bypass plan mode edit: deny permission rule #30291

@jpravetz

Description

@jpravetz

Description

When plan mode is configured with "edit": "deny" in opencode.json, MCP filesystem tools (e.g., filesystem_edit_file, filesystem_write_file) are not blocked. They execute successfully despite the explicit deny rule.

The "edit" permission rule appears to only gate opencode's native edit tools, not MCP tools that perform equivalent file-modification operations. Since MCP tools are dispatched through the MCP protocol with their own permission namespace (e.g., filesystem_edit_file), the "edit" deny rule never sees them.

Steps to Reproduce

  1. Configure an agent with "edit": "deny" (e.g., the default plan agent or a custom plan agent):
    "plan": {
      "mode": "primary",
      "permission": {
        "edit": "deny",
        ...
      }
    }
  2. Ensure an MCP filesystem server is configured (e.g., @anthropic/claude-code's filesystem MCP or any MCP server providing filesystem_edit_file/filesystem_write_file tools).
  3. Enter plan mode and ask the agent to modify a file.
  4. The agent uses the MCP filesystem tool to write/edit the file successfully.

Expected Behavior

Plan mode with "edit": "deny" should block ALL file-modifying tools, including those provided by MCP servers. This is the core invariant of plan mode being read-only.

Actual Behavior

MCP filesystem tools bypass the "edit" deny rule because the permission system doesn't map MCP tool names to the edit permission key. The AI sees the MCP tools as available and uses them.

Environment

  • opencode version: latest
  • MCP filesystem server configured
  • Plan mode active with "edit": "deny"

Related Issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions