An MCP server that lets any MCP host — Claude Code, Codex CLI, Cursor, and more — drive OpenCode instances and delegate tasks to AI subagents — asynchronously. Fire parallel tasks, poll for results, and orchestrate models like Opus and Fable without blocking.
claude mcp add opencode -- npx -y mcp-server-opencode
Architecture
Your MCP host delegates tasks through a clean pipeline. Each step is async — no blocking, no timeouts.
Claude Code, Codex CLI, Cursor…
opencode-mcp (this project)
Sessions & async prompts
Isolated AI workers
Async by design:
opencode_start_task
returns immediately with a
task_id. No blocking. No MCP timeouts. Fire multiple tasks in parallel
and poll for results when ready.
Features
Everything you need to delegate, parallelize, and manage AI subagent work from your MCP host.
Fire-and-forget task creation.
start_task
returns instantly with a
task_id — no
blocking, no MCP timeouts.
Launch multiple tasks simultaneously. Each one opens an isolated OpenCode session — no interference between workers.
Every task gets its own OpenCode session. Context stays clean, results stay separate, and failures don't cascade.
Check task progress anytime with
get_task_status. Track
pending,
running,
completed, or
failed
states.
wait_for_task
blocks efficiently until tasks finish. Supports
"all" and
"any" modes
with configurable timeouts.
Start, stop, and manage OpenCode server instances. List available
agents and models. Clean shutdown with
killAllServers()
on exit.
Send follow-up prompts to an existing task's session. Iterative back-and-forth with subagents without starting a new session.
Abort running tasks at any time with
cancel_task.
Clean session cancellation without leaving orphaned processes.
Tools
Every tool is registered as an MCP tool and available to your AI host immediately after setup.
Start (or attach to) an OpenCode server instance.
Stop a running OpenCode server instance.
List agents/models available on a server instance.
Delegate a task to an agent by starting a new session and
prompt. Optional
agent /
model
override.
Send a follow-up prompt to an existing task's session for iterative back-and-forth with the subagent.
Abort a running delegated task by cancelling its session.
Poll the status of a delegated task (pending
/
running /
completed
/
failed).
Optional
include_progress
adds partial output while running.
Fetch the final result of a completed task.
Long-poll one or more delegated tasks until they finish (mode: "all"
or "any")
or the timeout elapses. Optional
include_progress
enriches unfinished tasks with partial output. Server-side max
configurable via
MCP_TOOL_TIMEOUT
(default: 300000 ms / 5 min).
Guides the host through delegating one or more tasks to OpenCode agents — the full start/wait/result workflow in a single prompt.
Get started
Install via npm or build from source. Works with Claude Code, Codex CLI, Cursor, and any MCP host. Requires Node.js 18+ and OpenCode on your PATH.
$ claude mcp add opencode -- npx -y mcp-server-opencode
Or add manually to your MCP config:
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "mcp-server-opencode"]
}
}
}
$ codex mcp add opencode -- npx -y mcp-server-opencode
Or add manually to
~/.codex/config.toml:
[mcp_servers.opencode]
command = "npx"
args = ["-y", "mcp-server-opencode"]
$ git clone https://github.com/alejandro-technology/opencode-mcp.git
$ cd opencode-mcp
$ pnpm install
$ pnpm build
Then point your MCP host at the built entrypoint:
{
"mcpServers": {
"opencode": {
"command": "node",
"args": ["/path/to/opencode-mcp/build/src/index.js"]
}
}
}
MCP_TOOL_TIMEOUT
configures the server-side max for
opencode_wait_for_task. Default:
300000 ms (5 min).
MCP_TOOL_TIMEOUT
in your MCP server config's
env block
(takes precedence)
MCP_TOOL_TIMEOUT=<ms>
as an extra arg to the server process