opencode MCP server
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 MCP serversummarize the structure of this project"
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 server
A small, dependency-light MCP (stdio) server that lets Claude Code delegate cheap, mechanical work to opencode's free models — codebase summaries, exploration, web research, boilerplate, first drafts, contained bulk edits — so paid tokens go where they matter.
Python 3.10+, stdlib + the official mcp SDK. Runs on Linux and Windows.
Tools
Tool | Purpose |
| Run one task on a free model. |
| Named sessions with opencode ids, dirs, turn counts, token/cost tallies. |
| Drop a name from local bookkeeping (opencode's server-side session survives). |
| Liveness + doctor: resolves the binary, reports version, round-trips one prompt. |
| List model ids (free only by default — free ids rotate). |
Related MCP server: codex-buddy-for-claude
Safety model
The worker is a cheap model; the guardrails assume it will occasionally do something dumb.
Read-only by default.
mode:"read"maps toopencode --agent plan. Verified behavior: file writes and bash mutations are refused (nothing ever hit disk in testing); read-only shell commands and network (websearch) still work — read mode is not offline.Write mode is confined.
dirmust be an absolute, existing directory; the filesystem root, the home directory itself, and system paths (/etc,/usr,/var, …,C:\Windows,C:\Program Files*) are refused, including their subtrees. Optionally setOPENCODE_MCP_ALLOWED_DIRS(pathsep-separated roots) to allowlist where write mode may operate.Never
--auto. opencode's own permission prompts stay denied in non-interactive runs.Everything is reported.
files_changedandtools_usedcome back on every call; point write mode at git-tracked dirs so you can diff/revert.Hard timeout with tree-kill (opencode spawns child processes): POSIX process-group kill, Windows
taskkill /T /F. Cancelling the MCP call kills the worker too. Timeouts return partial results and keep the session resumable.One call per session name at a time; parallel calls on different sessions are fine.
Install & register
cd /root/agent-mcp
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
# register with Claude Code (user scope):
claude mcp add -s user opencode -- /root/agent-mcp/.venv/bin/python /root/agent-mcp/server.pyWindows (PowerShell):
cd C:\path\to\agent-mcp
py -3 -m venv .venv
.venv\Scripts\pip install -r requirements.txt
claude mcp add -s user opencode -- C:\path\to\agent-mcp\.venv\Scripts\python.exe C:\path\to\agent-mcp\server.pyWindows smoke check (3 commands):
opencode --version # CLI reachable?
.venv\Scripts\python -m unittest discover -s tests # parser/guards/kill-path
.venv\Scripts\python tests\e2e_client.py # live free-model round-tripConfiguration (env vars, all optional)
Var | Default | Meaning |
| auto-detect | Path to the opencode executable. Auto-detection: PATH, then the real |
|
| Default model id. |
|
| Where |
|
| Default per-call timeout (s); per-call |
|
| Truncate the worker's answer beyond this many chars ( |
| unset | If set, write-mode |
Giving the worker MCP tools
Pass opencode_config (absolute path) to delegate, pointing at e.g.:
{
"mcp": {
"gbk-fs": {
"type": "local",
"command": ["/root/gbk-fs/.venv/bin/python3", "-m", "gbk_fs"],
"enabled": true
}
}
}Verified live: the free model discovers and calls such tools (they surface to
it as gbk-fs_list_files, etc.).
Tests
.venv/bin/python -m unittest discover -s tests # offline: real captured fixtures
.venv/bin/python tests/e2e_client.py # live: needs network, ~1-2 min, $0Design notes / gotchas (hard-won)
The task prompt is piped via stdin (write, close). Never pass it in argv: a
--separator makes opencode drop the message and hang waiting on stdin, and Windows caps argv at 32 KB.Resume sessions with
-s <ses_id>(never--continue).opencode run --format jsonemits JSONL events; the answer is the concatenation oftextparts, tokens/cost arrive instep-finishparts, file writes are completedtoolparts (write/edit/patch/multiedit) withstate.input.filePath.Pipes are forced to UTF-8 (
errors="replace") — Windows would otherwise default to cp125x. stderr goes to a temp file to avoid two-pipe deadlock.Free model ids rotate; the
modelstool exists so the orchestrator can self-correct when the default disappears.
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/rajib884/opencode-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server