Repository navigation
Description
Description
Bug Description
When a subagent session is spawned via the Task tool, MCP tools from configured MCP servers appear in the subagent's tool registry but cannot be executed due to missing session permissions. The subagent can see the tools (e.g., tymemud-builder_read_room, context7_resolve-library-id) in its function list, but when attempting to call them, the permission system blocks execution.
What Happened
- Parent agent successfully uses MCP tools (e.g.,
tymemud-builder_list_rooms_in_zone) - Subagent spawned via Task tool reports MCP tools are "not appearing in available function list" or gets permission denied
- Subagent can see MCP tools in the registry but lacks permission to execute them
- Permission check fails at execution time in
packages/opencode/src/session/prompt.ts
Root Cause Analysis
In packages/opencode/src/tool/task.ts (lines 66-102), when creating a subagent session, only explicit permissions are granted for native tools (todowrite, todoread, task). MCP tools are not included in the session's permission array:
return await Session.create({
parentID: ctx.sessionID,
title: params.description + ` (@${agent.name} subagent)`,
permission: [
{
permission: "todowrite",
pattern: "*",
action: "deny",
},
{
permission: "todoread",
pattern: "*",
action: "deny",
},
// ... MCP tools NOT explicitly granted permission
],
})When MCP tools are added to the tool registry in packages/opencode/src/session/prompt.ts (lines 830-921), they are wrapped with a permission check via ctx.ask(). The permission ruleset is merged from input.agent.permission and input.session.permission (line 778), but since subagent sessions don't have MCP tool permissions explicitly granted, the check fails.
Relevant Code Locations
File: packages/opencode/src/tool/task.ts, lines 66-102 - Subagent session creation
File: packages/opencode/src/session/prompt.ts, lines 773-780, 830-921 - Permission merging and MCP tool wrapping
File: packages/opencode/src/mcp/index.ts, line 598 - MCP tools retrieval
Impact
I have a number of MCP servers for things like grepai, and query tools for querying/updating non-SQL data stores. This issue makes it nearly impossible for any subagents to do useful work in my environment because they cannot access any of my MCP tools needed to do their work.
Plugins
oh-my-opencode
OpenCode version
1.2.20
Steps to reproduce
Steps to Reproduce
-
Configure an MCP server in opencode.json -
Start OpenCode and verify MCP shows as "connected" via opencode mcp list -
Use parent agent to successfully call an MCP tool -
Spawn a subagent via Task tool with a prompt that requires MCP tool usage -
Observe that subagent reports MCP tools are not available or gets permission denied when attempting to execute
Screenshot and/or share link
Operating System
Ubuntu 22.04
Terminal
Web UI
Activity
github-actions commentedon Mar 7, 2026
This issue might be a duplicate of existing issues. Please check:
fix: resolve 4 bugs — payload bloat, MCP subagents, tool names, token…
btbxbob commentedon Mar 16, 2026
today i met this problem with jenkins mcp. i think the sub-agents doesn't get any mcp at all.
thanhnndev commentedon Mar 19, 2026
Same here. Spawn sub-agent to double check code with
context7. But can'tHyp3rSon1X commentedon Mar 29, 2026
This is still a problem and it seems the Pull Request that tried to solve this issue got closed.
I had to wrap my mcp into an opencode plugin to register it as a native tool to circumvent this problem... but that really shouldn't be needed...
luoshuijs commentedon Apr 9, 2026
I've also noticed that subtasks sometimes fail to invoke MCP under specific circumstances. Currently, it's difficult to consistently reproduce this issue.
ZiyiTsang commentedon Apr 14, 2026
Same here. I call the subagent to use MCP, but clearly observed failing to use (it seems the subagent does not see it at all)
EL4CTEO commentedon Apr 24, 2026
reading comments
fix: inherit MCP tool allow permissions in subagent sessions
fix: inherit MCP tool allow permissions in subagent sessions
duan2026 commentedon Jun 11, 2026
I want to know if this bug has been resolved in the latest version. I have also been troubled by this bug and after ruling it out for two hours, I began to suspect that the subagent was unable to call MCP. After finding this post, I confirmed that this is the case. Also, I found that the sub agent cannot call the plug, right? If there is any progress on this, please let me know. Thank you all. If the sub agent can call MCP, it will be very convenient for development
fix(opencode): inherit MCP tool allow permissions in subagent sessions
entrptaher commentedon Jul 14, 2026
I think in v2 it's possible to fix this.
Three changes decouple MCP tools from the
executemechanic:packages/core/src/mcp/guidance.ts- ` Use tools from this server through \`execute\` under \`tools[${JSON.stringify(McpTool.group(server.server))}]\`.`,packages/core/src/tool/mcp.tspackages/tui/src/context/data.tsxIf you make these changes,
codemode: false) rather than code-mode tools, so they don't requireexecutepermission.executewas denied.executeusage hint is removed from guidance, since the model no longer routes throughexecuteto use MCP tools.refresh()to default the location whenrefis undefined, which was silently breaking MCP list/catalog calls.And then in your config file,
The code hardcodes some restrictions which are responsible for this issue.
However, this is also probably a critical security issue as you can see the closed PRs connected to this issue.
fix(mcp): prevent null parameters in MCP tool calls for OpenAI-compat…
github-actions commentedon Sep 13, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
jeremyakers commentedon Sep 13, 2026
Every freaking issue or PR I open in OpenCode gets closed with this same BS. So obnoxious. Nothing that actually effects real people ever gets fixed.