Skip to main content
Glama
sebstaq

opencode-subagent-mcp

by sebstaq

opencode-subagent-mcp

Run Claude Code subagents on cheaper opencode models — for example opencode-go/deepseek-v4.1-flash (DeepSeek) from an opencode Go subscription — while Claude Code itself keeps talking to Anthropic directly. Delegate searches, refactors, bug fixes, tests and research to a model that costs a fraction of Opus or Sonnet, and keep the tools you already use: background agents, resume via send_message, worktree isolation, .claude/agents definitions, permission prompts and structured output.

It is a stdio MCP server. Your main Claude Code session is not proxied or routed anywhere; the server only runs the subagents you delegate to it, on a private opencode serve instance it starts itself.

Install

Requires Node 22+, git, and the opencode CLI logged in to the providers you want (opencode auth login).

As a Claude Code plugin (also adds a skill that tells Claude when to delegate to opencode):

claude plugin marketplace add sebstaq/opencode-subagent-mcp
claude plugin install opencode-subagent-mcp@sebstaq-opencode

Or as a plain MCP server:

claude mcp add -s user opencode -- npx -y opencode-subagent-mcp@0.1.3

Related MCP server: opencode MCP server

What it runs and sends

  • It starts a private opencode serve process on a random localhost port with a random password, and stops it when Claude Code exits. The password is generated for each run and only used between this server and that local process. The process inherits your environment so opencode can use the provider logins and API keys you already configured for it; this server never reads, stores or sends those credentials itself.

  • The prompts you delegate, and the files and command output the subagent reads, go to the model provider you choose through opencode (by default opencode Go), under that provider's data retention terms. opencode keeps session history in its local database on your machine. Nothing else is sent anywhere; the server has no telemetry and makes no other network calls.

  • It reads ~/.claude/settings.json, the project's .claude/settings.json and .claude/settings.local.json, and .claude/agents/*.md (user and project) to mirror your permission rules and agent definitions, and ~/.config/opencode-subagent-mcp/config.json if present.

  • With isolation: "worktree" it creates git worktrees under the project's .claude/worktrees/ and removes them when they have no changes.

This is an independent project, not affiliated with Anthropic or the opencode team.

Tools

Tool

Native equivalent

What it does

agent

Agent tool

Run a subagent; returns its final report, usage and worktree outcome

send_message

SendMessage

Continue a finished agent with its full history; also after a restart

wait

background completion notification

Collect a run_in_background agent (optionally with a timeout)

stop

TaskStop

Abort a running agent and return what it produced

list

/agents

This session's agents, Claude agent definitions and opencode agents

An agent_id keeps working after the MCP server or Claude Code restarts: wait and stop return what happened to it, and send_message continues it. Agents from before a restart do not appear in list until their id is used again, but they still exist in opencode's local session store.

agent parameters: description, prompt, subagent_type, model, isolation: "worktree", permission_mode, tools, disallowed_tools, max_turns, effort, output_schema, run_in_background, cwd.

Parity with native subagents

Native behaviour

Here

Fresh context, only the final message comes back

Same. Long output is truncated (maxResultChars) with the full text written to a file

Runs in the project directory

