From 262bba1a290abfaa7b2c673c56b64fd724d1e242 Mon Sep 17 00:00:00 2001 From: mstoyanova Date: Thu, 28 May 2026 12:25:16 +0300 Subject: [PATCH 1/6] fix: update MCP server entries to allow built-in servers to be updated --- packages/core/util/mcp-config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/util/mcp-config.ts b/packages/core/util/mcp-config.ts index 081b27328..c27b519dc 100644 --- a/packages/core/util/mcp-config.ts +++ b/packages/core/util/mcp-config.ts @@ -80,7 +80,9 @@ export function addMcpServers( let modified = false; for (const [key, value] of Object.entries(servers)) { - if (!existing[key]) { + const isBuiltIn = key in IGNITEUI_MCP_SERVERS; + const needsUpdate = !existing[key] || isBuiltIn; + if (needsUpdate) { const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions }); text = jsonc.applyEdits(text, edits); modified = true; From 9b10ea6699555450fabd39010a5aca8acf461961 Mon Sep 17 00:00:00 2001 From: Marina Stoyanova Date: Fri, 29 May 2026 09:28:45 +0300 Subject: [PATCH 2/6] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- packages/core/util/mcp-config.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/util/mcp-config.ts b/packages/core/util/mcp-config.ts index c27b519dc..eaa0ab0a2 100644 --- a/packages/core/util/mcp-config.ts +++ b/packages/core/util/mcp-config.ts @@ -84,8 +84,11 @@ export function addMcpServers( const needsUpdate = !existing[key] || isBuiltIn; if (needsUpdate) { const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions }); - text = jsonc.applyEdits(text, edits); - modified = true; + const updatedText = jsonc.applyEdits(text, edits); + if (updatedText !== text) { + text = updatedText; + modified = true; + } } } From 3c4d5fe123df8c79ca8ef56ccbd551af07f4ff83 Mon Sep 17 00:00:00 2001 From: mstoyanova Date: Fri, 29 May 2026 09:48:43 +0300 Subject: [PATCH 3/6] fix: streamline MCP server update logic in addMcpServers function --- packages/core/util/mcp-config.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/core/util/mcp-config.ts b/packages/core/util/mcp-config.ts index eaa0ab0a2..9ca641c10 100644 --- a/packages/core/util/mcp-config.ts +++ b/packages/core/util/mcp-config.ts @@ -80,15 +80,10 @@ export function addMcpServers( let modified = false; for (const [key, value] of Object.entries(servers)) { - const isBuiltIn = key in IGNITEUI_MCP_SERVERS; - const needsUpdate = !existing[key] || isBuiltIn; - if (needsUpdate) { + if (!existing[key] || (key in IGNITEUI_MCP_SERVERS && JSON.stringify(existing[key]) !== JSON.stringify(value))) { const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions }); - const updatedText = jsonc.applyEdits(text, edits); - if (updatedText !== text) { - text = updatedText; - modified = true; - } + text = jsonc.applyEdits(text, edits); + modified = true; } } From 14ea4f429a8e1e478166c67a6efbd734d8ad354e Mon Sep 17 00:00:00 2001 From: mstoyanova Date: Fri, 29 May 2026 11:38:09 +0300 Subject: [PATCH 4/6] fix: update addMcpServers logic to ensure edits are applied only when necessary --- packages/core/util/mcp-config.ts | 8 +++++--- spec/unit/ai-config-spec.ts | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/core/util/mcp-config.ts b/packages/core/util/mcp-config.ts index 9ca641c10..69b42b067 100644 --- a/packages/core/util/mcp-config.ts +++ b/packages/core/util/mcp-config.ts @@ -80,10 +80,12 @@ export function addMcpServers( let modified = false; for (const [key, value] of Object.entries(servers)) { - if (!existing[key] || (key in IGNITEUI_MCP_SERVERS && JSON.stringify(existing[key]) !== JSON.stringify(value))) { + if (!existing[key] || key in IGNITEUI_MCP_SERVERS) { const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions }); - text = jsonc.applyEdits(text, edits); - modified = true; + if (edits.length) { + text = jsonc.applyEdits(text, edits); + modified = true; + } } } diff --git a/spec/unit/ai-config-spec.ts b/spec/unit/ai-config-spec.ts index 3bb146ffe..bbf9344df 100644 --- a/spec/unit/ai-config-spec.ts +++ b/spec/unit/ai-config-spec.ts @@ -104,19 +104,19 @@ describe("Unit - ai-config command", () => { expect((config.servers as any)[IGNITEUI_THEMING_SERVER_KEY]).toEqual(igniteuiThemingServer); }); - it("is a no-op and logs when both servers are already configured", () => { + it("rewrites when both servers are already configured", () => { const mockFs = createMockFs(JSON.stringify({ servers: { [IGNITEUI_SERVER_KEY]: igniteuiServer, [IGNITEUI_THEMING_SERVER_KEY]: igniteuiThemingServer } - })); + }, null, 2)); App.container.set(FS_TOKEN, mockFs); configureMCP(["vscode"]); - expect(mockFs.writeFile).not.toHaveBeenCalled(); - expect(Util.log).toHaveBeenCalledWith(jasmine.stringContaining("already configured")); + expect(mockFs.writeFile).toHaveBeenCalled(); + expect(Util.log).toHaveBeenCalledWith(jasmine.stringContaining("MCP servers configured")); }); it("preserves existing third-party servers when adding igniteui servers", () => { From 944806180c76906823f8c7bb377de61cbe86f54f Mon Sep 17 00:00:00 2001 From: mstoyanova Date: Fri, 29 May 2026 12:21:36 +0300 Subject: [PATCH 5/6] fix: simplify logic in addMcpServers to apply edits unconditionally --- packages/core/util/mcp-config.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/core/util/mcp-config.ts b/packages/core/util/mcp-config.ts index 69b42b067..99b77ff6e 100644 --- a/packages/core/util/mcp-config.ts +++ b/packages/core/util/mcp-config.ts @@ -80,12 +80,10 @@ export function addMcpServers( let modified = false; for (const [key, value] of Object.entries(servers)) { - if (!existing[key] || key in IGNITEUI_MCP_SERVERS) { - const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions }); - if (edits.length) { - text = jsonc.applyEdits(text, edits); - modified = true; - } + const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions }); + if (edits.length) { + text = jsonc.applyEdits(text, edits); + modified = true; } } From 50c57b349d3237f7b16dbf674ac53c5c8e926604 Mon Sep 17 00:00:00 2001 From: mstoyanova Date: Fri, 29 May 2026 15:50:55 +0300 Subject: [PATCH 6/6] fix: improve addMcpServers logic to handle no-op cases and update outdated configurations --- packages/core/util/mcp-config.ts | 5 +++-- spec/unit/ai-config-spec.ts | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/core/util/mcp-config.ts b/packages/core/util/mcp-config.ts index 99b77ff6e..f380856c3 100644 --- a/packages/core/util/mcp-config.ts +++ b/packages/core/util/mcp-config.ts @@ -81,8 +81,9 @@ export function addMcpServers( for (const [key, value] of Object.entries(servers)) { const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions }); - if (edits.length) { - text = jsonc.applyEdits(text, edits); + const newText = jsonc.applyEdits(text, edits); + if (newText !== text) { + text = newText; modified = true; } } diff --git a/spec/unit/ai-config-spec.ts b/spec/unit/ai-config-spec.ts index bbf9344df..20db6b95d 100644 --- a/spec/unit/ai-config-spec.ts +++ b/spec/unit/ai-config-spec.ts @@ -3,6 +3,7 @@ import { App, Config, FS_TOKEN, FsFileSystem, GoogleAnalytics, IFileSystem, Inqu import * as coreDetect from "../../packages/core/util/detect-framework"; import { configureMCP, configureSkills } from "../../packages/cli/lib/commands/ai-config"; import * as aiConfig from "../../packages/cli/lib/commands/ai-config"; +import { addMcpServers } from "../../packages/core/util/mcp-config"; const IGNITEUI_SERVER_KEY = "igniteui-cli"; const IGNITEUI_THEMING_SERVER_KEY = "igniteui-theming"; @@ -104,7 +105,7 @@ describe("Unit - ai-config command", () => { expect((config.servers as any)[IGNITEUI_THEMING_SERVER_KEY]).toEqual(igniteuiThemingServer); }); - it("rewrites when both servers are already configured", () => { + it("is a no-op when both servers are already configured", () => { const mockFs = createMockFs(JSON.stringify({ servers: { [IGNITEUI_SERVER_KEY]: igniteuiServer, @@ -113,10 +114,28 @@ describe("Unit - ai-config command", () => { }, null, 2)); App.container.set(FS_TOKEN, mockFs); - configureMCP(["vscode"]); + const result = addMcpServers("vscode"); + + expect(result).toBe(false); + expect(mockFs.writeFile).not.toHaveBeenCalled(); + }); + + it("updates config when server configuration is outdated", () => { + const mockFs = createMockFs(JSON.stringify({ + servers: { + [IGNITEUI_SERVER_KEY]: { command: "npx", args: ["-y", "igniteui-cli", "old-command"] }, + [IGNITEUI_THEMING_SERVER_KEY]: igniteuiThemingServer + } + }, null, 2)); + App.container.set(FS_TOKEN, mockFs); + + const result = addMcpServers("vscode"); + expect(result).toBe(true); expect(mockFs.writeFile).toHaveBeenCalled(); - expect(Util.log).toHaveBeenCalledWith(jasmine.stringContaining("MCP servers configured")); + const config = writtenConfig(mockFs); + expect((config.servers as any)[IGNITEUI_SERVER_KEY]).toEqual(igniteuiServer); + expect((config.servers as any)[IGNITEUI_THEMING_SERVER_KEY]).toEqual(igniteuiThemingServer); }); it("preserves existing third-party servers when adding igniteui servers", () => {