altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

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

Open FrankTub opened this issue 8 months ago • 1 comments

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

FrankTub avatar Apr 02 '26 18:04 FrankTub

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!

anandgupta42 avatar Apr 05 '26 03:04 anandgupta42