Skip to content

MCP server config uses unrecognized 'mcpServers' key in altimate-code.json #619

Closed

Description

@FrankTub

When asking the tool to add an MCP server for GitLab, it creates a file that will prevent altimate from starting up when running a new session. The following error is shown when you run altimate to create a new session.

Error: Configuration is invalid at ~/.config/altimate-code/altimate-code.json
↳ Unrecognized key: "mcpServers"

Output of ~/.config/altimate-code/altimate-code.json:

{
  "mcpServers": {
    "gitlab": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-gitlab"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "my-token",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

Metadata

Field Value
CLI Version 0.5.17
Platform darwin
Architecture arm64
OS Release 25.3.0
Category bug

Activity

  1. added a commit that references this issue on Apr 3, 2026
    c292be1
  2. anandgupta42 commented on Apr 5, 2026

    @anandgupta42
    Contributor

    Status: Fixed by #639 (merged April 4, 2026)

    The compatibility gap you reported — AI tools writing `mcpServers` instead of `mcp` in `altimate-code.json` — has been fully resolved.

    What was shipped

    #639 added `normalizeMcpConfig()` in `packages/opencode/src/config/config.ts:1372-1421` which does:

    1. Top-level key aliasing: `mcpServers` → `mcp` (with `log.warn` when migrated, `log.debug` when dropped due to conflict)
    2. Per-server shape translation: converts Claude Code / Copilot format to altimate-code's schema:
      • `{command: "npx", args: [...], env: {...}}` → `{type: "local", command: [...], environment: {...}}`
      • String `command` + `args` array → merged into `command` array
      • `env` → `environment`
      • Remote servers with `url` → `{type: "remote", url, headers}`
    3. Conflict handling: always deletes `mcpServers` from the parsed config before Zod schema validation, regardless of whether `mcp` is also present

    Adversarial test coverage

    Comprehensive tests at `packages/opencode/test/config/config.test.ts:346-490` covering:

    • Normal case: `mcpServers` only → aliased to `mcp`
    • Array `command` format → preserved as-is
    • Conflict: both `mcp` and `mcpServers` → `mcp` wins, `mcpServers` dropped silently
    • Remote servers without `type` field → auto-inferred as `"remote"`
    • Typed entries with external field names → normalized
    • Empty `mcpServers` object → loads without error
    • Malformed entries → rejected cleanly

    Verifying the fix

    # Drop an altimate-code.json with Claude Code's mcpServers format:
    {
      \"mcpServers\": {
        \"gitlab\": {
          \"command\": \"npx\",
          \"args\": [\"-y\", \"@modelcontextprotocol/server-gitlab\"],
          \"env\": { \"GITLAB_PERSONAL_ACCESS_TOKEN\": \"your-token\" }
        }
      }
    }

    altimate-code will auto-normalize it on load and log a warning instead of crashing. No config rewrite needed — the transformation happens in-memory before schema validation.

    Closing this issue as resolved. Thanks @VJ-yadav for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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