You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: let plugins call tools and read resources on the engine's MCP connections #53514
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Let a server plugin call a tool and read a resource through the MCP connections the engine already holds.
We build a client on opencode serve with server plugins. Some features need data from an MCP server the user has already connected and signed in to. Two examples: a view that lists the user's tasks from a tasks MCP server, and an MCP App, whose ui:// resource the host must read to show it beside the tool result.
A plugin cannot do this today (checked on v2.0.24):
ctx.mcp offers only list, transform and reload (packages/plugin/src/effect/mcp.ts).
Core already has callTool and readResource on the MCP service (packages/core/src/mcp/index.ts). Neither plugins nor the HTTP API can reach them.
So a plugin must open its own MCP client. For a server with OAuth, that second client needs its own registration and sign-in, separate from the one the user just completed. We prototyped a second client in a plugin. It worked for a server without auth and stopped at the first OAuth server.
Possible approach:
ctx.mcp.callTool({ server, name, args })// the engine's connection and credentialsctx.mcp.readResource({ server, uri })
These calls could go through the same permission check as a model tool call. MCP Apps hosts also need a tool's _meta.ui.resourceUri, which the registry drops today (packages/core/src/tool/mcp.ts). A way to read a tool's _meta would cover that.
Related, not duplicates:#10884 (MCP Apps in the desktop app) needs the same resource read. #28225 (an mcp.call.before hook) is about request headers.
+1, with a second use case and a tested patch for the HTTP side.
We run recorded procedures (programs that repeat a task with new inputs) through the MCP connections a person already has in their agent, without a model turn per step. In OpenCode that needs exactly this: one tool call on a connected server, with the engine's own connection and credentials.
For dev (1.18.35) I have a small, tested patch that exposes it over the server API, using the same path and payload Kilo already ships for MCP Apps, so one client works on both:
POST /experimental/mcp/call-tool{server, name, arguments?} calls mcp.clients()[server].callTool(...) and returns {content, isError?, structuredContent?}; a server that is not connected is a 404 (McpServerNotFoundError).
Tests: a stdio fixture server; success, an isError result passed through, and the missing-server 404 (bun test test/server/httpapi-mcp*.test.ts: 7 pass); bun run typecheck clean; JS SDK regenerated.
A plugin-level ctx.mcp.callTool going through the same permission check as a model tool call, as proposed above, would cover our case even better. Happy to open the PR for the route, or adapt it to whichever shape you prefer.
Raw tool definitions and negotiated server capabilities, including _meta, resource associations and change notifications, separate from the model-facing list.
Resource reads on that connection preserving the full result, HTML, MIME type, metadata and CSP.
Authorized app-initiated calls on the existing connection, using its permission policy and app, server and conversation binding, without another sign-in.
Opt-in delivery of complete original input and result before conversion, correlated to the invocation, preserving errors, content, structuredContent and _meta, without replay or UI-only metadata entering model text.
MCP Apps visibility: default model and app visibility, app-only tools excluded from the model list, and ordinary app calls requiring app visibility on the same server connection.
Activity
github-actions commentedon Oct 6, 2026
This issue might be a duplicate of an existing issue. Please check:
luismalcaraz commentedon Oct 9, 2026
+1, with a second use case and a tested patch for the HTTP side.
We run recorded procedures (programs that repeat a task with new inputs) through the MCP connections a person already has in their agent, without a model turn per step. In OpenCode that needs exactly this: one tool call on a connected server, with the engine's own connection and credentials.
For
dev(1.18.35) I have a small, tested patch that exposes it over the server API, using the same path and payload Kilo already ships for MCP Apps, so one client works on both:POST /experimental/mcp/call-tool{server, name, arguments?}callsmcp.clients()[server].callTool(...)and returns{content, isError?, structuredContent?}; a server that is not connected is a 404 (McpServerNotFoundError).isErrorresult passed through, and the missing-server 404 (bun test test/server/httpapi-mcp*.test.ts: 7 pass);bun run typecheckclean; JS SDK regenerated.A plugin-level
ctx.mcp.callToolgoing through the same permission check as a model tool call, as proposed above, would cover our case even better. Happy to open the PR for the route, or adapt it to whichever shape you prefer.Skeptomenos commentedon Oct 17, 2026
A host needs UI resources and original tool data through the engine's existing authorized MCP connection.
In v2.0.32, the public MCP domain exposes only
list,transformandreload, while result conversion drops metadata.Could the native contract provide:
_meta, resource associations and change notifications, separate from the model-facing list.content,structuredContentand_meta, without replay or UI-only metadata entering model text.