opencode MCP server
2026년 11월 13일 커밋AI 클라이언트에 제공자 API 키를 입력할 필요 없이, 지속적인 opencode server를 통해 GitHub Copilot 및 기타 설정된 모델을 쿼리합니다.
다른 이름 kud/mcp-opencode
- 스타
- 3
- Tools
- 10
- 다운로드, 30일
- —
- 최신 버전
- —
- 마지막 커밋
- 2026년 11월 13일
- 라이선스
- MIT
opencode MCP란?
opencode은(는) MCP server입니다. AI 클라이언트에 제공자 API 키를 입력할 필요 없이, 지속적인 opencode server를 통해 GitHub Copilot 및 기타 설정된 모델을 쿼리합니다. 10개 도구를 제공합니다. 예: query, list_models, list_sessions.
프로젝트 README에서 생성된 요약
opencode MCP server 정보
mcp-opencode를 사용하면 개발자는 지속적인 opencode server를 통해 GitHub Copilot, Claude, Gemini 등 다양한 AI 모델을 쿼리할 수 있습니다. 프롬프트를 로컬 opencode 인스턴스로 라우팅함으로써, 사용자는 Claude Desktop, Cursor, VS Code와 같은 MCP 호환 클라이언트에 제공자 API 키를 직접 제공하지 않고도 이러한 모델과 상호작용할 수 있습니다. 서버는 모델 액세스를 관리하며, 백그라운드 서비스가 실행 중이지 않은 경우 자동으로 시작할 수 있습니다.
사용자는 list_sessions, send, read와 같은 도구를 사용하여 활성 TUI 세션과 상호작용하며 연속적인 대화를 유지할 수 있습니다. 백그라운드 작업을 위해 서버는 start_instance, task, wait, stop_instance를 통한 headless job을 지원합니다. 이러한 작업은 git push 또는 자격 증명 액세스와 같은 동작을 방지하는 내장 가드레일이 있는 격리된 환경에서 실행됩니다. 개발자는 자동화된 작업에 추가 보안 계층을 더하기 위해 srt runtime을 사용하여 OS 수준의 샌드박싱을 선택할 수도 있습니다.
활용 사례
- 1사용 가능한 AI 모델 제한환경 변수를 사용하여 어시스턴트가 사용할 수 있거나 사용이 금지된 모델을 정확하게 정의합니다.
- 2안전한 자동화 작업 실행git push나 자격 증명 액세스와 같은 민감한 작업을 수행하지 못하도록 제한된 headless 작업을 실행합니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
opencode MCP 도구 10
README에서 감지됨querylist_modelslist_sessionssendreadstart_instancetaskwaitlist_instancesstop_instance
| query | — | |
| list_models | — | |
| list_sessions | — | |
| send | — | |
| read | — | |
| start_instance | — | |
| task | — | |
| wait | — | |
| list_instances | — | |
| stop_instance | — |
구성
MCP_OPENCODE_MODEL_ALLOWMCP_OPENCODE_MODEL_BLOCKOPENCODE_PASSWORD
| 이름 | 설명 | 유형 |
|---|---|---|
| MCP_OPENCODE_MODEL_ALLOW | — | |
| MCP_OPENCODE_MODEL_BLOCK | — | |
| OPENCODE_PASSWORD | — |
자동 검사
2026년 11월 14일에 실행됨전체 보고서 →아직 인증되지 않았습니다. 서버는 80점 이상의 점수, 심각한 결함 없음, 그리고 검사에 충분한 데이터를 갖추어야 합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능kud/mcp-opencode is public and reachablegithub.com/kud/mcp-opencode ↗통과
- 패키지가 이 저장소를 소스로 명시검사되지 않음
- 빌드 출처(Sigstore 증명)검사되지 않음
- 오픈 소스 라이선스 (OSI)No license결함 발견
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-11-12github.com/kud/mcp-opencode ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음검사되지 않음
- 패키지 및 해당 종속성에 중요한 보안 권고 없음검사되지 않음
- 모델에 대한 숨겨진 지침 없음10 tool descriptions and the README read; no override phrases, credential paths or hidden characters통과
- 파괴적인 도구에 라벨 표시됨No tool named like delete, drop or exec통과
- 원격 엔드포인트가 MCP 핸드셰이크에 응답검사되지 않음
README
GitHub에서 보기
MCP server for opencode — query github-copilot models via a persistent opencode server.
Website · Documentation
Features
- Zero API key — routes prompts through a locally running opencode server, so no provider credentials are needed in your AI client.
- Multi-model support — any model configured in opencode is available; query GPT-4.1, Claude, Gemini, or any other supported provider.
- Model filtering — restrict or block models via
MCP_OPENCODE_MODEL_ALLOWandMCP_OPENCODE_MODEL_BLOCKenvironment variables using glob-style patterns. - Talk to a live session —
list_sessions,sendandreadlet your assistant hold a conversation with a running opencode session, such as the one open in your TUI, and the exchange shows up there live. - Headless jobs —
start_instance,task,wait,list_instancesandstop_instancerun work on a private opencode server per job, with guard rails (no git push, no credentials, no permission prompts) and a ready-madeopencode --servercommand to watch it live. - Auto-start — if opencode's background service is not running,
queryandlist_modelsstart it the same way the TUI does. - Session isolation — each
querycall creates and destroys its own opencode session, so one-off questions leave nothing behind. - Works everywhere — compatible with Claude Desktop, Claude Code, Cursor, Windsurf, VSCode, and any MCP-capable client.
Install
npm install -g @kud/mcp-opencode
Requires opencode 2.x (npm i -g @opencode/cli) with at least one provider configured, and Node.js ≥ 20. For opencode 1.x, stay on @kud/mcp-opencode@1.
Usage
Add the server to your MCP client configuration:
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "@kud/mcp-opencode"]
}
}
}
To restrict which models are available, pass environment variables:
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "@kud/mcp-opencode"],
"env": {
"MCP_OPENCODE_MODEL_ALLOW": "github-copilot/*",
"MCP_OPENCODE_MODEL_BLOCK": "github-copilot/gpt-4o-mini"
}
}
}
}
Talking to a live opencode session
opencode 2 runs one background service that every TUI window shares, and records where it listens (and its password) in its state directory. The MCP reads that registration, so any window you open with a plain opencode is reachable: no ports, no wrapper.
1. Open opencode and say something. opencode only creates a session once you send the first message.
2. Ask your assistant to talk to it. For example: "list my opencode sessions and ask the one in my-project what it thinks of this plan". It calls list_sessions to find the session, send to talk to it, and read to catch up on its history. Messages appear live in the window, and you can reply there yourself.
A window started with opencode --standalone runs a private server with a throwaway password, so the MCP cannot reach it. To use a server of your own instead of the background service, set MCP_OPENCODE_URL (and MCP_OPENCODE_PASSWORD if it has one); a TUI joins that server with opencode --server <url>.
Running headless jobs
For work you want done in the background rather than in a window you are watching, ask your assistant to start an instance and hand it a task. For example: "start an opencode instance in ~/Projects/my-app, have it add a health-check endpoint, and tell me what changed". It calls:
start_instance({ directory })→{ port, url }: a privateopencode serveon a free port behind a generated password, separate from the background service your windows use.task({ port, prompt })→{ session_id, port, attach }: returns at once while the job runs.wait({ port, session_id })→ status, the last assistant text and the files changed. Call it again if it comes backbusy.stop_instance({ port })when done. Idle instances are reaped afterMCP_OPENCODE_INSTANCE_TTL, and the MCP stops its own instances when it exits.
Guard rails. Nobody is there to answer a permission prompt, so a task's session never gets one: reading, editing and shell commands are allowed, while git push, git remote, gh, npm publish, git reset --hard, web fetches and searches, questions and anything outside the directory are denied. Every deny is set twice: as an opencode permission rule (session and server config) and as a policy, which opencode applies after all rules, so a repository's own opencode config cannot allow it back. The server itself runs with no git credentials (GIT_TERMINAL_PROMPT=0, GIT_SSH_COMMAND=false, an empty credential.helper), without GH_TOKEN/GITHUB_TOKEN, and with its model pinned to MCP_OPENCODE_MODEL.
Sandboxing (opt-in OS sandbox). Set MCP_OPENCODE_SANDBOX=srt to wrap each instance's opencode serve in srt (npm i -g @anthropic-ai/sandbox-runtime), enforced by the OS (macOS sandbox-exec, Linux bubblewrap) rather than by opencode's own permissions. Off by default; when the variable is unset everything behaves exactly as before. Any other non-empty value is refused with an error listing the supported values, and if srt is not on PATH the instance fails to start rather than running unsandboxed.
The server generates an srt settings file per instance (kept in a temp dir under the state dir, removed on stop_instance) and passes it as srt --settings <file> opencode serve … — always explicit, so a stray ~/.srt-settings.json can never decide the policy. The generated file allows writes only to the instance directory (realpath), its git dir(s) (both --git-common-dir and --git-dir, so worktrees work), opencode's own data/config/cache/state dirs (XDG-aware, so provider auth keeps working) and the temp dir; denies reads of credential paths (~/.ssh, ~/.aws, ~/.config/gh, ~/.gnupg, ~/.netrc, ~/.npmrc, **/.env, **/.env.*, ~/Library/Keychains, ~/.config/gcloud, ~/.kube, ~/.docker/config.json, and the background service's service.json files, which hold its password); and allows only these network destinations plus local binding for the server's own port: opencode.ai, *.opencode.ai, models.dev, api.githubcopilot.com, openrouter.ai, github.com, *.github.com, api.github.com, registry.npmjs.org, localhost, 127.0.0.1.
Sandboxed instances also get extra shell denies merged into their opencode permission config (session ruleset and OPENCODE_CONFIG_CONTENT alike): rm -rf*, sudo *, curl *|* and wget *|*. These are deny, never ask — a headless session cannot answer and would hang — and they are heuristic glob matches, a second layer behind the OS sandbox, not a guarantee. The opencode.ai / *.opencode.ai / api.githubcopilot.com entries were verified against the opencode 2.1.2 binary's strings (Zen API, model registry at models.opencode.ai, Copilot provider), and openrouter.ai serves the openrouter/* models; models.dev, the 1.x registry, is kept for older lookups; the rest are assumed useful for public clones and npm installs. Non-existent allowWrite entries are dropped when the file is written, so a missing opencode dir cannot break the wrap on any platform.
This is defence in depth, not a guarantee: it raises the cost of escape and of credential or network misuse, but a determined agent inside the sandbox still has the instance directory, git, and whatever the allowlist permits. Combine it with the guard rails above and review what jobs do.
Model fallback. A job tries [its model, ...MCP_OPENCODE_MODEL_FALLBACK] once each, in order. When the session stays in retry for MCP_OPENCODE_RETRY_TIMEOUT_SECONDS (default 90) or its run ends in a provider error (a provider.* error type, or model not found), the watchdog interrupts it, switches the session's model and re-prompts the same session on the next model, so history and worktree edits carry over. When the list is exhausted the job settles as error. wait and list_instances report the current model and the fallbacks taken ({ from, to, reason, at }), and wait reports retry as its own status.
Watching or stepping in. Paste the attach command from task into a terminal. It opens the session in the TUI against the instance, with the instance's password:
OPENCODE_PASSWORD=… opencode --server http://127.0.0.1:53817 --session ses_…
Instance registry
Instances are recorded in ~/.local/state/mcp-opencode/instances.json (or $MCP_OPENCODE_STATE_DIR/instances.json). Other tools may read it directly; this shape is a stable contract:
[
{
"runtime": "opencode", // always "opencode" for now
"sandbox": "srt", // "srt" when OS-sandboxed, else null
"port": 53817, // where the server listens, on 127.0.0.1
"pid": 41234, // the opencode serve process (or the srt wrapper, when sandboxed)
"mcpPid": 41200, // the mcp-opencode process that started it
"directory": "/Users/me/Projects/my-app",
"startedAt": "2026-10-02T12:04:34.453Z",
"password": "…", // basic-auth password (user "opencode") for the server
// one entry per task, appended when task starts it
"sessions": [
{
"id": "ses_…",
"title": "add health check",
"model": "github-copilot/gpt-4.1",
"startedAt": "2026-10-02T12:04:35.021Z",
// model switches so far, oldest first; empty until one happens
"fallbacks": [
{
"from": "github-copilot/gpt-4.1",
"to": "github-copilot/gpt-5",
"reason": "retry timeout after 90s (attempt 3: rate limited)",
"at": "2026-10-02T12:06:05.111Z",
},
],
},
],
},
]
Live state (busy or idle, last activity) is deliberately not in the file: read it from the server at http://127.0.0.1:<port> with the row's password. The file is written owner-only (0600) because it holds those passwords; list_instances leaves them out. A sandboxed row also carries an internal sandboxSettingsDir with the generated srt settings file; it is cleaned up on stop and is not part of the contract.
Environment variables
| Variable | Default | Purpose |
|---|---|---|
MCP_OPENCODE_URL |
the background service | Use this opencode server for everything instead of the background service and its discovery |
MCP_OPENCODE_PASSWORD |
none | Password for MCP_OPENCODE_URL, when that server has one |
MCP_OPENCODE_SEND_TIMEOUT |
600 |
Seconds send waits for a reply before handing back and letting you read it later |
MCP_OPENCODE_MODEL |
github-copilot/gpt-4.1 |
Model query uses when none is passed |
MCP_OPENCODE_MODEL_ALLOW |
all | Comma-separated models or provider/* patterns query may use |
MCP_OPENCODE_MODEL_BLOCK |
none | Comma-separated models or patterns to block. Filters apply to query, list_models and a model passed to send; without one, send uses the session's own model |
MCP_OPENCODE_MODEL_FALLBACK |
none | Ordered, comma-separated fallback models (provider/model) a headless job tries in order after its chosen model when that model stalls or fails. Filtered by the allow/block filters; disallowed entries are dropped |
MCP_OPENCODE_RETRY_TIMEOUT_SECONDS |
90 |
Seconds a job's session may stay continuously in retry before the watchdog switches it to the next fallback model |
MCP_OPENCODE_INSTANCE_TTL |
1800 |
Seconds every session on an instance may sit idle before the reaper stops it |
MCP_OPENCODE_STATE_DIR |
~/.local/state/mcp-opencode |
Where the instance registry (instances.json) and instance logs live |
MCP_OPENCODE_SANDBOX |
unset (off) | srt wraps headless instances in an OS sandbox via srt (npm i -g @anthropic-ai/sandbox-runtime); any other non-empty value fails start_instance |
MCP_OPENCODE_SANDBOX_SETTINGS |
generated | Path to an srt settings file used as --settings verbatim instead of the generated one (must exist; implies srt) |
Available tools
| Tool | Description |
|---|---|
query |
Send a prompt to an opencode model. Accepts prompt (required) and model (optional, default: github-copilot/gpt-4.1). |
list_models |
List models available through the running opencode server. Accepts an optional provider filter (e.g. anthropic). |
list_sessions |
List sessions on the background service and on headless instances, most recent first, with the port(s) each is served on. Accepts an optional directory filter. |
send |
Send a message to an existing session and return the reply. Accepts session_id, prompt, and optional agent, model (allowlist-checked; either switches the session for later turns too, as picking it in the TUI does), port and timeout_seconds. Routes to the server that owns the session. Never creates or deletes sessions. |
read |
Read a session's recent messages as a condensed transcript. Accepts session_id and optional limit (default 20) and port. |
start_instance |
Start a private headless opencode server in directory. Returns { port, url }. |
task |
Start a job on an instance: port, prompt, optional model (allowlist-checked), agent (default build) and title. Tries [model, ...fallbacks] in order when a model stalls or fails. Returns { session_id, port, attach } at once. |
wait |
Wait for a job (port, session_id, timeout_seconds up to 570). Returns status (idle, busy, retry or error), the current model, the fallbacks taken so far, last assistant text and changed files (diffed across the whole session, fallback re-prompts included). |
list_instances |
Reap, then list registered instances with their task sessions' live status, current model and fallbacks. |
stop_instance |
Interrupt busy sessions, stop the server on port and confirm the port has closed. |
Development
git clone https://github.com/kud/mcp-opencode.git
cd mcp-opencode
npm install
npm run build
npm test
Use the local .mcp.json to connect Claude Code to your dev build, or npm run inspect to open the MCP Inspector against the compiled output.
| Script | Purpose |
|---|---|
npm run dev |
Run from source via tsx |
npm run build |
Compile TypeScript to dist/ |
npm test |
Run the Vitest test suite |
npm run inspect |
Open MCP Inspector against the built server |
📚 Full documentation → mcp-opencode/docs
opencode MCP 질문
opencode MCP는 어떤 도구를 제공하나요?
10개 도구를 제공합니다. 예: query, list_models, list_sessions, send, read.
AI 클라이언트에 API 키가 필요한가요?
아니요, 서버가 로컬에서 실행되는 opencode server를 통해 프롬프트를 라우팅하므로 AI 클라이언트에 제공자 자격 증명을 입력할 필요가 없습니다.
어떤 모델을 사용할 수 있나요?
GPT-4.1, Claude, Gemini 또는 기타 지원되는 제공자를 포함하여 opencode에 설정된 모든 모델을 사용할 수 있습니다.