Skip to content

Commit 6491b3b

Browse files
Merge pull request #1709 from IgniteUI/mstoyanova/ai-config-mcp-config-update
fix: update MCP server entries to allow built-in servers to be updated
1 parent 55820e1 commit 6491b3b

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

packages/core/util/mcp-config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ export function addMcpServers(
8080
let modified = false;
8181

8282
for (const [key, value] of Object.entries(servers)) {
83-
if (!existing[key]) {
84-
const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions });
85-
text = jsonc.applyEdits(text, edits);
83+
const edits = jsonc.modify(text, [rootKey, key], value, { formattingOptions });
84+
const newText = jsonc.applyEdits(text, edits);
85+
if (newText !== text) {
86+
text = newText;
8687
modified = true;
8788
}
8889
}

spec/unit/ai-config-spec.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { App, Config, FS_TOKEN, FsFileSystem, GoogleAnalytics, IFileSystem, Inqu
33
import * as coreDetect from "../../packages/core/util/detect-framework";
44
import { configureMCP, configureSkills } from "../../packages/cli/lib/commands/ai-config";
55
import * as aiConfig from "../../packages/cli/lib/commands/ai-config";
6+
import { addMcpServers } from "../../packages/core/util/mcp-config";
67

78
const IGNITEUI_SERVER_KEY = "igniteui-cli";
89
const IGNITEUI_THEMING_SERVER_KEY = "igniteui-theming";
@@ -104,19 +105,37 @@ describe("Unit - ai-config command", () => {
104105
expect((config.servers as any)[IGNITEUI_THEMING_SERVER_KEY]).toEqual(igniteuiThemingServer);
105106
});
106107

107-
it("is a no-op and logs when both servers are already configured", () => {
108+
it("is a no-op when both servers are already configured", () => {
108109
const mockFs = createMockFs(JSON.stringify({
109110
servers: {
110111
[IGNITEUI_SERVER_KEY]: igniteuiServer,
111112
[IGNITEUI_THEMING_SERVER_KEY]: igniteuiThemingServer
112113
}
113-
}));
114+
}, null, 2));
114115
App.container.set(FS_TOKEN, mockFs);
115116

116-
configureMCP(["vscode"]);
117+
const result = addMcpServers("vscode");
117118

119+
expect(result).toBe(false);
118120
expect(mockFs.writeFile).not.toHaveBeenCalled();
119-
expect(Util.log).toHaveBeenCalledWith(jasmine.stringContaining("already configured"));
121+
});
122+
123+
it("updates config when server configuration is outdated", () => {
124+
const mockFs = createMockFs(JSON.stringify({
125+
servers: {
126+
[IGNITEUI_SERVER_KEY]: { command: "npx", args: ["-y", "igniteui-cli", "old-command"] },
127+
[IGNITEUI_THEMING_SERVER_KEY]: igniteuiThemingServer
128+
}
129+
}, null, 2));
130+
App.container.set(FS_TOKEN, mockFs);
131+
132+
const result = addMcpServers("vscode");
133+
134+
expect(result).toBe(true);
135+
expect(mockFs.writeFile).toHaveBeenCalled();
136+
const config = writtenConfig(mockFs);
137+
expect((config.servers as any)[IGNITEUI_SERVER_KEY]).toEqual(igniteuiServer);
138+
expect((config.servers as any)[IGNITEUI_THEMING_SERVER_KEY]).toEqual(igniteuiThemingServer);
120139
});
121140

122141
it("preserves existing third-party servers when adding igniteui servers", () => {

0 commit comments

Comments
 (0)