Repository navigation
refactor(core): contribute MCP tools through a built-in plugin - #47389
Closed
kitlangton wants to merge 1 commit into
Closed
kitlangton wants to merge 1 commit into
kitlangton wants to merge 1 commit into
Conversation
Contributor
|
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. |
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.
MCP-discovered tools currently register from a Location layer outside the built-in plugin lifecycle. Registration also happens after discovery, so a slow server can place its transform after a later plugin's override or removal. This draft moves that contribution into
opencode.tool.mcpand reserves its transform before discovery starts.The plugin captures internal MCP, permission, and bus services through
PluginInternal; it contributes throughctx.tool.transform/reload. Connections and invocation remain inMcp.Service. The plugin owns discovery and subscriptions, retains the stable transform and 100ms debounce, and participates in activation/disposal and grouped transform failures.A small
McpToolreadiness service preserves Session's existing wait before its tool snapshot. Plugin activation stays asynchronous with respect to slow MCP discovery. Removing or replacing an activation cancels its discovery and releases its waiters; disabling the adapter makes readiness a no-op. The public Protocol, Server API, and plugin API are unchanged.This is an exploratory proposal against v2, based on
97303c39dd, rather than the materially different tool architecture on dev. The tradeoff is retaining a small readiness bridge; consumers assemblingMcpTool.nodedirectly must now activate the plugin explicitly.Validation from
packages/core:bun typecheck— passed.bun run test test/mcp.test.ts test/mcp-tool-plugin.test.ts test/plugin.test.ts test/mcp-instructions.test.ts test/location-layer.test.ts— 108 passed, 0 failed.git diff --checkpassed. Integration tests required loopback access outside the filesystem sandbox.The broader audit is recorded in
packages/core/docs/mcp-tool-plugin.md:One limitation deserves follow-up: MCP instructions filter the raw MCP catalog rather than the effective Tool snapshot. Guidance can mention tools removed by plugins, including disabling this adapter. Deriving reachability from the selected snapshot would address both cases. Moving instruction rendering alone would not.
Fully plugin-provided MCP is a separate design question involving discovery, invocation, resources/prompts, cancellation, readiness, and credential ownership. This draft deliberately proposes only the tool contribution boundary. Draft for review; do not merge yet.