fix(opencode): exclude denied MCP tools from provider requests - #38060
Closed
IbrahimKhan12 wants to merge 1 commit into
Closed
fix(opencode): exclude denied MCP tools from provider requests#38060IbrahimKhan12 wants to merge 1 commit into
IbrahimKhan12 wants to merge 1 commit into
Conversation
The global `tools` config (e.g. `{ "mymcp_*": false }`, documented as
equivalent to `{ "*": "deny" }`) is meant to disable all of an MCP
server's tools, but SessionTools.resolve advertised every `mcp.tools()`
entry to the provider regardless of permission. A wholly-denied MCP tool
whose schema the provider rejects then fails the whole session with a 400.
Apply the existing `Permission.visibleTools` filter to `mcp.tools()` in the
normal path, matching the experimental code-mode path which already does
this. Only wholly-denied tools (resource pattern `*`) are hidden; `ask`
and resource-scoped rules leave the tool advertised.
Fixes anomalyco#37675
IbrahimKhan12
force-pushed
the
mcp-tools-visibility
branch
from
July 21, 2026 19:01
cfb8217 to
c9f90c5
Compare
IbrahimKhan12
marked this pull request as ready for review
July 21, 2026 19:01
Author
|
Fixed by #6319, with the current provider-bound filtering path retained by #28560: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #37675
Type of change
What does this PR do?
The global
toolskey is documented so that{ "mymcp_*": false }(equivalent to{ "*": "deny" }) disables all of an MCP server's tools. ButSessionTools.resolveadded everymcp.tools()entry to the tool list sent to the provider regardless of permission. So a wholly-denied MCP tool was still advertised, and when its schema is one the provider rejects (the Moonshot 400 in the report) the whole session fails.Permission.visibleToolsalready drops wholly-denied tools, and the experimental code-mode path already applies it tomcp.tools(). This applies the same filter in the normal path. Only tools denied with resource pattern*are hidden;askand resource-scoped rules leave the tool advertised, so nothing else changes.How did you verify your code works?
Added
packages/opencode/test/session/tools.test.ts, which drivesSessionTools.resolvewith mocked MCP tools and a permission ruleset:"postman*"deny rule excludespostman_searchbut keepsgithub_listpattern != "*") keeps the toolThe deny-glob test fails before the change and passes after. Also ran
bun typecheckand the related suites (test/session/prompt.test.ts,test/permission/next.test.ts,test/tool/code-mode.test.ts,test/tool/registry.test.ts,test/mcp/), all passing.Screenshots / recordings
N/A, not a UI change.
Checklist