opencode_execute
Delegate a bounded coding or codebase-analysis task to a local OpenCode 2 executor with an explicit provider/model, returning text, session ID, exit status, and Git context. Runs read-only by default.
Instructions
Run a bounded task in a new session with local OpenCode 2. An explicit provider/model is REQUIRED for every task; never infer a model or rely on CLI defaults. Defaults to isolated read-only project analysis. Returns the requested model (not independently verified), text, session ID, exit status and Git context; reports model failures as errors.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"task": "<task>",
"cwd": "<cwd>",
"model": "<model>"
},
"name": "opencode_execute"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | Yes | Existing absolute project directory. | |
| task | Yes | Task, scope and expected output. Start with ordinary text, not a CLI option. | |
| agent | No | Optional OpenCode agent in write mode. Read-only mode always uses an isolated reader agent. | |
| model | Yes | REQUIRED for each delegation: configured provider/model, optionally #variant. Use an explicitly authorized ID; ask or call opencode_models if unspecified. No automatic model selection or fallback. | |
| readOnly | No | Allow file reading/search only. Denies edit, shell, external directories and network tools. | |
| sessionId | No | Unsupported: omit this field. Old sessions can override the selected project and current permissions. | |
| timeoutMs | No | OpenCode process timeout, independent of the MCP request timeout. | |
| standalone | No | Start a private OpenCode server. Required in read-only mode. | |
| autoApprove | No | Approve tools that are not explicitly denied. Enable only for tasks whose tool actions are authorized. | |
| continueSession | No | Must remain false. This bridge creates a new session for each task. |