| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Subagents spawned via the Task tool could see MCP tools in their tool registry but got permission denied when trying to execute them. The root cause was that deriveSubagentSessionPermission only forwarded deny rules and external_directory rules from the parent session, never copying the allow rules that MCP tools require. MCP tool permission keys contain underscores (e.g. context7_resolve-library-id, matrix_matrix_read) as they follow the sanitize(clientName) + '_' + sanitize(toolName) naming pattern. This fix copies all allow rules whose permission key contains an underscore, which covers MCP tools while leaving native tools (todowrite, task, bash, edit, etc.) unaffected since they don't contain underscores in their permission names. Wildcard '*' allow rules are also forwarded. Co-authored-by: Olli Kurki <kurki.olli@outlook.com> Co-authored-by: AI <ai@opencode.ai>
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found one potential duplicate: PR #30085 - fix(opencode): grant MCP tool permissions in subagent sessions This PR appears to be addressing the exact same issue as the current PR (#30288). Both PRs are focused on granting/inheriting MCP tool permissions in subagent sessions, which are the issues closed by #16491 and #3808. You should verify whether PR #30085 is open and compare its implementation approach with PR #30288 to determine if one should be closed in favor of the other. |
Sorry, something went wrong.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
|
For context: there are other open PRs addressing #16491 (#30085) that take a different approach — they import the MCP service into task.ts and enumerate tool names at spawn time. This PR takes a lighter approach: pattern-based filtering in subagent-permissions.ts that doesn't require importing MCP internals. Both approaches solve the same problem; ours is just more narrowly scoped to MCP tool permission inheritance without coupling to the MCP service layer. |
Sorry, something went wrong.
|
After comparing #30085 and #30288, #30288 is clearly the better fix. It inherits parent session permissions cleanly, respects the existing allow/deny model, and follows least privilege—unlike #30085 which hard‑codes full MCP access. Go with #30288. |
Sorry, something went wrong.
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Issue for this PR
Closes #16491, #3808
Type of change
What does this PR do?
Subagents spawned via the Task tool can see MCP tools in their tool registry but get permission denied when trying to execute them. The root cause is that deriveSubagentSessionPermission() only forwards deny rules and external_directory rules from the parent session — never the allow rules that MCP tools require.
MCP tool permission keys follow the pattern sanitize(clientName) + "_" + sanitize(toolName) (e.g. context7_resolve-library-id, matrix_matrix_read). This fix copies all allow rules whose permission key contains an underscore, which covers MCP tools while leaving native opencode tools (todowrite, task, bash, edit, etc.) unaffected since they don't contain underscores in their names. Wildcard * allow rules are also forwarded.
In deriveSubagentSessionPermission() (packages/opencode/src/agent/subagent-permissions.ts), a new filter extracts MCP-allow rules:
These are then spread into the returned ruleset alongside the existing deny, external_directory, and task/todowrite defaults. The approach is:
How did you verify your code works?
Added 4 new test cases to packages/opencode/test/agent/plan-mode-subagent-bypass.test.ts:
All 8 tests pass (4 existing + 4 new):
Screenshots / recordings
N/A — no UI changes, purely a permission logic fix.
Checklist