Same (cwd from MCP roots, then CLAUDE_PROJECT_DIR, then the server's cwd)

isolation: worktree

Same layout (.claude/worktrees/<name>, branch worktree-<name>, based on the default branch). Removed when unchanged, kept with commit/file summary otherwise. Outside paths are denied

Permission prompts surface in the main session

opencode ask rules are shown as MCP elicitation dialogs (allow once / always / deny, with optional feedback)

Permission modes

default, acceptEdits, auto, bypassPermissions, plan mapped to opencode rules; your Claude permissions.allow/ask/deny from user, project and local settings apply

Background agents with completion notification

Claude Code moves long MCP calls to the background automatically and notifies when they finish; run_in_background + wait for explicit control

Resume with full history

send_message (also works for agents from earlier sessions or after a restart, since opencode persists them)

.claude/agents/*.md definitions

Used via subagent_type: prompt, tools, disallowedTools, permissionMode, maxTurns, effort, isolation. model applies only when it is an opencode provider/model

maxTurns returns partial output

Same; status max_turns, resumable

Progress in the UI

Tool calls are sent as MCP progress notifications

Subagents cannot spawn subagents or ask the user questions

opencode's task and question tools are disabled

Structured output

output_schema (JSON Schema) → opencode structured output, returned as structuredContent

Known gaps: agents do not appear in Claude Code's /tasks agent view; there is no fork-with-parent-context; the Workflow tool's agent() cannot target them; auto mode has no safety classifier (it allows everything, including paths outside the project, except rules you configured and a fixed list of destructive commands that ask: rm -r/-rf, git push --force, git reset --hard, git clean -f, git restore/git checkout --, curl | sh, sudo, chmod -R/chown -R, dd, mkfs, npm/pnpm publish; opencode matches each command in a chain separately); the parent's permission mode is not visible to MCP servers, so the default comes from config; hooks, skills preloading, memory and per-agent MCP servers are not mapped.

Steering Claude

Claude Code picks between its native Agent tool and this one on its own, so routing is unpredictable. To make opencode the default for delegated work that is cheap to verify, paste the snippet from docs/claude-md-snippet.md into your global ~/.claude/CLAUDE.md.

Configuration

Optional ~/.config/opencode-subagent-mcp/config.json (or $OPENCODE_SUBAGENT_CONFIG):

{
  "defaultModel": "opencode-go/deepseek-v4.1-flash",
  "defaultPermissionMode": "auto",
  "pure": true,
  "opencodeBin": "opencode",
  "maxConcurrent": 8,
  "maxResultChars": 80000
}

OPENCODE_SUBAGENT_MODEL and OPENCODE_SUBAGENT_MODE override the first two. pure starts opencode without external plugins.

How it works

On first use the server starts opencode serve on a random loopback port with a random password, subscribes to its event stream, and drives one opencode session per agent (agent id = session id). Permission requests from opencode are answered through MCP elicitation. The opencode process is stopped with the MCP server; leftovers from crashed servers are reaped on the next start.

Development

pnpm check   # typecheck, lint, format check, unit tests
pnpm smoke [provider/model]   # end-to-end run against a real model in a temp repo

License

MIT

Available Tools

5 tools
agentopencode subagentA

Launch a subagent that runs on an opencode model (default opencode-go/deepseek-v4.1-flash) in the current project. Mirrors the built-in Agent tool: give a self-contained task prompt; the agent starts with no conversation context and returns only its final report. subagent_type accepts Claude agent definitions from .claude/agents/ (their prompt, tools, permissionMode and maxTurns apply) or opencode agents (general, explore, plan, build). isolation 'worktree' runs it in a temporary git worktree off the default branch, removed if unchanged. The call blocks until the agent finishes (it is backgrounded automatically after a while); set run_in_background to return at once and collect the result with wait.

ParametersJSON Schema
NameRequiredDescriptionDefault
cwdNoWorking directory (default: the project directory)
modelNoopencode model as provider/model (default: opencode-go/deepseek-v4.1-flash)
toolsNoAllowlist of tools (Claude or opencode names)
effortNoModel variant/reasoning effort, e.g. low, high, max
promptYesThe task for the agent to perform
isolationNo
max_turnsNo
descriptionYesShort (3-5 word) description of the task
output_schemaNoJSON Schema the final answer must satisfy; returned as structured output
subagent_typeNoClaude agent definition name or opencode agent name (default: general)
permission_modeNoPermission mode (default: auto)
disallowed_toolsNo
run_in_backgroundNo

TDQS

A4.4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations present, the description carries the full burden, and it delivers substantial disclosure: blocking behavior ('The call blocks until the agent finishes'), automatic backgrounding, the run_in_background escape hatch, worktree isolation semantics including cleanup ('removed if unchanged'), and the no-conversation-context behavior. These are exactly the non-obvious behavioral traits an agent needs and are not derivable from the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Every sentence earns its place and the content is dense with no filler, but it is a single run-on paragraph that is hard to scan. The size is arguably justified by the tool's complexity, yet the lack of structure (no bullets, no separation of behavior vs parameters) makes it harder to parse than it should be.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 13-parameter tool with no annotations and no output schema, the description covers the most critical non-obvious behaviors (blocking, backgrounding, isolation cleanup, subagent resolution, context isolation). It could add a bit on permission_mode behavior or how the final result is returned, but given the complexity, the coverage is close to complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

At 69% schema coverage, the description meaningfully compensates for the schema on the hardest parameters: it explains what subagent_type accepts (Claude .claude/agents/ definitions vs opencode agents, with their prompt/tools/permissionMode/maxTurns applying), what isolation 'worktree' induces, and the run_in_background blocking trade-off. Some params (output_schema, max_turns, effort, tools) are left to the schema, but the description targets the most complex ones.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource ('Launch a subagent that runs on an opencode model'), states the scope ('in the current project') and immediately distinguishes itself from siblings by invoking the built-in Agent tool it mirrors. The sibling set (send_message, wait, stop, list) is clearly different, so there is little chance of confusing this tool with an alternative.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides clear contextual guidance: instructs to 'give a self-contained task prompt' and explains that the agent 'starts with no conversation context and returns only its final report', which tells an agent when this tool is appropriate (standalone tasks) and what to expect. It references the built-in Agent tool as a mirror but stops short of explicit when-not-to-use or exclusion statements, which would push it to a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

listList opencode subagentsA
Read-only

List this session's opencode subagents and the available agent types. It shows agents started or used since this MCP server started; agents from before a restart are not listed but their agent_id still works with wait, send_message and stop.

ParametersJSON Schema
NameRequiredDescriptionDefault
cwdNo

TDQS

A3.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnlyHint=true; the description adds substantive behavioral context beyond that — the listing is scoped to the current server lifetime, and IDs survive restarts even when entries vanish. This restriction is exactly the kind of trait annotations cannot express.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with what is returned and then the important persistence caveat. No filler, though the second sentence is slightly dense.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description describes the payload only loosely ('shows agents started or used'). Combined with an unexplained cwd parameter, a caller still lacks the details needed to interpret the result or pass the optional argument correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There is one parameter (cwd) with 0% schema description coverage, and the description never mentions it, so an agent cannot tell what cwd does or whether it is required. The description leaves the schema's gap unfilled.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb+resource ('List this session's opencode subagents and the available agent types'), which rescues the generic name 'list' and makes the tool's intent unambiguous. It does not explicitly distinguish itself from a sibling list-type tool, but it clarifies its relationship to wait/send_message/stop.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives clear context for when to use it (discovering started/used agents and available agent types) and a useful exclusion: agents from before a restart are not listed, but their agent_id still works with wait, send_message and stop. It stops short of naming an alternative tool for finding pre-restart agents.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

send_messageContinue an opencode subagentA

Send a follow-up message to a finished opencode subagent by agent_id. It resumes with its full previous history (and its worktree, if one was kept) and returns its new final report. Also works for agent_ids from before a restart of the MCP server or Claude Code session, and for agents that were interrupted by such a restart.

ParametersJSON Schema
NameRequiredDescriptionDefault
messageYes
agent_idYes
max_turnsNo
run_in_backgroundNo

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does disclose meaningful behavior: the subagent resumes with its full prior history, its worktree is preserved if one was kept, and the call returns a new final report. It also discloses cross-restart persistence, a real operational trait. It omits what max_turns does by default or that run_in_background makes the call async.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, zero filler, with the core verb and the agent_id anchor front-loaded. The trailing restart sentence is a worthwhile edge case rather than padding, though it could be tightened.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a stateful, mutating tool with no annotations and no output schema, the description does tell the agent what comes back ("its new final report") and how state is restored. What's missing is the behavior of the two optional control parameters (max_turns, run_in_background), which materially change how the call behaves.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% across 4 parameters, so the description must compensate. It clarifies `agent_id` semantics (finished agents, agents from before a restart) but says nothing about `max_turns` or `run_in_background`, leaving half the parameters entirely unexplained anywhere.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("Send a follow-up message to a finished opencode subagent by agent_id") and immediately distinguishes itself from siblings like `agent` (which starts a new one) and `stop`/`wait`. An agent can tell exactly what this does without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description scopes usage clearly (a *finished* subagent) and adds a valuable edge case: agent_ids that predate an MCP/Claude Code restart or that were interrupted by one. However, it never explicitly names alternatives or states when *not* to use it (e.g., use `agent` for a fresh subagent, `stop` to cancel).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

stopStop an opencode subagentB

Abort a running opencode subagent. Returns what it produced so far. agent_ids from before a restart of the MCP server still work.

ParametersJSON Schema
NameRequiredDescriptionDefault
agent_idYes

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description carries the behavioral burden and does add real value: it says the call returns partial output produced so far and that IDs survive an MCP server restart. It does not state whether the abort is irreversible, whether it errors on finished agents, or any permission requirements, leaving gaps for a mutation-style tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences, front-loaded with the action, then the return behavior, then the edge-case note. Nothing is padded; it is appropriately sized for a one-parameter tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no annotations and no output schema, the description covers the core action, the partial-result return, and the restart edge case. It still omits idempotency, failure modes when the agent is already stopped, and error semantics — meaningful gaps for a termination operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% and agent_id is undocumented in the schema, but the description adds genuine meaning about it — that IDs minted before a server restart remain valid. That is one useful semantic detail, though it does not fully document format or validity expectations for the single parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (abort) and resource (running opencode subagent), and clarifies it stops an in-flight subagent rather than waiting on or messaging one. It stops short of explicitly naming which sibling to use instead, so it is clear but not sibling-routing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'running opencode subagent' implies the condition for use, but no alternative is named (e.g., when to use stop vs wait), and there is no guidance on what to do if the agent is not running or has already finished.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

waitWait for an opencode subagentA

Wait for a background opencode subagent and return its result. agent_ids from before a restart of the MCP server still work.

ParametersJSON Schema
NameRequiredDescriptionDefault
agent_idYes
timeout_secondsNoReturn early if still running

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It usefully discloses a non-obvious behavioral trait — agent_ids survive an MCP server restart — but omits blocking/polling semantics, what happens when the agent never finishes or the id is invalid, and whether early timeout returns partial state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tightly-written sentences with zero padding; the core purpose is front-loaded and the restart caveat is a single qualifying clause rather than a paragraph. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple wait tool with no output schema and only two parameters, the definition covers the essential purpose and one non-obvious behavior. The remaining gap — error/failure and timeout-result semantics — is meaningful but small given the schema already explains early return.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With two parameters and 50% schema coverage, timeout_seconds is already documented in the schema as an early-return mechanism. The description references agent_ids but adds no format, provenance, or semantics for agent_id beyond what the parameter name implies, so it neither compensates nor regresses.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb+resource ('Wait for a background opencode subagent and return its result'), which an agent can immediately distinguish from siblings like send_message, stop, list, and agent. The scope is unambiguous and the outcome (returns the result) is stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied: 'background' subagent suggests it is used when polling an asynchronously-started agent, but no explicit when-to-use, when-not-to-use, or alternative (e.g., vs. list or agent) is named. No exclusions or prerequisites are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv0.1.1
    • First observedagent
    • First observedlist
    • First observedsend_message
    • First observedstop
    • First observedwait

TDQS

A3.8/5.0

Scored across 5 tools

Disambiguation5/5

Each tool maps to a distinct lifecycle action: launch (agent), follow-up (send_message), await result (wait), abort (stop), enumerate (list). The overlap between wait (awaits a background agent) and send_message (resumes a finished agent and returns its report) is clearly disambiguated by their descriptions.

Naming Consistency3/5

Names mix conventions: send_message is verb_noun, while wait, stop, and list are bare verbs and 'agent' is a bare noun. All are readable, but there is no single predictable pattern across the set.

Tool Count5/5

Five tools cleanly cover the subagent lifecycle (launch, message, wait, stop, list) with no redundancy. This is well-scoped for the server's stated purpose.

Completeness4/5

The surface covers launch, resume, wait, stop, and list, which spans the full lifecycle. Minor gaps exist (e.g. no dedicated status/inspect or explicit cleanup of retained worktrees), but agents can work around them via list and send_message.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers