Skip to content

fix: normalize mcpServers config key to mcp and transform external MCP formats#639

Merged
anandgupta42 merged 2 commits intomainfrom
fix/normalize-mcpservers-config-key
Apr 4, 2026
Merged

fix: normalize mcpServers config key to mcp and transform external MCP formats#639
anandgupta42 merged 2 commits intomainfrom
fix/normalize-mcpservers-config-key

Conversation

@anandgupta42
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the config validation error when users or LLMs write MCP server config using the mcpServers key (common in Claude Code, Cursor, .mcp.json format). The strict config schema rejected this with Unrecognized key: "mcpServers", preventing the app from starting.

This PR adds a normalizeMcpConfig function that:

  • Auto-normalizes top-level mcpServersmcp with a warning log
  • Transforms external MCP server format: string command + args + env → array command + environment
  • Handles remote servers without explicit type field (infers from url presence)
  • Always deletes mcpServers to prevent strict schema rejection (even when mcp already exists)
  • Normalizes typed entries that use external field names (env, string command)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Issue for this PR

Closes #638 (reported in #619)

How did you verify your code works?

  • 5 new tests covering: string command format, array command format, both-keys conflict resolution, remote server normalization, typed entry with external field names
  • All 7217 existing tests pass (0 failures)
  • Typecheck passes
  • Marker Guard passes (bun run script/upstream/analyze.ts --markers --base main --strict)
  • Multi-model code review (6 models: Claude, GPT 5.2 Codex, Gemini 3.1 Pro, Kimi K2.5, MiniMax M2.5, GLM-5) — all critical/major findings addressed

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes
  • I have added altimate_change markers to upstream-shared files

🤖 Generated with Claude Code

…l MCP formats

- Auto-normalize top-level `mcpServers` → `mcp` (used by Claude Code, Cursor, `.mcp.json`)
- Transform external MCP server format: string `command` + `args` + `env` → array `command` + `environment`
- Handle remote servers without explicit `type` field (infer from `url` presence)
- Always delete `mcpServers` to prevent strict schema rejection (even when `mcp` exists)
- Normalize typed entries that use external field names (`env`, string `command`)
- Add 5 tests: string command, array command, both-keys conflict, remote server, typed entry normalization

Closes #638

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

Warning

Rate limit exceeded

@anandgupta42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 43 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 13 minutes and 43 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8e04c111-3ba6-484a-a8b0-bd203839ffaf

📥 Commits

Reviewing files that changed from the base of the PR and between dd0c323 and 4ca0b3f.

📒 Files selected for processing (2)
  • packages/opencode/src/config/config.ts
  • packages/opencode/test/config/config.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/normalize-mcpservers-config-key

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Empty `mcpServers` object
- Non-object `mcpServers` value (string)
- Null server entries removed during normalization
- Numeric/boolean args coerced to strings
- String `args` field wrapped in array
- Disabled server entry (`{ enabled: false }`)
- `environment` takes precedence over `env`
- `timeout` and `enabled` fields preserved
- Mixed local and remote servers
- Special characters in server names

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anandgupta42 anandgupta42 force-pushed the fix/normalize-mcpservers-config-key branch from ed35235 to 4ca0b3f Compare April 4, 2026 15:55
@anandgupta42 anandgupta42 merged commit c103bfd into main Apr 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config validation rejects mcpServers key in altimate-code.json

1 participant