feat: Add Permission Control for MCP Tools #1803

Closed
opened 2026-02-16 17:32:41 -05:00 by yindo · 2 comments
Owner

Originally created by @thuanpham582002 on GitHub (Sep 23, 2025).

Originally assigned to: @rekram1-node on GitHub.

Summary: MCP tools currently bypass OpenCode's permission system while built-in tools require approval.
Add permission control for MCP tools.

Problem

Currently, MCP (Model Context Protocol) tools completely bypass OpenCode's permission system:
Built-in tools (have permission checks):

await Permission.ask({
  type: "bash",
  pattern: patterns,
  sessionID: ctx.sessionID,
   ... approval flow
})

MCP tools (bypass permission system):

In packages/opencode/src/session/prompt.ts

for (const [key, item] of Object.entries(await MCP.tools())) {
  item.execute = async (args, opts) => {
     NO Permission.ask() here!
    await Plugin.trigger("tool.execute.before", ...)
    const result = await execute(args, opts)
    await Plugin.trigger("tool.execute.after", ...)
    return { output }
  }
}

Security Concerns

• No user control: MCP tools can execute without approval
• Inconsistent security: Built-in tools require approval, MCP tools don't
• Potential abuse: Malicious MCP servers could perform harmful actionsl

Originally created by @thuanpham582002 on GitHub (Sep 23, 2025). Originally assigned to: @rekram1-node on GitHub. **Summary**: MCP tools currently bypass OpenCode's permission system while built-in tools require approval. Add permission control for MCP tools. ## Problem Currently, MCP (Model Context Protocol) tools completely bypass OpenCode's permission system: **Built-in tools** (have permission checks): ```typescript await Permission.ask({ type: "bash", pattern: patterns, sessionID: ctx.sessionID, ... approval flow }) ``` **MCP tools** (bypass permission system): In packages/opencode/src/session/prompt.ts ``` typescript for (const [key, item] of Object.entries(await MCP.tools())) { item.execute = async (args, opts) => { NO Permission.ask() here! await Plugin.trigger("tool.execute.before", ...) const result = await execute(args, opts) await Plugin.trigger("tool.execute.after", ...) return { output } } } ``` ## Security Concerns • No user control: MCP tools can execute without approval • Inconsistent security: Built-in tools require approval, MCP tools don't • Potential abuse: Malicious MCP servers could perform harmful actionsl
yindo closed this issue 2026-02-16 17:32:41 -05:00
Author
Owner

@rekram1-node commented on GitHub (Sep 23, 2025):

totally agree

@rekram1-node commented on GitHub (Sep 23, 2025): totally agree
Author
Owner

@rekram1-node commented on GitHub (Sep 23, 2025):

this will be done as part of: #1961

@rekram1-node commented on GitHub (Sep 23, 2025): this will be done as part of: #1961
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1803