opencode-cursor icon indicating copy to clipboard operation
opencode-cursor copied to clipboard

Permissions are broken when installing OpenCode with this plugin.

Open cantalupo555 opened this issue 6 months ago • 4 comments

When you install this plugin, OpenCode no longer respects the settings in opencode.json. It begins editing and executing commands without our confirmation.

The plugin is instructing the model to use the mcptool CLI via bash to access MCP servers. Because I have "bash": { "*": "allow" } in my opencode.json, bash commands are being executed automatically, bypassing the specific rules I had in ask or deny. (This shouldn't happen, since OpenCode allows exception lists even when “*”: “allow” is set)

This created a loophole where the model could execute any MCP tool without confirmation, as OpenCode perceived it as a simple "allowed" bash command.

Image Imagem

cantalupo555 avatar May 20 '26 02:05 cantalupo555

Thanks for raising this, I had a look at it today.

I think the confusing bit here is that the mcp bridge currently uses mcptool as a shell-based bridge. That means opencode applies the bash permission rule to mcptool call ..., rather than a separate mcp permission rule.

So with a config like bash: { "*": "allow" }, opencode is basically doing what it was told to do: allow shell commands. The catch is that broad bash access also allows commands that can reach mcp tools through mcptool.

I’ve added a readme note to make this clearer. If you want mcp calls to keep asking for confirmation, the safer config is to keep bash as ask, or add an explicit ask/deny rule for mcptool call *.

I’ll leave this open for now in case there’s a better way to expose mcp tools without relying on the shell bridge.

Nomadcxx avatar May 20 '26 19:05 Nomadcxx

I ran into this as well while testing the plugin. It seemed like OpenCode's permission system no longer applied correctly when using bash rules. I also noticed this behavior could affect other models, not just the Cursor ones.

Is this architecture currently required because of an OpenCode limitation, or could MCP tools eventually be exposed as proper OpenCode tools so permissions continue working normally?

BrianValente avatar May 21 '26 16:05 BrianValente

@BrianValente In fact, this affects the entire OpenCode session, as long as the plugin is installed... regardless of the LLM/provider.

@Nomadcxx I've fixed this issue; I can go ahead and submit the PR. That way, we'll be able to thoroughly review my proposed fix.

cantalupo555 avatar May 21 '26 17:05 cantalupo555

Thanks, yeah fair question.

From memory, this was mostly a cursor-agent limitation rather than an opencode limitation.

We did try exposing the mcp tools more directly as plugin tools, but cursor-agent did not reliably call those tools. Shell was the path it would reliably use, so mcptool became the bridge.

That does work, but the tradeoff is the one raised here: opencode sees a bash call, not a first-class mcp tool call, so broad bash rules also cover mcptool call ....

I’d prefer this to be first-class tool routing eventually, but I’m being cautious because changing it touches permissions, tool routing, and provider behaviour all at once.

Nomadcxx avatar May 23 '26 04:05 Nomadcxx

Triage (2026-06-18): Keeping open as bug — partial mitigation shipped, full fix still desired.

Mitigations already in main:

  • PR #77 (v2.4.x): system prompt now recommends direct mcp__<server>__<tool> calls instead of mcptool via bash
  • PR #79: prompt shows exact callable MCP tool names
  • README note: broad bash: { "*": "allow" } also permits mcptool call ...

Why still open: first-class MCP tool routing (so OpenCode permission rules apply per-tool, not via bash) is the desired end state but needs careful rollout across permissions, tool routing, and cursor-agent behaviour.

Nomadcxx avatar Jun 17 '26 14:06 Nomadcxx

Great progress! I can't wait to test it out and follow the progress more closely.

cantalupo555 avatar Jun 17 '26 19:06 cantalupo555