Skip to content

feat(mcp): add OpenCode as an MCP install target#758

Open
jojosenthusiast wants to merge 1 commit into
PostHog:mainfrom
jojosenthusiast:feat/opencode-mcp-target
Open

feat(mcp): add OpenCode as an MCP install target#758
jojosenthusiast wants to merge 1 commit into
PostHog:mainfrom
jojosenthusiast:feat/opencode-mcp-target

Conversation

@jojosenthusiast

Copy link
Copy Markdown

Fixes #729

Summary

  • Adds OpenCode as an MCP install target.
  • Writes PostHog MCP config under OpenCode's mcp key using type: remote.
  • Supports XDG config path on Linux and the documented ~/.config/opencode/opencode.json fallback.

Verification

  • node_modules\.bin\vitest.cmd run src/steps/add-mcp-server-to-clients/clients/__tests__/opencode.test.ts
  • git diff --check main...HEAD

Risk

Low. This adds a new client target following the existing MCP client pattern.

OpenCode reads MCP servers from ~/.config/opencode/opencode.json under a
top-level mcp key, with each entry tagged by a type discriminator
(local or remote). PostHog MCP is registered as a remote entry so
OpenCode's native OAuth handling (and not subprocess mcp-remote) talks to
mcp.posthog.com — matching the pattern Sentry uses in OpenCode's docs.

- Add OpenCodeMCPClient (extends DefaultMCPClient): mcp property, type:
  remote server config via getNativeHTTPServerConfig, XDG_CONFIG_HOME
  honoured on Linux, supported on darwin/linux/win32.
- Wire OpenCodeMCPClient into getSupportedClients alongside the other
  registered clients.
- Add a zod schema for the OpenCode config shape (local + remote variants)
  to mirror the existing per-client schema convention.
- Tests cover add/remove/idempotency, local/posthog-local naming, OAuth
  vs apiKey modes, sibling preservation, and isServerInstalled detection
  under the mcp key.

Refs: PostHog#729
Schema source: https://opencode.ai/docs/mcp-servers
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.

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

1 participant