Antigravity OpenCode Delegate
This server bridges Antigravity to local OpenCode 2 so you can diagnose it, inspect models, and delegate bounded code-analysis or development tasks while retaining review and verification.
Run read-only diagnostics on the OpenCode binary, version, and optional model catalog (
opencode_doctor).List configured
provider/modelIDs without invoking an LLM (opencode_models).Execute a bounded task synchronously in a fresh isolated session, requiring an explicit
provider/model[#variant](opencode_execute).Start up to 4 concurrent background OpenCode jobs and return a job ID (
opencode_start).Poll running or completed jobs with live progress such as elapsed time and last event age (
opencode_status).Cancel an active job and terminate its owned process tree (
opencode_cancel).Default to read-only, standalone sessions with tool permissions denied for edits, shell, external directories, and network access.
Click on "Deploy 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., "@Antigravity OpenCode Delegate Please review src/auth for security issues using anthropic/claude-sonnet-4"
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.
Antigravity OpenCode Delegate (agy-opencode-mcp)
English | 简体中文
An Antigravity (agy) native plugin and stdio MCP bridge that delegates read-only codebase analysis and bounded development tasks to local OpenCode 2 (opencode), while Antigravity retains specification, planning, git diff review, and independent verification.
Ported from liuxiaofengone/opencode-mcp (originally forked from yuriisamohvalov-creator/opencode-mcp, preserving the MIT license and upstream attribution in NOTICE.md) specifically for Antigravity.
Key Characteristics
Clear Responsibility Split: Antigravity acts as planner, reviewer, and verifier; local OpenCode 2 runs as a bounded executor inside an isolated session (
--format json) and returns structured results with Git context (diffStat,statusShort).Native Antigravity Plugin (
plugins/opencode-delegate/): Ships plugin.json, mcp_config.json (${PLUGIN_ROOT}/mcp/server.mjs,timeoutSeconds: 3660), assets/logo.svg, and the opencode-delegate skill with reference.md.Zero-Install Single-File Bundle: build-plugin.mjs bundles
server.mjsandsrc/withesbuildintoplugins/opencode-delegate/mcp/server.mjs(tracked in Git), so the plugin runs offline withoutnpm install.Lazy Tool Loading & Gemini Schema Compatibility: All 6 tools (
opencode_doctor,opencode_models,opencode_status,opencode_execute,opencode_start,opencode_cancel) are lazy-loaded viacall_mcp_tool(mcp_config.json intentionally avoids"eager": trueso Antigravity does not drop tools from the enabled set), and all integer schema bounds stay within 32-bit signed limits.Mandatory Explicit Model Gate: Every
opencode_executeandopencode_startcall requires a completeprovider/model[#variant]ID (MODEL_REQUIRED/MODEL_INVALIDrejects missing or malformed IDs before spawning). Useopencode_modelsto inspect configured models first—there is no silent default or fallback model selection.Read-Only & Isolation Defaults: Defaults to
readOnly: true,standalone: true, andautoApprove: false, injecting an isolatedagy-mcp-readeragent viaOPENCODE_CONFIG_CONTENT(overriding both legacy and native permission fields to denyedit,write,patch,bash,shell,task,external_directory,webfetch, andwebsearch). Session continuation (sessionId,continueSession: true) is rejected socwdand permissions remain authoritative. (Note: OpenCode permissions are application-level controls, not an OS sandbox; exclude sensitive files such as.envor private keys in task briefs.)Shell-Free Execution, Redaction & Process-Tree Cleanup: Never spawns OpenCode through a shell (
shell: false) and rejects.cmd/.bat/.ps1wrappers forOPENCODE_BIN. Redacts common credentials (server password,Bearertokens, API keys/passwords) from output and errors, caps stdout line/text/stderr buffers, and terminates owned process trees (taskkill.exe /T /Fon Windows; process-groupSIGTERM/SIGKILLon POSIX) on timeout, cancellation, or MCP disconnect.Async Background Job Lifecycle:
opencode_start,opencode_status, andopencode_cancelsupport up to 4 concurrent background jobs (retaining up to 50 terminal results in memory) with liveelapsedMsandlastEventAgeMsprogress tracking to distinguish long thinking/tool calls from hangs.Portable Validator & Cross-Platform Test Suite: validate-plugin.mjs runs with zero third-party dependencies to verify manifest semver, UTF-8 BOM hygiene,
${PLUGIN_ROOT}relative paths, symlink/junction escapes, and absence of leaked user paths, backed by 49 automated tests and a Linux/Windows/macOS CI matrix (Node 22 & 24).
Related MCP server: zcode-mcp
MCP Tools Overview
Tool | Loading | Purpose | Key Notes |
| Lazy | Verify native OpenCode binary, | Read-only; rejects |
| Lazy | List deduplicated | Supports |
| Lazy | Poll async job state ( | Reports |
| Lazy | Run a bounded task synchronously in a fresh session | Requires |
| Lazy | Start an async background job and return | Max 4 active jobs; poll |
| Lazy | Abort an active job and terminate its owned process tree | Poll |
Prerequisites
Node.js >= 22
Antigravity (
agyCLI)Local OpenCode 2 installed with at least one configured model provider (verify with
opencode --versionandopencode models)
Install From Git
git clone https://github.com/liuxiaofengone/agy-opencode-mcp.git
Set-Location agy-opencode-mcp
agy plugin validate ./plugins/opencode-delegate --strict
agy plugin install ./plugins/opencode-delegate
agy plugin list --jsonWindows directory junction note: If the repository checkout sits under a directory junction (causing
agy plugin installto fail with path/rename errors), copyplugins/opencode-delegatedirectly to~/.gemini/config/plugins/opencode-delegateand verify withagy plugin validate ~/.gemini/config/plugins/opencode-delegate --strict.
If OpenCode is not discovered automatically, set OPENCODE_BIN in the installed plugin's mcp_config.json (env.OPENCODE_BIN) to the native executable absolute path (never a .cmd, .bat, or .ps1 wrapper).
After installing or updating mcp_config.json, refresh MCP servers (or restart Antigravity) and open a new Antigravity chat, then run opencode_doctor({ deep: true }) to verify the OpenCode binary and model catalog.
Repository Structure
agy-opencode-mcp/
├── server.mjs # Canonical stdio MCP server entrypoint
├── src/
│ ├── runner.mjs # Executable discovery, read-only config injection, process & git runner
│ ├── jobs.mjs # Bounded async job manager (start/status/cancel/prune)
│ ├── events.mjs # Streaming NDJSON event parser with line/text overflow bounds
│ └── version.mjs # Package/plugin version resolver
├── plugins/opencode-delegate/
│ ├── plugin.json # Antigravity plugin manifest
│ ├── mcp_config.json # MCP config (${PLUGIN_ROOT}/mcp/server.mjs, lazy loading)
│ ├── mcp/server.mjs # Tracked single-file esbuild bundle
│ ├── assets/logo.svg # Plugin icon
│ └── skills/opencode-delegate/ # Delegation rules (SKILL.md) & reference (reference.md)
├── scripts/
│ ├── build-plugin.mjs # esbuild bundler for plugins/opencode-delegate/mcp/server.mjs
│ ├── validate-plugin.mjs # Zero-dependency Antigravity plugin contract validator
│ └── smoke.mjs # Opt-in live smoke test against a temporary fixture directory
└── test/ # Node built-in test suite (49 tests)Development & Verification
npm install
npm run build:plugin
npm test
npm run validate:plugin
agy plugin validate ./plugins/opencode-delegate --strict --jsonOptional live smoke test (uses an explicitly authorized model and only touches a temporary fixture directory):
npm run test:live -- your-provider/your-modelTroubleshooting
MODEL_REQUIRED/MODEL_INVALID: Always pass a fullprovider/model(orprovider/model#variant) ID without whitespace. Callopencode_modelsif unsure which models are configured locally.agent.found: falseinopencode_doctor: OpenCode native binary was not found, orOPENCODE_BINpoints to a.cmd/.bat/.ps1script. SetOPENCODE_BINto the nativeopencode.exe(oropencodeon POSIX) path.New/updated tools not visible in Antigravity: Check plugin tool toggles in Antigravity, refresh MCP servers, and start a new chat session so the updated
mcp_config.jsonand schemas load.Long-running tasks timing out: Prefer
opencode_start+opencode_statusinstead of synchronousopencode_execute, and checkgit status/git diffbefore retrying any interrupted run.
Available Tools
6 toolsopencode_cancelA
Cancel one OpenCode background job and its owned local process tree. Poll status until the job reaches cancelled.
Inputs: jobId (required).
opencode_doctorA
Read-only diagnostics for local OpenCode 2 binary resolution, CLI version, and (with deep=true) configured model catalog availability.
Inputs: cwd, deep, timeoutMs.
opencode_executeA
Run a bounded task in a new session with local OpenCode 2. An explicit provider/model is REQUIRED for every task; never infer a model or rely on CLI defaults. Defaults to isolated read-only project analysis. Returns the requested model (not independently verified), text, session ID, exit status and Git context; reports model failures as errors.
Inputs: cwd (required), task (required), model (required), agent, +6 more.
opencode_modelsA
List configured provider/model IDs from local OpenCode 2 without invoking any model. Call this before delegating if the user has not specified an explicit provider/model.
Inputs: cwd, provider, timeoutMs, standalone.
opencode_startA
Start an OpenCode task in the background and immediately return a job ID. Poll opencode_status; do not start a duplicate task while the job is running.
Inputs: cwd (required), task (required), model (required), agent, +6 more.
opencode_statusC
Read the progress or terminal result of an OpenCode background job.
Inputs: jobId (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct role: doctor diagnostics, model listing, synchronous execution, background start, status polling, and cancellation. The only potentially confusable pair, opencode_execute and opencode_start, is explicitly differentiated by foreground/bounded execution versus background job creation.
All tools use the same opencode_ prefix followed by a clear action or resource noun in snake_case. The naming pattern is predictable and consistent across the entire set.
Six tools is well-scoped for a delegation server covering diagnostics, discovery, execution, and job lifecycle. No tool appears redundant or unnecessary.
The surface covers the core lifecycle: checking the local binary, listing models, executing tasks synchronously or in the background, polling status, and cancelling jobs. Minor gaps exist around session history or detailed log retrieval, but the essential workflows are covered.
Related MCP Connectors
Hosted coding agent: start, follow up on and stop tasks that can open GitHub pull requests.
Context, runtime and review for AI coding agents. One local install.
Run Claude Code, Codex and opencode on your own machines, with policy checks and phone approvals.
Scoped agent execution. Server-side credentials, policy, budgets and verifiable receipts.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables Codex to delegate coding tasks to an OpenCode CLI locally, returning structured results such as exit codes, session summaries, tool calls, and git diffs.2MIT
- AlicenseAqualityCmaintenanceEnables external agents to delegate coding tasks to a local zcode/GLM coding agent, with multi-turn sessions, model selection, and task cancellation.32MIT
- AlicenseBqualityBmaintenanceEnables MCP clients such as Claude Code, Codex CLI, and Cursor-agent to delegate bounded coding tasks to a local OpenCode v2.x installation via a single opencode_execute tool, returning the model's response, git diff/status summary, exit code, and session ID.18 npmMIT
- AlicenseAqualityAmaintenanceEnables a DeepSeek Harness agent to delegate bounded coding tasks to a local ZCode runtime, follow their progress through events, and review the resulting diffs before accepting or continuing the work. It also exposes model catalog, default-model, and setup-diagnostics tools for managing those delegated tasks.12Apache 2.0