Skip to main content
Glama
opencode-delegate-mcp

opencode-delegate-mcp

by mryesiller

opencode-delegate-mcp

Let your primary coding agent (Claude Code, Codex) delegate the grunt work to a cheaper model via OpenCode.

Keep architecture, critical logic, and hard decisions on your expensive frontier model — and hand off the high-volume, low-risk work (boilerplate, repetitive edits, tests, lint/type fixes, mechanical refactors) to a cheap model like MiniMax running through OpenCode. It's an agent talking to another agent: your main agent uses a second agent as a subagent, with the model/provider configurable at runtime.

┌────────────────────┐   MCP (stdio)   ┌───────────────────────┐   opencode run   ┌──────────────────┐
│  Claude Code /      │ ──────────────► │  opencode-delegate-mcp │ ───────────────► │  OpenCode +      │
│  Codex (primary)    │   delegate_task │  (this server)         │  --model cheap   │  cheap model     │
└────────────────────┘ ◄────────────── └───────────────────────┘ ◄─────────────── └──────────────────┘
        result: text + session + token usage + actions taken

Why this exists

The problem: frontier models (Claude, GPT-class) are your best tool for architecture, hard bugs, and judgment calls — and expensive overkill for the mechanical majority of real coding work: boilerplate, tests, lint/type fixes, repetitive multi-file edits. Doing all of it with your primary agent burns premium tokens and fills its context with busywork instead of the decisions that actually need it.

What this tool does: it gives your primary agent a tool to hand that busywork to a cheaper model — or a free one — running through OpenCode, without leaving your workflow. The primary agent stays focused on what matters; the cheap model grinds through the repetitive stuff and reports back. Which model does the work is a config change, not a redeploy — switch it any time.

Related MCP server: opencode-bridge

Install

The easiest path is the web configurator, which builds a one-line install command for you:

👉 https://mryesiller.github.io/opencode-delegate-mcp/

Or install directly from the terminal — one command, one paste, done:

curl -fsSL https://mryesiller.github.io/opencode-delegate-mcp/install.sh | bash -s -- --model "minimax-coding-plan/MiniMax-M2.5-highspeed" --targets "claude,codex"

Prefer to inspect the script before running it? Download first, then run it locally:

curl -fsSL https://mryesiller.github.io/opencode-delegate-mcp/install.sh -o install.sh
less install.sh   # read it
bash install.sh --model "minimax-coding-plan/MiniMax-M2.5-highspeed" --targets "claude,codex"

The installer will:

  1. Clone + build the server into ~/.local/share/opencode-delegate-mcp.

  2. Write config to ~/.config/opencode-delegate/config.json.

  3. Register the server with the hosts you chose (claude / codex / opencode).

Then restart your agent (or reload its MCP servers).

Let your AI install it for you

You don't have to run this yourself — paste the block below into Claude Code, Codex, or any coding agent with shell access. It'll run the command, read the output, and fix common problems (missing prerequisite, unauthenticated provider) itself instead of just reporting them.

Install and register the opencode-delegate-mcp MCP server for me. Use opencode/deepseek-v4-flash-free (free, no signup) as the default model unless I say otherwise, register it with whichever of Claude Code / Codex you find on my machine, and use "user" scope (available in all my projects) unless I ask for "project" or "local" scope instead.

Run:

curl -fsSL https://mryesiller.github.io/opencode-delegate-mcp/install.sh | bash -s -- --model "opencode/deepseek-v4-flash-free" --targets "claude,codex"

Then show me the output, flag any warnings (missing OpenCode, unauthenticated provider, PATH issues), and confirm it's registered by running claude mcp list and/or codex mcp list. If something fails, diagnose and fix it rather than just reporting it.

The web configurator generates this same prompt for you, kept in sync with whatever model/targets/scope you pick in the form — see the "Prefer to have your AI do it?" card.

Scope: global, project, or local

By default the installer registers the server globally (user scope) — available in every project on this machine. Pass --scope to change that, and --project-dir to pick which project (defaults to the directory you run the installer from):

curl -fsSL https://mryesiller.github.io/opencode-delegate-mcp/install.sh | bash -s -- --model "…" --scope project --project-dir "$(pwd)"

--scope

Claude Code

Codex

OpenCode

user (default)

~/.claude.json — all your projects

~/.codex/config.toml — all your projects

~/.config/opencode/opencode.json — all your projects

project

.mcp.json in the project — commit it to share with your team, but needs one-time approval

.codex/config.toml in the project — only loads for trusted projects

