This guide connects OpenCode to Code Agent++ through the stdio MCP server. OpenCode remains the coding runtime; Code Agent++ supplies task context, edit boundaries, evidence checks, and repair/finalize decisions.
Build the package:
npm run buildAdd the MCP server to the OpenCode MCP configuration supported by your OpenCode version:
{
"mcpServers": {
"code-agent-plusplus": {
"command": "code-agent-plusplus-mcp",
"args": []
}
}
}Local development can use the built server directly:
{
"mcpServers": {
"code-agent-plusplus": {
"command": "node",
"args": ["F:/codex/code/Repo-to-Agent-Context/dist/mcp/server.js"]
}
}
}Ask OpenCode to call:
code_agent_plusplus_start_loopExample:
{
"repo": "F:/path/to/repo",
"task": "fix login timeout bug",
"agent": "other",
"type": "bugfix",
"base": "main"
}The response is the runtime contract for the turn: nextAction, blocking, requiredCommands, mustInspect, allowedEditGlobs, avoidEditGlobs, and missingEvidence.
Record file edits:
{
"repo": "F:/path/to/repo",
"traceId": "fix-login-timeout-bug",
"agent": "opencode",
"action": "edit",
"files": ["src/auth/session.ts"],
"reason": "Timeout handling lives in the session module"
}Record command evidence:
{
"repo": "F:/path/to/repo",
"traceId": "fix-login-timeout-bug",
"agent": "opencode",
"action": "run-test",
"command": "npm test -- test/auth/session.test.ts",
"result": "passed"
}If OpenCode emits JSON events, prefer passing those events through the CLI orchestrator or future native normalizer; MCP step is the portable manual bridge.
Call:
code_agent_plusplus_evaluateExample:
{
"repo": "F:/path/to/repo",
"task": "fix login timeout bug",
"traceId": "fix-login-timeout-bug",
"base": "main",
"phase": "after-edit",
"failOn": "required"
}OpenCode should treat blocking: true as a stop condition and follow nextAction plus requiredCommands.
Call code_agent_plusplus_repair when evaluation returns missing evidence, policy failures, contract failures, hallucination findings, or regression findings. Repair should focus on the returned requiredActions and must not widen the edit surface unless allowedEditGlobs changes after a repack.
Call code_agent_plusplus_finalize only when the latest evaluation is non-blocking:
{
"repo": "F:/path/to/repo",
"task": "fix login timeout bug",
"traceId": "fix-login-timeout-bug",
"base": "main",
"finalState": "success"
}- MCP mode is advisory unless your OpenCode workflow refuses to continue on
blocking: true. - OpenCode event schemas may differ by version; native event normalization should be validated per version.
- For Code Agent++-led execution, prefer
code-agent-plusplus orchestrate ... --executor opencode. - MCP
stepdoes not execute shell commands; it records evidence provided by the agent or host.