Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,12 @@ export namespace Config {
const normalized = (() => {
if (!data || typeof data !== "object" || Array.isArray(data)) return data
const copy = { ...(data as Record<string, unknown>) }
// Alias mcpServers → mcp (Claude Code / Copilot format compatibility)
if ("mcpServers" in copy && !("mcp" in copy)) {
copy.mcp = copy.mcpServers
delete copy.mcpServers
log.info("aliased mcpServers to mcp in config", { path: source })
}
Comment on lines +1436 to +1441
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Remove duplicate normalization logic.

This code duplicates the mcpServers → mcp aliasing already handled by normalizeMcpConfig() (lines 1375-1383), which is called immediately after at line 1450. Since this code executes first, the normalization logic inside normalizeMcpConfig becomes unreachable for the top-level key, creating dead code and maintenance confusion.

The normalizeMcpConfig function is more comprehensive—it handles both the top-level key aliasing and individual server entry normalization. Consolidating all MCP normalization in one place improves maintainability and follows the DRY principle.

♻️ Proposed fix: Remove duplicate normalization
  const normalized = (() => {
    if (!data || typeof data !== "object" || Array.isArray(data)) return data
    const copy = { ...(data as Record<string, unknown>) }
-   // Alias mcpServers → mcp (Claude Code / Copilot format compatibility)
-   if ("mcpServers" in copy && !("mcp" in copy)) {
-     copy.mcp = copy.mcpServers
-     delete copy.mcpServers
-     log.info("aliased mcpServers to mcp in config", { path: source })
-   }
    const hadLegacy = "theme" in copy || "keybinds" in copy || "tui" in copy
    if (hadLegacy) {
      delete copy.theme
      delete copy.keybinds
      delete copy.tui
      log.warn("tui keys in opencode config are deprecated; move them to tui.json", { path: source })
    }
    // altimate_change start — normalize mcpServers to mcp (common key used by other AI tools)
    return normalizeMcpConfig(copy, source)
    // altimate_change end
  })()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/config/config.ts` around lines 1436 - 1441, The
duplicate top-level aliasing block that maps copy.mcpServers → copy.mcp
(checking "mcpServers" in copy && !("mcp" in copy") and logging) should be
removed so all MCP normalization is performed by normalizeMcpConfig(); delete
that if-block (the code referencing copy.mcpServers, copy.mcp and the log.info
call) and rely on normalizeMcpConfig() to handle both top-level aliasing and
per-server normalization to avoid dead code and duplication.

const hadLegacy = "theme" in copy || "keybinds" in copy || "tui" in copy
if (!hadLegacy) return copy
delete copy.theme
Expand Down
Loading