Skip to content

Add OpenCode as an MCP install target (wizard mcp add) #729

Description

@gewenyu99

Summary

wizard mcp add installs the PostHog MCP server into the user's AI coding clients. We should add OpenCode (sst/opencode) as a supported target.

Current supported clients

Defined in getSupportedClients() (src/steps/add-mcp-server-to-clients/index.ts): Claude Code, Claude Desktop/Web, Codex, Cursor, VS Code, Zed. OpenCode is a popular terminal AI coding agent with native MCP support and isn't covered.

How OpenCode consumes MCP

OpenCode is config-file based (not a CLI subcommand like claude mcp add / codex mcp add), so it fits the existing DefaultMCPClient file-writer pattern (same shape as Zed / VS Code):

  • Config: opencode.json (project) or ~/.config/opencode/opencode.json (global).
  • Remote MCP server entry under an mcp key, roughly:
    {
      "mcp": {
        "posthog": {
          "type": "remote",
          "url": "https://mcp.posthog.com/mcp",
          "enabled": true,
          "headers": { "Authorization": "Bearer <key>" }
        }
      }
    }

⚠️ Verify the exact schema (key name mcp, type: "remote" vs "local", enabled, header shape) against the current OpenCode docs before implementing — it has changed over releases.

Implementation sketch

  • New src/steps/add-mcp-server-to-clients/clients/opencode.ts extending DefaultMCPClient:
    • getServerPropertyName()"mcp"
    • getConfigPath() → global OpenCode config path (mac/linux; check Windows)
    • getServerConfig() → remote entry shape above (reuse getNativeHTTPServerConfig, add type/enabled)
    • isClientSupported() → detect OpenCode install / supported platforms
  • Register in getSupportedClients() (index.ts).
  • Add label/enum + tests mirroring clients/__tests__/claude.test.ts (the DefaultMCPClient reference test).

Context

Filed while hardening the MCP install path (subprocess timeouts + error-tracking the previously-silent config-write failures). Adding OpenCode is follow-up scope, not part of that fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions