@theia/ai-mcp 1.72.0-next.5 → 1.72.0-next.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/mcp-frontend-application-contribution.d.ts +1 -1
- package/lib/browser/mcp-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/mcp-frontend-application-contribution.js +3 -2
- package/lib/browser/mcp-frontend-application-contribution.js.map +1 -1
- package/lib/browser/mcp-frontend-application-contribution.spec.d.ts +2 -0
- package/lib/browser/mcp-frontend-application-contribution.spec.d.ts.map +1 -0
- package/lib/browser/mcp-frontend-application-contribution.spec.js +178 -0
- package/lib/browser/mcp-frontend-application-contribution.spec.js.map +1 -0
- package/package.json +5 -5
- package/src/browser/mcp-frontend-application-contribution.spec.ts +252 -0
- package/src/browser/mcp-frontend-application-contribution.ts +3 -2
- package/lib/package.spec.d.ts +0 -1
- package/lib/package.spec.d.ts.map +0 -1
- package/lib/package.spec.js +0 -26
- package/lib/package.spec.js.map +0 -1
- package/src/package.spec.ts +0 -28
|
@@ -44,7 +44,7 @@ export declare class McpFrontendApplicationContribution implements FrontendAppli
|
|
|
44
44
|
protected updateBlockedServersStatusBar(): void;
|
|
45
45
|
getRestrictions(): WorkspaceRestriction[];
|
|
46
46
|
protected autoStartServers(servers: Map<string, MCPServerDescription>): Promise<void>;
|
|
47
|
-
protected handleServerChanges(newServers: MCPServersPreference): void
|
|
47
|
+
protected handleServerChanges(newServers: MCPServersPreference): Promise<void>;
|
|
48
48
|
protected syncServers(servers: Map<string, MCPServerDescription>): void;
|
|
49
49
|
protected convertToMap(servers: MCPServersPreference): Map<string, MCPServerDescription>;
|
|
50
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC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AAC;IAGjD,SAAS,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAGvD,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAE7C,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAa;IAErE,SAAS,CAAC,uBAAuB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAE3D,OAAO,IAAI,IAAI;cAyCC,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;cA6BrD,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC;cAe9C,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAY/C,SAAS,CAAC,6BAA6B,IAAI,IAAI;IAI/C,eAAe,IAAI,oBAAoB,EAAE;cAUzB,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAmB,MAAM,aAAa,CAAC;AAEjE,OAAO,EACH,qBAAqB,EACrB,gCAAgC,EAChC,oBAAoB,EACvB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAElF,UAAU,4BAA4B;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,6BAA8B,SAAQ,4BAA4B;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE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eAAe,IAAI,oBAAoB,EAAE;cAUzB,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;cAqB3E,mBAAmB,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCpF,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,IAAI;IAavE,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC;CAgC3F"}
|
|
@@ -72,7 +72,7 @@ let McpFrontendApplicationContribution = class McpFrontendApplicationContributio
|
|
|
72
72
|
await this.autoStartServers(this.prevServers);
|
|
73
73
|
this.preferenceService.onPreferenceChanged(async (event) => {
|
|
74
74
|
if (event.preferenceName === mcp_preferences_1.MCP_SERVERS_PREF) {
|
|
75
|
-
this.handleServerChanges(filterValidValues(this.preferenceService.get(mcp_preferences_1.MCP_SERVERS_PREF, {})));
|
|
75
|
+
await this.handleServerChanges(filterValidValues(this.preferenceService.get(mcp_preferences_1.MCP_SERVERS_PREF, {})));
|
|
76
76
|
}
|
|
77
77
|
if (event.preferenceName === mcp_preferences_1.MCP_USE_WORKSPACE_AS_ROOT_PREF) {
|
|
78
78
|
await this.updateWorkspaceRoots(true);
|
|
@@ -175,11 +175,12 @@ let McpFrontendApplicationContribution = class McpFrontendApplicationContributio
|
|
|
175
175
|
}
|
|
176
176
|
this.updateBlockedServersStatusBar();
|
|
177
177
|
}
|
|
178
|
-
handleServerChanges(newServers) {
|
|
178
|
+
async handleServerChanges(newServers) {
|
|
179
179
|
const oldServers = this.prevServers;
|
|
180
180
|
const updatedServers = this.convertToMap(newServers);
|
|
181
181
|
for (const [name] of oldServers) {
|
|
182
182
|
if (!updatedServers.has(name)) {
|
|
183
|
+
await this.frontendMCPService.stopServer(name);
|
|
183
184
|
this.manager.removeServer(name);
|
|
184
185
|
this.blockedUntrustedServers.delete(name);
|
|
185
186
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/mcp-frontend-application-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAGhF,4DAAkE;AAClE,sCAAmE;AACnE,+DAA6F;AAC7F,qEAAkE;AAElE,sCAAiE;AACjE,oDAAiD;AACjD,kGAI8D;AAC9D,sFAAkF;AAuBjF,CAAC;AAEF,IAAU,oBAAoB,CAa7B;AAbD,WAAU,oBAAoB;IAC1B,SAAgB,OAAO,CAAC,GAAY;QAChC,OAAO,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YACnC,CAAC,SAAS,IAAI,GAAG,IAAI,WAAW,IAAI,GAAG,CAAC;YACxC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC;YACxD,CAAC,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC;YAC/F,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK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CAAC;QACzB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAGM,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAAxC;QAiBO,gBAAW,GAAsC,IAAI,GAAG,EAAE,CAAC;QAE3D,4BAAuB,GAAgB,IAAI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/mcp-frontend-application-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAGhF,4DAAkE;AAClE,sCAAmE;AACnE,+DAA6F;AAC7F,qEAAkE;AAElE,sCAAiE;AACjE,oDAAiD;AACjD,kGAI8D;AAC9D,sFAAkF;AAuBjF,CAAC;AAEF,IAAU,oBAAoB,CAa7B;AAbD,WAAU,oBAAoB;IAC1B,SAAgB,OAAO,CAAC,GAAY;QAChC,OAAO,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YACnC,CAAC,SAAS,IAAI,GAAG,IAAI,WAAW,IAAI,GAAG,CAAC;YACxC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC;YACxD,CAAC,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC;YAC/F,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,GA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eAAe,IAAI,EAAE,eAAe,EAAE,CAAC;oBAC3C,GAAG,CAAC,qBAAqB,IAAI,EAAE,qBAAqB,EAAE,CAAC;oBACvD,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC;oBAC3B,SAAS,EAAE,SAAS,IAAI,IAAI;iBAC/B,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,6EAA6E;gBAC7E,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,WAAW,CAAC;gBACtD,mBAAmB,GAAG;oBAClB,IAAI;oBACJ,OAAO;oBACP,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;oBACrB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC;oBACnB,SAAS,EAAE,SAAS,IAAI,IAAI;iBAC/B,CAAC;YACN,CAAC;YAED,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AA3OY,gFAAkC;AAGjC;IADT,IAAA,kBAAM,EAAC,wBAAiB,CAAC;;6EACqB;AAGrC;IADT,IAAA,kBAAM,EAAC,yBAAgB,CAAC;;mEACW;AAG1B;IADT,IAAA,kBAAM,EAAC,uCAAkB,CAAC;;8EACsB;AAGvC;IADT,IAAA,kBAAM,EAAC,+CAAqB,CAAC;sCACG,+CAAqB;iFAAC;AAG7C;IADT,IAAA,kBAAM,EAAC,oCAAgB,CAAC;sCACG,oCAAgB;4EAAC;6CAfpC,kCAAkC;IAD9C,IAAA,sBAAU,GAAE;GACA,kCAAkC,CA2O9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-frontend-application-contribution.spec.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-frontend-application-contribution.spec.ts"],"names":[],"mappings":"AAqBA,OAAO,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
|
|
19
|
+
let disableJSDOM = (0, jsdom_1.enableJSDOM)();
|
|
20
|
+
const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
|
|
21
|
+
frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
|
|
22
|
+
require("reflect-metadata");
|
|
23
|
+
const chai_1 = require("chai");
|
|
24
|
+
const sinon = require("sinon");
|
|
25
|
+
const inversify_1 = require("inversify");
|
|
26
|
+
const core_1 = require("@theia/core");
|
|
27
|
+
const mcp_frontend_application_contribution_1 = require("./mcp-frontend-application-contribution");
|
|
28
|
+
const common_1 = require("../common");
|
|
29
|
+
const mcp_server_manager_1 = require("../common/mcp-server-manager");
|
|
30
|
+
const workspace_trust_service_1 = require("@theia/workspace/lib/browser/workspace-trust-service");
|
|
31
|
+
const workspace_service_1 = require("@theia/workspace/lib/browser/workspace-service");
|
|
32
|
+
disableJSDOM();
|
|
33
|
+
describe('McpFrontendApplicationContribution', () => {
|
|
34
|
+
before(() => disableJSDOM = (0, jsdom_1.enableJSDOM)());
|
|
35
|
+
after(() => disableJSDOM());
|
|
36
|
+
let contribution;
|
|
37
|
+
let mockFrontendMCPService;
|
|
38
|
+
let mockManager;
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
const container = new inversify_1.Container();
|
|
41
|
+
mockFrontendMCPService = {
|
|
42
|
+
startServer: sinon.stub().resolves(),
|
|
43
|
+
stopServer: sinon.stub().resolves(),
|
|
44
|
+
hasServer: sinon.stub().resolves(false),
|
|
45
|
+
isServerStarted: sinon.stub().resolves(false),
|
|
46
|
+
registerToolsForAllStartedServers: sinon.stub().resolves(),
|
|
47
|
+
addOrUpdateServer: sinon.stub().resolves(),
|
|
48
|
+
getStartedServers: sinon.stub().resolves([]),
|
|
49
|
+
getServerNames: sinon.stub().resolves([]),
|
|
50
|
+
getServerDescription: sinon.stub().resolves(undefined),
|
|
51
|
+
getTools: sinon.stub().resolves(undefined),
|
|
52
|
+
getPromptTemplateId: sinon.stub().returns(''),
|
|
53
|
+
};
|
|
54
|
+
mockManager = {
|
|
55
|
+
callTool: sinon.stub().resolves({ content: [] }),
|
|
56
|
+
removeServer: sinon.stub(),
|
|
57
|
+
addOrUpdateServer: sinon.stub(),
|
|
58
|
+
getTools: sinon.stub().resolves({ tools: [] }),
|
|
59
|
+
getServerNames: sinon.stub().resolves([]),
|
|
60
|
+
getServerDescription: sinon.stub().resolves(undefined),
|
|
61
|
+
startServer: sinon.stub().resolves(),
|
|
62
|
+
stopServer: sinon.stub().resolves(),
|
|
63
|
+
getRunningServers: sinon.stub().resolves([]),
|
|
64
|
+
setClient: sinon.stub(),
|
|
65
|
+
disconnectClient: sinon.stub(),
|
|
66
|
+
readResource: sinon.stub().resolves({ contents: [] }),
|
|
67
|
+
getResources: sinon.stub().resolves({ resources: [] }),
|
|
68
|
+
setWorkspaceRoots: sinon.stub(),
|
|
69
|
+
};
|
|
70
|
+
const mockPreferenceService = {
|
|
71
|
+
ready: Promise.resolve(),
|
|
72
|
+
get: sinon.stub().returns({}),
|
|
73
|
+
onPreferenceChanged: sinon.stub().returns({ dispose: () => { } }),
|
|
74
|
+
};
|
|
75
|
+
const mockWorkspaceTrustService = {
|
|
76
|
+
getWorkspaceTrust: sinon.stub().resolves(true),
|
|
77
|
+
onDidChangeWorkspaceTrust: sinon.stub().returns({ dispose: () => { } }),
|
|
78
|
+
refreshRestrictedModeIndicator: sinon.stub(),
|
|
79
|
+
};
|
|
80
|
+
const mockWorkspaceService = {
|
|
81
|
+
tryGetRoots: sinon.stub().returns([]),
|
|
82
|
+
onWorkspaceChanged: sinon.stub().returns({ dispose: () => { } }),
|
|
83
|
+
};
|
|
84
|
+
container.bind(mcp_frontend_application_contribution_1.McpFrontendApplicationContribution).toSelf().inSingletonScope();
|
|
85
|
+
container.bind(core_1.PreferenceService).toConstantValue(mockPreferenceService);
|
|
86
|
+
container.bind(common_1.MCPServerManager).toConstantValue(mockManager);
|
|
87
|
+
container.bind(mcp_server_manager_1.MCPFrontendService).toConstantValue(mockFrontendMCPService);
|
|
88
|
+
container.bind(workspace_trust_service_1.WorkspaceTrustService).toConstantValue(mockWorkspaceTrustService);
|
|
89
|
+
container.bind(workspace_service_1.WorkspaceService).toConstantValue(mockWorkspaceService);
|
|
90
|
+
contribution = container.get(mcp_frontend_application_contribution_1.McpFrontendApplicationContribution);
|
|
91
|
+
});
|
|
92
|
+
afterEach(() => {
|
|
93
|
+
sinon.restore();
|
|
94
|
+
});
|
|
95
|
+
describe('handleServerChanges', () => {
|
|
96
|
+
it('calls stopServer before removeServer when a server is removed', async () => {
|
|
97
|
+
const callOrder = [];
|
|
98
|
+
mockFrontendMCPService.stopServer.callsFake(async () => { callOrder.push('stopServer'); });
|
|
99
|
+
mockManager.removeServer.callsFake(() => { callOrder.push('removeServer'); });
|
|
100
|
+
contribution.prevServers = new Map([
|
|
101
|
+
['test-server', { name: 'test-server', command: 'node', args: ['server.js'], autostart: true }]
|
|
102
|
+
]);
|
|
103
|
+
await contribution.handleServerChanges({});
|
|
104
|
+
(0, chai_1.expect)(mockFrontendMCPService.stopServer.calledOnce).to.be.true;
|
|
105
|
+
(0, chai_1.expect)(mockFrontendMCPService.stopServer.calledWith('test-server')).to.be.true;
|
|
106
|
+
(0, chai_1.expect)(mockManager.removeServer.calledOnce).to.be.true;
|
|
107
|
+
(0, chai_1.expect)(mockManager.removeServer.calledWith('test-server')).to.be.true;
|
|
108
|
+
(0, chai_1.expect)(callOrder).to.deep.equal(['stopServer', 'removeServer']);
|
|
109
|
+
});
|
|
110
|
+
it('calls stopServer and removeServer for each removed server', async () => {
|
|
111
|
+
contribution.prevServers = new Map([
|
|
112
|
+
['server-a', { name: 'server-a', command: 'node', args: ['a.js'], autostart: false }],
|
|
113
|
+
['server-b', { name: 'server-b', serverUrl: 'http://example.com', autostart: false }],
|
|
114
|
+
['server-c', { name: 'server-c', command: 'node', args: ['c.js'], autostart: false }]
|
|
115
|
+
]);
|
|
116
|
+
// Only server-b remains
|
|
117
|
+
await contribution.handleServerChanges({
|
|
118
|
+
'server-b': { serverUrl: 'http://example.com' }
|
|
119
|
+
});
|
|
120
|
+
(0, chai_1.expect)(mockFrontendMCPService.stopServer.calledWith('server-a')).to.be.true;
|
|
121
|
+
(0, chai_1.expect)(mockFrontendMCPService.stopServer.calledWith('server-c')).to.be.true;
|
|
122
|
+
(0, chai_1.expect)(mockFrontendMCPService.stopServer.calledWith('server-b')).to.be.false;
|
|
123
|
+
(0, chai_1.expect)(mockManager.removeServer.calledWith('server-a')).to.be.true;
|
|
124
|
+
(0, chai_1.expect)(mockManager.removeServer.calledWith('server-c')).to.be.true;
|
|
125
|
+
(0, chai_1.expect)(mockManager.removeServer.calledWith('server-b')).to.be.false;
|
|
126
|
+
});
|
|
127
|
+
it('does not call stopServer or removeServer when no servers are removed', async () => {
|
|
128
|
+
contribution.prevServers = new Map([
|
|
129
|
+
['existing-server', { name: 'existing-server', command: 'node', autostart: true }]
|
|
130
|
+
]);
|
|
131
|
+
await contribution.handleServerChanges({
|
|
132
|
+
'existing-server': { command: 'node' }
|
|
133
|
+
});
|
|
134
|
+
(0, chai_1.expect)(mockFrontendMCPService.stopServer.called).to.be.false;
|
|
135
|
+
(0, chai_1.expect)(mockManager.removeServer.called).to.be.false;
|
|
136
|
+
});
|
|
137
|
+
it('calls addOrUpdateServer for new servers', async () => {
|
|
138
|
+
contribution.prevServers = new Map();
|
|
139
|
+
await contribution.handleServerChanges({
|
|
140
|
+
'new-server': { command: 'node', args: ['server.js'] }
|
|
141
|
+
});
|
|
142
|
+
(0, chai_1.expect)(mockManager.addOrUpdateServer.calledOnce).to.be.true;
|
|
143
|
+
const addedServer = mockManager.addOrUpdateServer.firstCall.args[0];
|
|
144
|
+
(0, chai_1.expect)(addedServer.name).to.equal('new-server');
|
|
145
|
+
});
|
|
146
|
+
it('calls addOrUpdateServer for updated servers', async () => {
|
|
147
|
+
contribution.prevServers = new Map([
|
|
148
|
+
['my-server', { name: 'my-server', command: 'node', args: ['old.js'], autostart: true }]
|
|
149
|
+
]);
|
|
150
|
+
await contribution.handleServerChanges({
|
|
151
|
+
'my-server': { command: 'node', args: ['new.js'] }
|
|
152
|
+
});
|
|
153
|
+
(0, chai_1.expect)(mockFrontendMCPService.stopServer.called).to.be.false;
|
|
154
|
+
(0, chai_1.expect)(mockManager.removeServer.called).to.be.false;
|
|
155
|
+
(0, chai_1.expect)(mockManager.addOrUpdateServer.calledOnce).to.be.true;
|
|
156
|
+
});
|
|
157
|
+
it('clears blockedUntrustedServers entry when a server is removed', async () => {
|
|
158
|
+
contribution.prevServers = new Map([
|
|
159
|
+
['blocked-server', { name: 'blocked-server', command: 'node', autostart: true }]
|
|
160
|
+
]);
|
|
161
|
+
// Simulate the server having been blocked
|
|
162
|
+
contribution.blockedUntrustedServers.add('blocked-server');
|
|
163
|
+
await contribution.handleServerChanges({});
|
|
164
|
+
(0, chai_1.expect)(contribution.blockedUntrustedServers.has('blocked-server')).to.be.false;
|
|
165
|
+
});
|
|
166
|
+
it('updates prevServers after handling changes', async () => {
|
|
167
|
+
contribution.prevServers = new Map([
|
|
168
|
+
['old-server', { name: 'old-server', command: 'node', autostart: true }]
|
|
169
|
+
]);
|
|
170
|
+
await contribution.handleServerChanges({
|
|
171
|
+
'new-server': { command: 'python', args: ['serve.py'] }
|
|
172
|
+
});
|
|
173
|
+
(0, chai_1.expect)(contribution.prevServers.has('old-server')).to.be.false;
|
|
174
|
+
(0, chai_1.expect)(contribution.prevServers.has('new-server')).to.be.true;
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
//# sourceMappingURL=mcp-frontend-application-contribution.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-frontend-application-contribution.spec.js","sourceRoot":"","sources":["../../src/browser/mcp-frontend-application-contribution.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,8DAAiE;AACjE,IAAI,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC;AACjC,uHAAiH;AACjH,wEAAiC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAE1C,4BAA0B;AAE1B,+BAA8B;AAC9B,+BAA+B;AAC/B,yCAAsC;AACtC,sCAAgD;AAChD,mGAA6F;AAC7F,sCAAmE;AACnE,qEAAkE;AAClE,kGAA6F;AAC7F,sFAAkF;AAElF,YAAY,EAAE,CAAC;AAwCf,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAChD,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC,CAAC;IAC3C,KAAK,CAAC,GAAG,EAAE,CA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gBAC/B,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;aAC3E,CAAC,CAAC;YAEH,MAAM,YAAY,CAAC,mBAAmB,CAAC;gBACnC,YAAY,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE;aAC1D,CAAC,CAAC;YAEH,IAAA,aAAM,EAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAC/D,IAAA,aAAM,EAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAClE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-mcp",
|
|
3
|
-
"version": "1.72.0-next.
|
|
3
|
+
"version": "1.72.0-next.50+f26609f54",
|
|
4
4
|
"description": "Theia - MCP Integration",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
7
|
-
"@theia/ai-core": "1.72.0-next.
|
|
8
|
-
"@theia/core": "1.72.0-next.
|
|
9
|
-
"@theia/workspace": "1.72.0-next.
|
|
7
|
+
"@theia/ai-core": "1.72.0-next.50+f26609f54",
|
|
8
|
+
"@theia/core": "1.72.0-next.50+f26609f54",
|
|
9
|
+
"@theia/workspace": "1.72.0-next.50+f26609f54"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"nyc": {
|
|
49
49
|
"extends": "../../configs/nyc.json"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f26609f5411c7101a4b2f540584b8163a6036131"
|
|
52
52
|
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
|
|
18
|
+
let disableJSDOM = enableJSDOM();
|
|
19
|
+
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
20
|
+
FrontendApplicationConfigProvider.set({});
|
|
21
|
+
|
|
22
|
+
import 'reflect-metadata';
|
|
23
|
+
|
|
24
|
+
import { expect } from 'chai';
|
|
25
|
+
import * as sinon from 'sinon';
|
|
26
|
+
import { Container } from 'inversify';
|
|
27
|
+
import { PreferenceService } from '@theia/core';
|
|
28
|
+
import { McpFrontendApplicationContribution } from './mcp-frontend-application-contribution';
|
|
29
|
+
import { MCPServerDescription, MCPServerManager } from '../common';
|
|
30
|
+
import { MCPFrontendService } from '../common/mcp-server-manager';
|
|
31
|
+
import { WorkspaceTrustService } from '@theia/workspace/lib/browser/workspace-trust-service';
|
|
32
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
|
33
|
+
|
|
34
|
+
disableJSDOM();
|
|
35
|
+
|
|
36
|
+
type TestableContribution = McpFrontendApplicationContribution & {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
handleServerChanges(newServers: any): Promise<void>;
|
|
39
|
+
prevServers: Map<string, MCPServerDescription>;
|
|
40
|
+
blockedUntrustedServers: Set<string>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
interface MockFrontendMCPService {
|
|
44
|
+
startServer: sinon.SinonStub;
|
|
45
|
+
stopServer: sinon.SinonStub;
|
|
46
|
+
hasServer: sinon.SinonStub;
|
|
47
|
+
isServerStarted: sinon.SinonStub;
|
|
48
|
+
registerToolsForAllStartedServers: sinon.SinonStub;
|
|
49
|
+
addOrUpdateServer: sinon.SinonStub;
|
|
50
|
+
getStartedServers: sinon.SinonStub;
|
|
51
|
+
getServerNames: sinon.SinonStub;
|
|
52
|
+
getServerDescription: sinon.SinonStub;
|
|
53
|
+
getTools: sinon.SinonStub;
|
|
54
|
+
getPromptTemplateId: sinon.SinonStub;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface MockMCPServerManager {
|
|
58
|
+
callTool: sinon.SinonStub;
|
|
59
|
+
removeServer: sinon.SinonStub;
|
|
60
|
+
addOrUpdateServer: sinon.SinonStub;
|
|
61
|
+
getTools: sinon.SinonStub;
|
|
62
|
+
getServerNames: sinon.SinonStub;
|
|
63
|
+
getServerDescription: sinon.SinonStub;
|
|
64
|
+
startServer: sinon.SinonStub;
|
|
65
|
+
stopServer: sinon.SinonStub;
|
|
66
|
+
getRunningServers: sinon.SinonStub;
|
|
67
|
+
setClient: sinon.SinonStub;
|
|
68
|
+
disconnectClient: sinon.SinonStub;
|
|
69
|
+
readResource: sinon.SinonStub;
|
|
70
|
+
getResources: sinon.SinonStub;
|
|
71
|
+
setWorkspaceRoots: sinon.SinonStub;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
describe('McpFrontendApplicationContribution', () => {
|
|
75
|
+
before(() => disableJSDOM = enableJSDOM());
|
|
76
|
+
after(() => disableJSDOM());
|
|
77
|
+
|
|
78
|
+
let contribution: TestableContribution;
|
|
79
|
+
let mockFrontendMCPService: MockFrontendMCPService;
|
|
80
|
+
let mockManager: MockMCPServerManager;
|
|
81
|
+
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
const container = new Container();
|
|
84
|
+
|
|
85
|
+
mockFrontendMCPService = {
|
|
86
|
+
startServer: sinon.stub().resolves(),
|
|
87
|
+
stopServer: sinon.stub().resolves(),
|
|
88
|
+
hasServer: sinon.stub().resolves(false),
|
|
89
|
+
isServerStarted: sinon.stub().resolves(false),
|
|
90
|
+
registerToolsForAllStartedServers: sinon.stub().resolves(),
|
|
91
|
+
addOrUpdateServer: sinon.stub().resolves(),
|
|
92
|
+
getStartedServers: sinon.stub().resolves([]),
|
|
93
|
+
getServerNames: sinon.stub().resolves([]),
|
|
94
|
+
getServerDescription: sinon.stub().resolves(undefined),
|
|
95
|
+
getTools: sinon.stub().resolves(undefined),
|
|
96
|
+
getPromptTemplateId: sinon.stub().returns(''),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
mockManager = {
|
|
100
|
+
callTool: sinon.stub().resolves({ content: [] }),
|
|
101
|
+
removeServer: sinon.stub(),
|
|
102
|
+
addOrUpdateServer: sinon.stub(),
|
|
103
|
+
getTools: sinon.stub().resolves({ tools: [] }),
|
|
104
|
+
getServerNames: sinon.stub().resolves([]),
|
|
105
|
+
getServerDescription: sinon.stub().resolves(undefined),
|
|
106
|
+
startServer: sinon.stub().resolves(),
|
|
107
|
+
stopServer: sinon.stub().resolves(),
|
|
108
|
+
getRunningServers: sinon.stub().resolves([]),
|
|
109
|
+
setClient: sinon.stub(),
|
|
110
|
+
disconnectClient: sinon.stub(),
|
|
111
|
+
readResource: sinon.stub().resolves({ contents: [] }),
|
|
112
|
+
getResources: sinon.stub().resolves({ resources: [] }),
|
|
113
|
+
setWorkspaceRoots: sinon.stub(),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const mockPreferenceService = {
|
|
117
|
+
ready: Promise.resolve(),
|
|
118
|
+
get: sinon.stub().returns({}),
|
|
119
|
+
onPreferenceChanged: sinon.stub().returns({ dispose: () => { } }),
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const mockWorkspaceTrustService = {
|
|
123
|
+
getWorkspaceTrust: sinon.stub().resolves(true),
|
|
124
|
+
onDidChangeWorkspaceTrust: sinon.stub().returns({ dispose: () => { } }),
|
|
125
|
+
refreshRestrictedModeIndicator: sinon.stub(),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const mockWorkspaceService = {
|
|
129
|
+
tryGetRoots: sinon.stub().returns([]),
|
|
130
|
+
onWorkspaceChanged: sinon.stub().returns({ dispose: () => { } }),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
container.bind(McpFrontendApplicationContribution).toSelf().inSingletonScope();
|
|
134
|
+
container.bind(PreferenceService).toConstantValue(mockPreferenceService as unknown as PreferenceService);
|
|
135
|
+
container.bind(MCPServerManager).toConstantValue(mockManager as unknown as MCPServerManager);
|
|
136
|
+
container.bind(MCPFrontendService).toConstantValue(mockFrontendMCPService as unknown as MCPFrontendService);
|
|
137
|
+
container.bind(WorkspaceTrustService).toConstantValue(mockWorkspaceTrustService as unknown as WorkspaceTrustService);
|
|
138
|
+
container.bind(WorkspaceService).toConstantValue(mockWorkspaceService as unknown as WorkspaceService);
|
|
139
|
+
|
|
140
|
+
contribution = container.get<McpFrontendApplicationContribution>(McpFrontendApplicationContribution) as TestableContribution;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
afterEach(() => {
|
|
144
|
+
sinon.restore();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('handleServerChanges', () => {
|
|
148
|
+
|
|
149
|
+
it('calls stopServer before removeServer when a server is removed', async () => {
|
|
150
|
+
const callOrder: string[] = [];
|
|
151
|
+
mockFrontendMCPService.stopServer.callsFake(async () => { callOrder.push('stopServer'); });
|
|
152
|
+
mockManager.removeServer.callsFake(() => { callOrder.push('removeServer'); });
|
|
153
|
+
|
|
154
|
+
contribution.prevServers = new Map([
|
|
155
|
+
['test-server', { name: 'test-server', command: 'node', args: ['server.js'], autostart: true }]
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
await contribution.handleServerChanges({});
|
|
159
|
+
|
|
160
|
+
expect(mockFrontendMCPService.stopServer.calledOnce).to.be.true;
|
|
161
|
+
expect(mockFrontendMCPService.stopServer.calledWith('test-server')).to.be.true;
|
|
162
|
+
expect(mockManager.removeServer.calledOnce).to.be.true;
|
|
163
|
+
expect(mockManager.removeServer.calledWith('test-server')).to.be.true;
|
|
164
|
+
expect(callOrder).to.deep.equal(['stopServer', 'removeServer']);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('calls stopServer and removeServer for each removed server', async () => {
|
|
168
|
+
contribution.prevServers = new Map([
|
|
169
|
+
['server-a', { name: 'server-a', command: 'node', args: ['a.js'], autostart: false }],
|
|
170
|
+
['server-b', { name: 'server-b', serverUrl: 'http://example.com', autostart: false }],
|
|
171
|
+
['server-c', { name: 'server-c', command: 'node', args: ['c.js'], autostart: false }]
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
// Only server-b remains
|
|
175
|
+
await contribution.handleServerChanges({
|
|
176
|
+
'server-b': { serverUrl: 'http://example.com' }
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
expect(mockFrontendMCPService.stopServer.calledWith('server-a')).to.be.true;
|
|
180
|
+
expect(mockFrontendMCPService.stopServer.calledWith('server-c')).to.be.true;
|
|
181
|
+
expect(mockFrontendMCPService.stopServer.calledWith('server-b')).to.be.false;
|
|
182
|
+
|
|
183
|
+
expect(mockManager.removeServer.calledWith('server-a')).to.be.true;
|
|
184
|
+
expect(mockManager.removeServer.calledWith('server-c')).to.be.true;
|
|
185
|
+
expect(mockManager.removeServer.calledWith('server-b')).to.be.false;
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('does not call stopServer or removeServer when no servers are removed', async () => {
|
|
189
|
+
contribution.prevServers = new Map([
|
|
190
|
+
['existing-server', { name: 'existing-server', command: 'node', autostart: true }]
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
await contribution.handleServerChanges({
|
|
194
|
+
'existing-server': { command: 'node' }
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
expect(mockFrontendMCPService.stopServer.called).to.be.false;
|
|
198
|
+
expect(mockManager.removeServer.called).to.be.false;
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('calls addOrUpdateServer for new servers', async () => {
|
|
202
|
+
contribution.prevServers = new Map();
|
|
203
|
+
|
|
204
|
+
await contribution.handleServerChanges({
|
|
205
|
+
'new-server': { command: 'node', args: ['server.js'] }
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
expect(mockManager.addOrUpdateServer.calledOnce).to.be.true;
|
|
209
|
+
const addedServer = mockManager.addOrUpdateServer.firstCall.args[0];
|
|
210
|
+
expect(addedServer.name).to.equal('new-server');
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('calls addOrUpdateServer for updated servers', async () => {
|
|
214
|
+
contribution.prevServers = new Map([
|
|
215
|
+
['my-server', { name: 'my-server', command: 'node', args: ['old.js'], autostart: true }]
|
|
216
|
+
]);
|
|
217
|
+
|
|
218
|
+
await contribution.handleServerChanges({
|
|
219
|
+
'my-server': { command: 'node', args: ['new.js'] }
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
expect(mockFrontendMCPService.stopServer.called).to.be.false;
|
|
223
|
+
expect(mockManager.removeServer.called).to.be.false;
|
|
224
|
+
expect(mockManager.addOrUpdateServer.calledOnce).to.be.true;
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('clears blockedUntrustedServers entry when a server is removed', async () => {
|
|
228
|
+
contribution.prevServers = new Map([
|
|
229
|
+
['blocked-server', { name: 'blocked-server', command: 'node', autostart: true }]
|
|
230
|
+
]);
|
|
231
|
+
// Simulate the server having been blocked
|
|
232
|
+
contribution.blockedUntrustedServers.add('blocked-server');
|
|
233
|
+
|
|
234
|
+
await contribution.handleServerChanges({});
|
|
235
|
+
|
|
236
|
+
expect(contribution.blockedUntrustedServers.has('blocked-server')).to.be.false;
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('updates prevServers after handling changes', async () => {
|
|
240
|
+
contribution.prevServers = new Map([
|
|
241
|
+
['old-server', { name: 'old-server', command: 'node', autostart: true }]
|
|
242
|
+
]);
|
|
243
|
+
|
|
244
|
+
await contribution.handleServerChanges({
|
|
245
|
+
'new-server': { command: 'python', args: ['serve.py'] }
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
expect(contribution.prevServers.has('old-server')).to.be.false;
|
|
249
|
+
expect(contribution.prevServers.has('new-server')).to.be.true;
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
});
|
|
@@ -121,7 +121,7 @@ export class McpFrontendApplicationContribution implements FrontendApplicationCo
|
|
|
121
121
|
|
|
122
122
|
this.preferenceService.onPreferenceChanged(async event => {
|
|
123
123
|
if (event.preferenceName === MCP_SERVERS_PREF) {
|
|
124
|
-
this.handleServerChanges(filterValidValues(this.preferenceService.get(MCP_SERVERS_PREF, {})));
|
|
124
|
+
await this.handleServerChanges(filterValidValues(this.preferenceService.get(MCP_SERVERS_PREF, {})));
|
|
125
125
|
}
|
|
126
126
|
if (event.preferenceName === MCP_USE_WORKSPACE_AS_ROOT_PREF) {
|
|
127
127
|
await this.updateWorkspaceRoots(true);
|
|
@@ -234,12 +234,13 @@ export class McpFrontendApplicationContribution implements FrontendApplicationCo
|
|
|
234
234
|
this.updateBlockedServersStatusBar();
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
protected handleServerChanges(newServers: MCPServersPreference): void {
|
|
237
|
+
protected async handleServerChanges(newServers: MCPServersPreference): Promise<void> {
|
|
238
238
|
const oldServers = this.prevServers;
|
|
239
239
|
const updatedServers = this.convertToMap(newServers);
|
|
240
240
|
|
|
241
241
|
for (const [name] of oldServers) {
|
|
242
242
|
if (!updatedServers.has(name)) {
|
|
243
|
+
await this.frontendMCPService.stopServer(name);
|
|
243
244
|
this.manager.removeServer(name);
|
|
244
245
|
this.blockedUntrustedServers.delete(name);
|
|
245
246
|
}
|
package/lib/package.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=package.spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
|
package/lib/package.spec.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2024 EclipseSource GmbH and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
/* note: this bogus test file is required so that
|
|
17
|
-
we are able to run mocha unit tests on this
|
|
18
|
-
package, without having any actual unit tests in it.
|
|
19
|
-
This way a coverage report will be generated,
|
|
20
|
-
showing 0% coverage, instead of no report.
|
|
21
|
-
This file can be removed once we have real unit
|
|
22
|
-
tests in place. */
|
|
23
|
-
describe('ai-mcp package', () => {
|
|
24
|
-
it('support code coverage statistics', () => true);
|
|
25
|
-
});
|
|
26
|
-
//# sourceMappingURL=package.spec.js.map
|
package/lib/package.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAEhF;;;;;;qBAMqB;AAErB,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAE5B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
|
package/src/package.spec.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2024 EclipseSource GmbH and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/* note: this bogus test file is required so that
|
|
18
|
-
we are able to run mocha unit tests on this
|
|
19
|
-
package, without having any actual unit tests in it.
|
|
20
|
-
This way a coverage report will be generated,
|
|
21
|
-
showing 0% coverage, instead of no report.
|
|
22
|
-
This file can be removed once we have real unit
|
|
23
|
-
tests in place. */
|
|
24
|
-
|
|
25
|
-
describe('ai-mcp package', () => {
|
|
26
|
-
|
|
27
|
-
it('support code coverage statistics', () => true);
|
|
28
|
-
});
|