Skip to content

OpenCode export flow missing $rename map for mcpServers → mcp #32

@egonm12

Description

@egonm12

Bug description

When running opkg install <package> in a workspace with OpenCode detected, the generated .opencode/opencode.json uses the key "mcpServers" instead of "mcp". OpenCode rejects this with:

Configuration is invalid at .opencode/opencode.json
↳ Unrecognized key: "mcpServers"

Steps to reproduce

  1. Create a package with a mcp.jsonc:
    {
      "mcpServers": {
        "atlassian": {
          "type": "http",
          "url": "https://mcp.atlassian.com/v1/mcp"
        }
      }
    }
  2. Run opkg install <package> in a workspace where OpenCode is detected
  3. Inspect .opencode/opencode.json

Actual result:

{
  "mcpServers": {
    "atlassian": {
      "type": "http",
      "url": "https://mcp.atlassian.com/v1/mcp"
    }
  }
}

Expected result:

{
  "mcp": {
    "atlassian": {
      "type": "http",
      "url": "https://mcp.atlassian.com/v1/mcp"
    }
  }
}

Root cause

The OpenCode export flow in platforms.jsonc (lines 816-828) is missing the map transformation to rename mcpServersmcp:

// Current (line 816-828) — MISSING map
{
  "from": ["mcp.jsonc", "mcp.json"],
  "to": { "$switch": { ... ".opencode/opencode.json" } },
  "merge": "deep"
  // ❌ No map — mcpServers passes through unchanged
}

The Codex platform correctly handles the equivalent rename on line 472:

{ "$rename": { "mcpServers": "mcp_servers" } }

The spec in specs/platforms/flows.md (line 1898) also confirms the inverse rename should exist:

"map": [{ "$rename": { "mcpServers": "mcp" } }]

Suggested fix

Export flow (line 816-828) — add map:

{
  "from": ["mcp.jsonc", "mcp.json"],
  "to": {
    "$switch": {
      "field": "$$targetRoot",
      "cases": [
        { "pattern": "~/", "value": ".config/opencode/opencode.json" }
      ],
      "default": ".opencode/opencode.json"
    }
  },
  "merge": "deep",
  "map": [
    { "$rename": { "mcpServers": "mcp" } }
  ]
}

Import flow (line 884-895) — add reverse map:

{
  "from": {
    "$switch": {
      "field": "$$targetRoot",
      "cases": [
        { "pattern": "~/", "value": ".config/opencode/opencode.json" }
      ],
      "default": ".opencode/opencode.json"
    }
  },
  "to": "mcp.jsonc",
  "map": [
    { "$rename": { "mcp": "mcpServers" } }
  ]
}

Workaround

Users can override via ~/.openpackage/platforms.jsonc or <cwd>/.openpackage/platforms.jsonc with the corrected OpenCode section.

Environment

  • opkg version: latest (npm)
  • Platform: macOS (darwin)
  • Target: OpenCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions