opencode-mcp
The opencode-mcp server acts as an MCP intermediary, enabling orchestrator models (Claude Code, Codex, Cursor, etc.) to programmatically drive OpenCode instances and delegate tasks to AI subagents asynchronously.
Server Management
Start a headless OpenCode server instance, optionally specifying a port (default 4096)
Stop a running OpenCode server instance
Agent Discovery
List available agents, models, and providers on a running server instance
Task Delegation (Async Workflow)
Start a task — Delegate a prompt to an OpenCode agent, optionally specifying an agent name or model (
providerID/modelID); returns immediately with atask_idwithout blockingCheck task status — Poll the current status (
pending/running/completed/failed) of a task, including partial outputFetch task result — Retrieve the final output of a completed task
Send follow-up prompts — Interact iteratively with an existing task's session
Cancel a task — Cancel a running delegated task
Wait for task(s) — Long-poll one or more tasks until completion or timeout, with
mode: "all"(wait for every task) ormode: "any"(return on first completion), and configurabletimeout_msandpoll_interval_ms
Tasks run asynchronously in parallel across isolated OpenCode sessions, and a built-in delegate_task prompt guides the host through the full start → wait → result workflow.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@opencode-mcpDelegate a task to OpenCode agent to optimize database queries"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
opencode-mcp
An MCP (Model Context Protocol) server that lets any MCP host — Claude Code, Codex, Cursor, etc. — drive an OpenCode instance and delegate work to its subagents — so orchestrator models like Opus or Fable can hand off tasks to the other models OpenCode exposes.
Quick install
Requires Node.js 18+ and OpenCode installed and configured (opencode must be on your PATH, with at least one provider/model set up) — this server spawns and drives OpenCode instances.
For Claude Code:
claude mcp add opencode -- npx -y mcp-server-opencodeFor Codex:
codex mcp add opencode -- npx -y mcp-server-opencodeSee Installation for manual config, and from-source options.
Related MCP server: gpt-subagents-api
Tools
Tool | Description |
| 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 |
| 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 ( |
| Fetch the final result of a completed task |
| Long-poll one or more delegated tasks until they finish ( |
Prompt | Description |
| Guides the host through delegating one or more tasks to OpenCode agents (start/wait/result workflow), including a model selection guide that maps each OpenCode model tier to the task difficulty it should handle |
How it works
Task delegation is asynchronous: starting a task returns immediately with a task_id instead of blocking until the subagent finishes. This lets Claude Code fire multiple opencode_start_task calls in parallel — each one opens an isolated OpenCode Session — without hitting MCP client timeouts on long-running work. Status and results are fetched separately via polling.
Installation
Prerequisites
Node.js 18+
OpenCode installed and configured (
opencodemust be on yourPATH, with at least one provider/model set up) — this server spawns and drives OpenCode instances.
Option 1 — npm (recommended)
The package is published as mcp-server-opencode. No cloning or building needed — point your MCP host at npx:
For Claude Code, one command does it:
claude mcp add opencode -- npx -y mcp-server-opencodeOr manually
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "mcp-server-opencode"]
}
}
}For Codex, add the server to ~/.codex/config.toml:
[mcp_servers.opencode]
command = "npx"
args = ["-y", "mcp-server-opencode"]Or install it globally and use the binary directly:
npm install -g mcp-server-opencode{
"mcpServers": {
"opencode": {
"command": "opencode-mcp"
}
}
}Option 2 — from source
git clone https://github.com/alejandro-technology/opencode-mcp.git
cd opencode-mcp
pnpm install
pnpm buildThen point your MCP host at the built entrypoint:
{
"mcpServers": {
"opencode": {
"command": "node",
"args": ["/path/to/opencode-mcp/build/src/index.js"]
}
}
}Restart your MCP host after editing the config; the opencode_* tools should appear in its tool list.
Configuration
MCP_TOOL_TIMEOUT
opencode_wait_for_task accepts a timeout_ms input, but it's clamped to a server-side maximum so a single call can't block the MCP connection indefinitely. That maximum defaults to 300000 ms (5 minutes) and is configurable via MCP_TOOL_TIMEOUT.
MCP_TOOL_TIMEOUT can be set two ways:
Environment variable — set it in the MCP server config:
{ "mcpServers": { "opencode": { "command": "node", "args": ["/path/to/opencode-mcp/build/src/index.js"], "env": { "MCP_TOOL_TIMEOUT": "1200000" } } } }CLI argument — pass
MCP_TOOL_TIMEOUT=<ms>as an extra arg to the server process:{ "mcpServers": { "opencode": { "command": "node", "args": [ "/path/to/opencode-mcp/build/src/index.js", "MCP_TOOL_TIMEOUT=1200000" ] } } }
If both are present, the environment variable takes precedence over the CLI argument. Invalid or non-numeric values fall back to the 300000 ms default.
Development
Project structure
src/
├── index.ts # MCP server entrypoint (stdio transport, shutdown handlers)
└── modules/
├── tools/ # One file per MCP tool, registered in index.ts
├── prompts/ # One file per MCP prompt, registered in index.ts
└── shared/ # Cross-tool infrastructure
├── server-registry.ts # Tracks running OpenCode servers; killAllServers() on shutdown
├── task-registry.ts # Maps task_id → OpenCode server + session
├── opencode-client.ts # Builds SDK clients from the registries
├── config.ts # MCP_TOOL_TIMEOUT resolution (env var / CLI arg)
└── mcp-result.ts # jsonResult / jsonError MCP output helpersEach module ships with a *.test.ts Vitest suite under the parallel tests/ tree mirroring src/.
Getting started
pnpm install
pnpm dev # runs the server through the MCP Inspector (tsx, no build needed)Other scripts:
pnpm test # vitest run
pnpm test:coverage # vitest run --coverage
pnpm lint # biome check
pnpm lint:write # biome check --write
pnpm build # clean tsc build to ./build (also the typecheck)Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityBmaintenanceEnables Codex to delegate tasks to Claude Code, allowing Claude to investigate, edit, and verify changes in the repository with background job management.Last updated6MIT
- AlicenseAqualityBmaintenanceLets Claude Code delegate to OpenAI expert models as subagents and provides orchestration patterns for parallel, context-cheap, and verified use.Last updated3MIT
- Alicense-qualityBmaintenanceEnables Codex to offload expensive code reading, editing, and checking to a worker agent via Claude Code, supporting async jobs and long-running tasks.Last updatedMIT
- FlicenseAqualityAmaintenanceEnables Claude Code to dispatch opencode CLI tasks as background processes with immediate task handle return, status polling, and result retrieval, avoiding tmux and log parsing issues.Last updated6
Related MCP Connectors
Reliable async execution for agent tool calls: schema gating, retries, idempotency, audit trail.
Coding agents from Claude Code, Cursor and Codex claim jobs and lock files on one shared board.
Cross-agent artifact workspace with provenance across Claude Code, Codex, Cursor, LangGraph.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/alejandro-technology/opencode-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server