Skip to content

[FEATURE]: Granular permission pattern matching for MCP tools #12358

Closed

Description

@karlkurzer

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Describe the enhancement you want to request

Problem

Granular permission rules (object syntax) documented at https://opencode.ai/docs/permissions/#granular-rules-object-syntax don't work for MCP tools. Pattern matching only applies to built-in tools (bash, edit, read, etc.).
Many MCP tools bundle multiple operations behind a single tool name (e.g., outlook_calendar_meeting with operation=create|read|update|delete). There's no way to allow read-only operations while requiring approval for mutations.
Tested patterns (none matched)

The permission prompt shows MCP tool input as:
outlook_calendar_meeting operation=read, meetingId=AAMk..., meetingChangeKey=DwAA...
Patterns tried in opencode.jsonc — none bypassed the prompt:

"outlook_calendar_meeting": {
  "*": "ask",
  "operation=read*": "allow",
  "*operation=read*": "allow",
  "*\"operation\":\"read\"*": "allow",
  "[operation=read*": "allow"
}

Root cause

As identified in #12111, MCP tools fall through to a generic case in permission.tsx (line 262-264) that doesn't run the input() data through pattern matching the way built-in tools do.
Expected behavior
Granular permission patterns should work for MCP tools the same way they work for built-in tools. Using the displayed format [key=value, ...] as the match string would be consistent:
outlook_calendar_meeting: { *: ask, *operation=read*: allow }

Use case

MCP servers like Outlook, Slack, or database tools often expose a single tool with CRUD operations. Users need to:

  • Allow read operations (calendar reads, email inbox) without prompts
  • Ask for write operations (sending emails, creating meetings)
  • Deny destructive operations (deleting events)

Possible approach

The input() memo in permission.tsx (lines 128-138) already holds the MCP tool parameters. The fix would involve serializing those parameters into a matchable string (e.g., the same key=value, ... format shown in the prompt) and running it through the existing pattern matching logic that built-in tools already use. This could potentially be addressed alongside #12111 since both touch the same MCP fallback path.

Related

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Feb 5, 2026
  2. github-actions commented on Feb 5, 2026

    @github-actions
    Contributor

    This issue might be related to existing issues. Please check:

    This feature builds upon the improvements proposed in these issues, particularly #12111 which needs to be addressed first to display the tool parameters that would be matched against the patterns.

  3. added a commit that references this issue on Feb 6, 2026
    b0da2f1
  4. github-actions commented on Apr 7, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  5. mofleury commented on May 20, 2026

    @mofleury

    Hi,

    I'm hitting this exact limitation with the IntelliJ MCP server. I have intellij_read_file configured with granular patterns (allow .java/.class, ask for everything else) to prevent accidental secret leakage from config files. The object syntax is silently ignored — it always prompts regardless of the file path.

    My use case is security-focused: I want to deny/ask for reads of sensitive paths (**/.env, etc.) while allowing normal source file reads without friction. Today the only options are "allow all" or "ask for every single read", which makes the IntelliJ MCP integration very tedious.

    Is there a timeline for supporting granular patterns on MCP tools? This feature would be a huge help for me. Thank you!

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

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions