Skip to content

feat(opencode): mcp permission patterns - #12801

Closed
karlkurzer wants to merge 2 commits into
anomalyco:devfrom
karlkurzer:feat/mcp-permission-patterns
Closed

karlkurzer wants to merge 2 commits into
anomalyco:devfrom
karlkurzer:feat/mcp-permission-patterns

Conversation

@karlkurzer

Copy link
Copy Markdown

Summary

  • Serialize MCP tool arguments into a deterministic sorted key=value pattern string and use it for permission rule matching (instead of always "*")
  • Display MCP tool arguments in the TUI permission prompt so users can see what they're approving
  • Add PermissionNext.serialize() with 13 unit + integration tests

Problem

Granular permission rules didn't work for MCP tools. Pattern matching only applied to built-in tools (bash, edit, read, etc.) because MCP tools always passed patterns: ["*"] — making all user-defined patterns unmatchable.

Solution

Reuse the existing wildcard infrastructure by giving it something meaningful to match. MCP tool args are serialized into a sorted key=value, key=value string (e.g., meetingId=AAMk..., operation=read) and passed as the permission pattern. Users can now write:

"outlook_calendar_meeting": {
  "*": "ask",
  "*operation=read*": "allow",
  "*operation=delete*": "deny"
}

Zero changes to core permission evaluation (evaluate, ask, fromConfig, Wildcard.match). Fully backwards compatible — empty args falls back to ["*"].

Files changed

File Change
src/permission/next.ts Add PermissionNext.serialize()
src/session/prompt.ts Use serialized args as MCP permission pattern
src/cli/cmd/tui/routes/session/permission.tsx Display MCP tool args in permission prompt
test/permission/next.test.ts 8 serialize + 5 integration tests

Closes #12358

Karl Kurzer added 2 commits February 6, 2026 17:15
Serialize MCP tool arguments into a deterministic key=value string and
pass it as the permission pattern instead of always using "*". This
lets users write wildcard rules in opencode.json that match against
specific MCP tool inputs, e.g.:

  "outlook_calendar_meeting": {
    "*": "ask",
    "*operation=read*": "allow",
    "*operation=delete*": "deny"
  }

Also display MCP tool arguments in the TUI permission prompt so users
can see what they are approving.

Closes anomalyco#12358
@github-actions

github-actions Bot commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title Feat/mcp permission patterns doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Found a potentially related PR:

This PR appears related because it also addresses displaying tool arguments in permission prompts, which is one of the key features in the current PR (showing MCP tool arguments in the TUI permission prompt).

@karlkurzer karlkurzer changed the title Feat/mcp permission patterns feat(opencode) mcp permission patterns Feb 12, 2026
@karlkurzer karlkurzer changed the title feat(opencode) mcp permission patterns feat(opencode): mcp permission patterns Feb 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Apr 11, 2026
@kaorukobo

Copy link
Copy Markdown

+99. I really hope this gets reopened and merged! 🙏

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.

[FEATURE]: Granular permission pattern matching for MCP tools

2 participants