opencode.json in the project

local

Private to you, this project only (Claude Code's native local scope)

falls back to project (Codex has no separate local tier)

falls back to project (OpenCode has no separate local tier)

Both hosts gate project-scoped config behind a one-time human approval — this isn't optional and an unattended script can't do it for you: Claude Code shows it as "⏸ Pending approval" in claude mcp list until you run claude interactively in that directory and approve it; Codex only loads a project's .codex/config.toml once you've approved that project as trusted, the first time you run codex there. Re-running the installer with a different --scope cleanly moves the registration (Claude Code: removed from every scope before re-adding at the new one; Codex/OpenCode: the old file entry is left as-is, so remove it by hand if you're switching away from project).

Requirements

  • Node.js ≥ 18, npm, git, and curl.

  • OpenCode — the installer sets this up for you automatically if it's missing (see below), no separate step needed.

  • A provider authenticated (opencode auth login) — unless you use one of OpenCode's free opencode/* models below, which need no signup or API key at all.

If OpenCode isn't installed yet

The installer detects this and runs OpenCode's official installer for you — no separate step needed. One thing to know: OpenCode's installer adds ~/.opencode/bin to your shell's PATH by editing your rc file, but that only takes effect in new terminal sessions. So right after a fresh install, the opencode command may still say "not found" in your current terminal — that's expected. The delegate MCP itself isn't affected (it's configured with the full path), but to use the opencode command yourself, either open a new terminal tab or run source ~/.zshrc (or your shell's rc file — the installer tells you exactly which one).

Prefer to control this yourself? Pass --no-install-opencode to skip auto-install, or install OpenCode manually first from opencode.ai.

Try it for free — zero signup

OpenCode ships a handful of free, no-auth-required models under the opencode/ provider. Use one to try delegation immediately, with nothing to configure:

curl -fsSL https://mryesiller.github.io/opencode-delegate-mcp/install.sh | bash -s -- --model "opencode/deepseek-v4-flash-free" --targets "claude,codex"

Other free options: opencode/north-mini-code-free, opencode/mimo-v2.5-free. They're on a shared free tier, so expect lower rate limits than a paid provider — switch any time with config set (see Dynamic model / provider switching below) once you've got a key.

Tools

Tool

Purpose

delegate_task

Hand a self-contained coding task to the cheap model. It can read/write/edit files and run commands in a target directory. Returns the result text, session id, token usage, and the actions it took.

delegate_tests

Test-focused wrapper: write (and optionally run) tests for a given scope without touching production code.

list_models

List available provider/model ids (optionally filtered by provider or substring).

get_delegate_config

Read the current configuration.

set_delegate_config

Change the active model/provider/settings at runtime — no reinstall.

Example (from your primary agent)

"Delegate to the cheap model: in ~/code/app, add JSDoc to every exported function in src/utils/*.ts. Don't change behavior."

The primary agent calls delegate_task with directory: "~/code/app" and your task text; the cheap model does the mechanical work and reports back.

When does it delegate?

Installing the tools doesn't force an agent to use them — it decides, guided by its instruction file (CLAUDE.md for Claude Code, AGENTS.md for Codex). Add the delegation policy there to control it, and edit the conditions to fit your project.

✅ Delegate — high volume, low risk

⛔ Keep on the primary agent

Tests for well-specified behavior (delegate_tests)

Architecture, system design, choosing abstractions

Boilerplate & scaffolding (CRUD, DTOs, fixtures, mocks)

Security-sensitive code (auth, crypto, secrets, permissions)

Mechanical edits across many files (renames, prop propagation, import updates)

Concurrency, performance-critical paths, subtle correctness

Lint / formatting / type-error fixes

Ambiguous / underspecified requirements needing judgment

Docstrings, comments, README / changelog sections

Public API / interface design, breaking changes

Straightforward data transforms or migrations with a clear spec

Debugging unknown root causes

Obvious glue code / format conversions

Anything costly or hard to detect if the edit is wrong

Rule of thumb: high volume + low risk → delegate. Low volume + high risk → keep it. Unsure → keep it.

  • 📄 Full guide: docs/DELEGATION.md — how triggering works and how to customize the conditions.

  • 📋 Drop-in policy: docs/delegation-policy.md — the exact block to paste into CLAUDE.md / AGENTS.md (this table plus preconditions and briefing tips).

Install it during setup with --policy (or tick the boxes in the web configurator) — idempotent, safe to run more than once:

bash /tmp/ocd-install.sh --model "…" --targets "claude,codex" --policy "claude,codex"

Dynamic model / provider switching

You install once; you reconfigure as often as you like. A single config file is read fresh on every call, so switching the cheap model, provider, or any other setting never requires reinstalling. Four equivalent ways:

  1. Web configurator → "Update settings" tab — generates a one-line config set command.

  2. Terminal CLI (works wherever the server is installed):

    node ~/.local/share/opencode-delegate-mcp/dist/index.js config set --model openrouter/minimax/minimax-m2.5
    node ~/.local/share/opencode-delegate-mcp/dist/index.js config get
  3. From your agent, via the tool:

    // set_delegate_config
    { "default_model": "openrouter/minimax/minimax-m2.5" }   // switch provider+model
    { "default_model": "minimax-coding-plan/MiniMax-M2.7-highspeed", "timeout_ms": 900000 }
  4. Edit the file directly: ~/.config/opencode-delegate/config.json.

config CLI

node dist/index.js config get                     # print current config
node dist/index.js config path                    # print config file path
node dist/index.js config set [flags]             # patch config (only provided flags change)

  --model <provider/model>   --agent <name>        --variant <name>
  --timeout <seconds>        --default-dir <path>  --opencode-bin <path>
  --auto-approve <bool>

You can also override per call (delegate_task { model: "...", ... }) or define reusable profiles:

// set_delegate_config
{ "profiles": { "tests": { "model": "minimax-coding-plan/MiniMax-M2.5-highspeed" } } }
// then: delegate_task { profile: "tests", ... }

Profiles are merged, not replaced — existing ones survive unless you name them (an empty { "profiles": {} } patch is a no-op, it won't wipe your profiles). To remove a profile, set its value to null:

// set_delegate_config
{ "profiles": { "tests": null } }   // removes just "tests"; other profiles are untouched

Configuration reference

~/.config/opencode-delegate/config.json (override path with OPENCODE_DELEGATE_CONFIG):

Field

Type

Description

opencodeBin

string

Path/name of the opencode binary (installer sets the absolute path).

defaultModel

string

provider/model used when a call omits one.

defaultAgent

string?

Default OpenCode agent.

defaultVariant

string?

Default reasoning-effort variant (e.g. high).

autoApprove

boolean

Auto-approve tool permissions so headless delegations don't block (default true).

timeoutMs

number

Per-delegation timeout in ms (default 600000).

defaultDirectory

string?

Default working directory.

profiles

object

Named presets: name -> { model?, agent?, variant?, autoApprove? }.

How it works

The server shells out to opencode run --dir <dir> --model <provider/model> --format json [--auto] "<task>", parses OpenCode's JSON event stream, and returns a compact result (final text, session_id, token/cost usage, and the list of tool actions taken). Provider credentials live in OpenCode's own auth (opencode auth) — this server never stores API keys.

The execution backend is abstracted (Backend interface), so other agent runtimes can be added later. OpenCode is the first.

Security notes

  • This server does not store or transmit API keys. Provider auth is delegated to OpenCode.

  • autoApprove runs the cheap model non-interactively with tool permissions granted, so it can modify files and run commands in the target directory. Point delegations at repositories you trust and review the diffs. Set autoApprove: false to require manual approval (the delegation will then need an interactive OpenCode session).

Development

npm install      # installs deps and builds (prepare -> tsc)
npm run build    # compile TypeScript to dist/
npm run dev      # watch mode
node dist/index.js --version

License

MIT © mryesiller

Available Tools

5 tools
delegate_taskDelegate a coding task to a cheaper modelA
Destructive

Hand off self-contained, high-volume "grunt work" to a cheaper model running through OpenCode, so the primary agent can stay focused on architecture and critical decisions.

The subagent runs non-interactively in a real working directory and CAN read, write, and edit files and run shell commands there (auto-approved by default). Give it a complete, self-contained brief — it does not see your conversation.

Good for: writing repetitive/boilerplate code, mechanical refactors, generating tests, fixing lint/type errors, updating call sites, docstrings, simple migrations. Avoid for: architecture, security-sensitive logic, ambiguous specs, or anything where a wrong edit is costly.

Args:

  • task (string, required — alias: scope, accepted for parity with delegate_tests; provide one): Complete instructions for the subagent, including acceptance criteria.

  • directory (string): Absolute path of the repo/dir to work in. Defaults to the server's cwd or config.default_directory.

  • model (string): Override provider/model, e.g. "minimax-coding-plan/MiniMax-M2.5-highspeed". Defaults to config.default_model.

  • agent (string): OpenCode agent name to run as.

  • variant (string): Reasoning-effort variant, e.g. "high" | "minimal".

  • profile (string): Named preset from config (model/agent/variant/auto_approve).

  • files (string[]): Paths to attach as context.

  • session (string): Session id to continue a prior delegation (returned as session_id).

  • continue_session (boolean): Continue the last session instead of a specific id.

  • auto_approve (boolean): Auto-approve tool permissions (default from config, usually true).

  • response_format ('markdown' | 'json'): Output format (default 'markdown').

See also: delegate_tests — same shape, dedicated to test-writing; its required field is named scope instead of task.

Returns structured content: { ok, model, session_id, directory, result, error?, usage{tokens,cost}, actions[], duration_ms }.

Inputs: task, agent, files, model, +8 more.

delegate_testsDelegate test writing/running to a cheaper modelA
Destructive

Test-focused wrapper around delegate_task. The subagent writes (and optionally runs) tests for the given scope while avoiding changes to production code unless strictly required to make tests pass.

Args:

  • scope (string, required — alias: task, accepted for parity with delegate_task; provide one): What to test — module, files, behaviors, edge cases.

  • directory (string): Absolute repo path. Defaults to config.default_directory or server cwd.

  • framework (string): Optional testing framework/runner hint (e.g. "vitest", "pytest").

  • run_tests (boolean): Ask the subagent to run the suite and report pass/fail (default true).

  • model / agent / variant / profile / files / session / continue_session / auto_approve: same as delegate_task.

  • response_format ('markdown' | 'json'): Output format (default 'markdown').

See also: delegate_task — same shape, general-purpose; its required field is named task instead of scope.

Returns the same structured content shape as delegate_task.

Inputs: task, agent, files, model, +10 more.

get_delegate_configGet the delegate configurationA
Read-onlyIdempotent

Return the current delegate configuration (default model/provider, agent, variant, auto-approve, timeout, default directory, and named profiles) plus the config file path. Read-only.

Inputs: no named parameters.

list_modelsList available provider/model idsA
Read-onlyIdempotent

List provider/model ids that OpenCode can use, in "provider/model" form (e.g. "minimax-coding-plan/MiniMax-M2.5-highspeed"). Optionally filter to a single provider. Use these ids for the model argument of delegate_task or as default_model in set_delegate_config.

Args:

  • provider (string): Optional provider id to filter by (e.g. "minimax-coding-plan", "openrouter").

  • contains (string): Optional case-insensitive substring filter.

  • limit (number): Max ids to return (default 200).

  • response_format ('markdown' | 'json'): Output format (default 'markdown').

Inputs: limit, contains, provider, response_format.

set_delegate_configUpdate the delegate configurationA
Idempotent

Change the active delegation settings at runtime — this is how you dynamically switch the cheap model or provider without reinstalling. Only the fields you pass are updated. Returns the updated config.

Args (all optional):

  • default_model (string): provider/model used when a call omits one, e.g. "openrouter/minimax/minimax-m2.5".

  • default_agent (string): default OpenCode agent.

  • default_variant (string): default reasoning-effort variant.

  • auto_approve (boolean): auto-approve tool permissions for delegations.

  • timeout_ms (number): per-delegation timeout in milliseconds.

  • default_directory (string): default working directory.

  • opencode_bin (string): path/name of the opencode binary.

  • profiles (object): map of name -> { model?, agent?, variant?, autoApprove? }. Profiles are MERGED, not replaced — existing ones are kept unless you name them. To ADD or UPDATE a profile, give it a value; to REMOVE one, set its value to null: { "profiles": { "tests": null } }.

Inputs: profiles, timeout_ms, auto_approve, opencode_bin, +4 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.6/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: config read, config write, two specialized delegation tasks (general vs test), and model listing. The two delegation tools are differentiated by required field and documented use cases.

    Naming Consistency5/5

    All tools use consistent snake_case with a verb_noun pattern (get_, delegate_, list_, set_). No mixing of conventions.

    Tool Count5/5

    5 tools is well-scoped for the server's purpose: reading/writing config, listing models, and delegating tasks (general and test-specific). No excess or deficiency.

    Completeness4/5

    Covers all core operations for configuring and using delegation. Minor gap: no tool to retrieve results of a past delegation by session ID, but the delegation tools return results synchronously, so it's not a critical omission.

    Related MCP Connectors

    Related MCP Servers