anomalyco / anomalyco/opencode
[FEATURE]: Expose request-scoped tool execution to provider plugins
@nexxeln is already working on this.
Since Sep 5, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
I maintain opencode-cursor-provider, an OpenCode 2 provider plugin that uses the Cursor Agent SDK.
Cursor runs its own agent loop. It accepts custom tools as callbacks. To expose OpenCode MCP tools, each callback must ask OpenCode to run the selected tool.
The current OpenCode 2 plugin API exposes tool names and schemas in the model context. It does not expose a supported method to run those tools.
A plugin can inspect executors through ctx.tool.transform(). Calling those executors directly would bypass the normal OpenCode tool lifecycle, including:
- The final tool list for the current model request
- Input validation
- Permission rules and permission hooks
- Tool execution hooks
- Progress events
- Session history
- Cancellation
Copying mcp.servers into Cursor is not a correct alternative. It starts a second MCP connection and does not preserve OpenCode OAuth credentials or permissions.
Requested behavior
Please expose a request-scoped tool runtime to provider plugins.
The runtime needs these operations:
- List the final tools for the current model request.
- Identify the source of each tool, including MCP tools.
- Run a tool by its name, call ID, and input.
- Stop tool execution when the request is canceled.
- Return the normalized tool result.
OpenCode must supply the session, agent, and message information. A provider plugin must not create this information.
Tool execution must use the normal OpenCode pipeline. This keeps permissions, hooks, progress, history, and cancellation intact.
The runtime must become invalid when the model request ends. It must reject tools outside the captured request tool list.
A possible API shape is:
interface ProviderToolRuntime {
readonly tools: readonly ProviderToolDefinition[]
execute(call: {
readonly id: string
readonly name: string
readonly input: unknown
readonly signal?: AbortSignal
}): Promise<ProviderToolResult>
}
The exact API shape is open for discussion.
Use case
The provider converts OpenCode MCP tools into callbacks for the external agent SDK.
When the external agent selects a tool, the callback asks OpenCode to run it. OpenCode keeps ownership of the MCP connection, OAuth state, permissions, and tool history.
This API can also support other providers that run their own agent loops.
Related issues
#20697 asks an external application to run tools and submit results to OpenCode.
This request is different. OpenCode continues to run its registered tools through its normal tool pipeline.
#19702 covers responses to the question tool. It does not provide general tool execution for provider plugins.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.