Skip to content

Add opencode skill + MCP server installation to installers#22

Merged
aniongithub merged 1 commit into
mainfrom
opencode-installer-support
May 23, 2026
Merged

Add opencode skill + MCP server installation to installers#22
aniongithub merged 1 commit into
mainfrom
opencode-installer-support

Conversation

@aniongithub
Copy link
Copy Markdown
Owner

@aniongithub aniongithub commented May 23, 2026

Summary

Adds opencode (https://opencode.ai) as a first-class target in both installers, alongside the existing GitHub Copilot CLI, Claude Code, VS Code, and Cursor support.

Why

opencode is gaining traction as an MCP-compatible coding agent. Until now, users had to hand-edit ~/.config/opencode/opencode.json after running the installer. This PR makes it just work.

What changed

opencode reads MCP configuration from ~/.config/opencode/opencode.json using a distinct schema from the mcpServers convention used by every other client we support:

  • top-level key is mcp (not mcpServers)
  • requires "type": "local"
  • command is a single array (binary + args combined) — not separate command string + args array
  • explicit "enabled": true

That meant a dedicated config function in each installer rather than reusing the existing configure_mcp_client / Set-McpConfig helpers.

install.sh

  • Add ~/.config/opencode/skills/devcontainer-mcp to SKILL_DIRS so SKILL.md lands at opencode's documented global skills path.
  • New configure_opencode_mcp function. Creates the file if missing; otherwise merges via python3 — preserves any existing $schema, model, sibling MCP entries, and other settings.

install.ps1

  • Mirror the skill directory addition.
  • New Set-OpencodeMcpConfig that writes the WSL-bridge form: command: ["wsl", "~/.local/bin/devcontainer-mcp", "serve"].

README.md

  • List opencode in the "Works with" badge line.

Scope note: host-protection hooks

opencode does have a hook mechanism, but it works very differently from Claude Code's PreToolUse / SessionStart (JSON pointing at a shell script). opencode uses a JS/TS plugin system (docs) where plugins live in ~/.config/opencode/plugins/ and subscribe to events like tool.execute.before and session.created.

Wiring our devcontainer-guard.sh and devcontainer-skill-loader.sh into that model requires writing a thin JS plugin that spawns the existing bash hooks — out of scope for this PR. Tracked as a follow-up issue.

Verification

Spun up the project's own devcontainer (debian-bookworm + rust + node + docker-in-docker) and ran install.sh inside. All checks pass:

Test Result
Fresh-install creates ~/.config/opencode/opencode.json with valid schema
SKILL.md placed at ~/.config/opencode/skills/devcontainer-mcp/
Schema validated: $schema, mcp.devcontainer-mcp.{type,command,enabled} correct
Idempotent rerun → "opencode — already configured"
Merge into pre-existing config preserves $schema, model, and a sibling MCP entry
Binary at the configured command[0] launches correctly (devcontainer-mcp --help succeeds)

Sample of the file the installer produces:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "devcontainer-mcp": {
      "type": "local",
      "command": ["/home/vscode/.local/bin/devcontainer-mcp", "serve"],
      "enabled": true
    }
  }
}

opencode reads MCP configuration from ~/.config/opencode/opencode.json using
a distinct schema: 'mcp' key (not 'mcpServers'), 'type: local', a single
'command' array, and explicit 'enabled: true'.

Changes:
- install.sh: add ~/.config/opencode/skills/devcontainer-mcp to SKILL_DIRS
  and write the opencode MCP entry via a dedicated configure_opencode_mcp
  function (preserves existing schema/model/sibling MCP entries).
- install.ps1: mirror the skill directory addition and add
  Set-OpencodeMcpConfig that writes the wsl-bridge command array.
- README.md: list opencode alongside the other supported clients.

opencode has no documented PreToolUse/SessionStart hook system, so the
host-protection guard and skill-loader hooks are not configured for it.

Verified end-to-end inside the project's devcontainer: fresh install,
idempotent rerun, and merge into a pre-existing config with sibling
schema/model/MCP entries — all preserved.
@aniongithub
Copy link
Copy Markdown
Owner Author

Follow-up issue for opencode host-protection hooks: #23

@aniongithub aniongithub merged commit d1ddb4f into main May 23, 2026
1 check passed
@aniongithub aniongithub deleted the opencode-installer-support branch May 23, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant