mcp-opencode
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., "@mcp-opencodeRefactor utils.ts with model openai/gpt-4o-mini in ~/Projects/myapp"
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.
mcp-opencode
An MCP server that lets an AI coding agent (Claude Code, Codex, or any MCP client) delegate implementation work to the OpenCode CLI — choosing an explicit provider + model on every call.
Use it to orchestrate with one model while offloading the actual code-writing to another: plan in Claude, implement with GLM 5.2, Kimi, DeepSeek, a local Ollama model, or anything else OpenCode can reach.
Provider-agnostic. This server contains no provider-specific logic. It passes your
provider/modelstring straight toopencode run -m, so it works with every provider OpenCode supports (75+ via models.dev, plus local models). Whatever you've authenticated in OpenCode, you can use here.
Why
Model per task. A cheap model for mechanical edits, a strong one for hard changes — decided per call, not baked into config.
Real cost/token reporting returned with every run.
Multi-turn. Continue a session to iterate on the same working tree.
Safe by construction.
cwdis confined to an allowlist; the child process tree is killed cleanly on timeout/abort/cost-cap; secrets are redacted from anything echoed back.
Related MCP server: AgentSpawnMCP
Prerequisites
Node.js ≥ 20
The OpenCode CLI installed and on
PATH, with at least one provider authenticated (opencode auth login). Runopencode modelsto see what's available to you.
Register
No install step needed — npx fetches and runs the published package.
Claude Code:
claude mcp add -s user opencode \
-e OPENCODE_MCP_ROOTS="$HOME/Projects" \
-- npx -y mcp-opencodeCodex:
codex mcp add opencode \
--env OPENCODE_MCP_ROOTS="$HOME/Projects" \
-- npx -y mcp-opencodeRestart the client (or run claude mcp list / codex mcp list) to confirm it
connects. The tools appear as opencode_run, opencode_reply, opencode_models.
Build from source (for development)
git clone https://github.com/shreeraman96/mcp-opencode.git
cd mcp-opencode
npm install
npm run build
npm test # unit tests
npm run smoke # optional: live test against a real free OpenCode modelThen register with node /absolute/path/to/mcp-opencode/dist/index.js instead of
the npx command above.
Tools
opencode_run — start a new session
field | type | notes |
| string | required — the task |
| string | required — |
| string | required — must resolve inside an allowed root (see below) |
|
| default |
| string | optional model variant / reasoning effort ( |
| int 30–3600 | default 900 |
| number | optional — kill the run and return partial output if exceeded |
Returns status, sessionID, model, elapsed time, tokens/cost, a git-derived
changed-files summary (when cwd is a repo), and the assistant output.
opencode_reply — continue a session
Takes a sessionID (ses_…) from a prior run plus a new prompt, model,
cwd, and agent. model is required on every call — there is no silent
inheritance from the original run, by design.
opencode_models
No input. Runs opencode models and returns the available list.
Example (Claude Code)
Delegate to OpenCode: call
opencode_runwith modelfireworks-ai/accounts/fireworks/models/glm-5p2, cwd~/Projects/myapp, agentbuild, and prompt "add input validation to routes/user.ts".
Swap the model string for anthropic/claude-sonnet-4-5, openai/gpt-oss-120b,
opencode/big-pickle (free), or any local model — nothing else changes.
Configuration
env var | default | purpose |
|
| colon-separated allowlist of directories |
| unset | set to |
cwd allowlist
cwd is resolved with fs.realpath (symlinks followed) and must land inside one
of the OPENCODE_MCP_ROOTS directories. Requests outside the allowlist are
rejected before opencode is ever spawned.
Permission model
OpenCode's build agent already runs edit/bash/webfetch non-interactively;
the plan agent is read-only. This server relies on those built-in agent
defaults and does not inject a custom permission config.
Note: passing a custom
permissionblock viaOPENCODE_CONFIGwas found to hangopencode runin a non-TTY environment (an unanswerableaskprompt), so that path is deliberately avoided. Seesrc/policy.ts.
--auto (OpenCode's "auto-approve anything not explicitly denied", which the CLI
itself flags as dangerous) is off by default and only added when you set
OPENCODE_MCP_ALLOW_AUTO=1 and the call uses agent: 'build'.
How it works
src/run.tsspawnsopencodedetached in its own process group, so the whole subprocess tree is killed as a unit (SIGTERM → 5s grace → SIGKILL) on timeout, client abort, or amaxCostUsdbreach. Process exit is treated as the authoritative completion signal.src/parse.tsstreams the--format jsonoutput line-by-line without ever buffering the raw stream; assistant text is capped to head(40k)+tail(10k) chars past 50k total.src/queue.tsserializes runs that share the same resolvedcwd; different working trees run concurrently.src/policy.tsholds the cwd allowlist, model/session validation, secret redaction, and error classification.
For long runs, the server emits MCP progress notifications every 15s (when the client supplies a progress token), which resets the client's idle timeout.
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- 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/shreeraman96/mcp-opencode'
If you have feedback or need assistance with the MCP directory API, please join our Discord server