@codingame/monaco-vscode-mcp-service-override 26.2.2 → 28.0.0
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/index.js +8 -2
- package/package.json +2 -2
- package/vscode/src/vs/base/common/jsonRpcProtocol.d.ts +66 -0
- package/vscode/src/vs/base/common/jsonRpcProtocol.js +216 -0
- package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +1 -1
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +2 -2
- package/vscode/src/vs/platform/mcp/common/mcpGateway.d.ts +39 -0
- package/vscode/src/vs/platform/mcp/common/mcpGateway.js +6 -0
- package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.d.ts +3 -1
- package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.js +12 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +15 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +58 -58
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +27 -28
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayService.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayService.js +51 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayToolBrokerContribution.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayToolBrokerContribution.js +16 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +18 -18
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpMigration.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.js +8 -8
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.d.ts +4 -1
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +42 -24
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +13 -12
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/installedMcpServersDiscovery.js +3 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.js +2 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/pluginMcpDiscovery.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/pluginMcpDiscovery.js +106 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.d.ts +39 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.js +302 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +25 -17
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +27 -18
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +28 -18
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.d.ts +47 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.js +385 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.d.ts +6 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +61 -3
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.d.ts +4 -20
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.js +95 -145
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +9 -9
- package/vscode/src/vs/workbench/services/mcp/browser/mcpWorkbenchManagementService.d.ts +1 -1
- package/vscode/src/vs/workbench/services/mcp/browser/mcpWorkbenchManagementService.js +2 -2
- package/vscode/src/vs/platform/mcp/common/mcpManagementIpc.d.ts +0 -42
- package/vscode/src/vs/platform/mcp/common/mcpManagementIpc.js +0 -105
- package/vscode/src/vs/platform/mcp/common/mcpManagementService.d.ts +0 -130
- package/vscode/src/vs/platform/mcp/common/mcpManagementService.js +0 -665
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.d.ts +0 -259
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.js +0 -1225
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.d.ts +0 -72
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.js +0 -996
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.d.ts +0 -17
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.js +0 -49
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerIcons.d.ts +0 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerIcons.js +0 -12
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.d.ts +0 -88
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.js +0 -464
- package/vscode/src/vs/workbench/contrib/mcp/browser/media/mcpServerEditor.css +0 -94
- package/vscode/src/vs/workbench/services/mcp/common/mcpWorkbenchManagementService.d.ts +0 -87
- package/vscode/src/vs/workbench/services/mcp/common/mcpWorkbenchManagementService.js +0 -702
|
@@ -1,702 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
-
import { RegistryType } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement';
|
|
5
|
-
import { IAllowedMcpServersService, IMcpGalleryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement.service';
|
|
6
|
-
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
|
-
import { IUserDataProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
|
|
8
|
-
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
9
|
-
import { IMcpResourceScannerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpResourceScannerService.service';
|
|
10
|
-
import { isWorkspaceFolder } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace';
|
|
11
|
-
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
12
|
-
import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
13
|
-
import { WORKSPACE_STANDALONE_CONFIGURATIONS, MCP_CONFIGURATION_KEY } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configuration/common/configuration';
|
|
14
|
-
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
15
|
-
import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
16
|
-
import { ConfigurationTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
|
|
17
|
-
import { McpManagementChannelClient } from '../../../../platform/mcp/common/mcpManagementIpc.js';
|
|
18
|
-
import { IUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
|
|
19
|
-
import { IRemoteUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.service';
|
|
20
|
-
import { AbstractMcpManagementService, AbstractMcpResourceManagementService } from '../../../../platform/mcp/common/mcpManagementService.js';
|
|
21
|
-
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
22
|
-
import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
23
|
-
|
|
24
|
-
const USER_CONFIG_ID = "usrlocal";
|
|
25
|
-
const REMOTE_USER_CONFIG_ID = "usrremote";
|
|
26
|
-
const WORKSPACE_CONFIG_ID = "workspace";
|
|
27
|
-
const WORKSPACE_FOLDER_CONFIG_ID_PREFIX = "ws";
|
|
28
|
-
var LocalMcpServerScope;
|
|
29
|
-
(function(LocalMcpServerScope) {
|
|
30
|
-
LocalMcpServerScope["User"] = "user";
|
|
31
|
-
LocalMcpServerScope["RemoteUser"] = "remoteUser";
|
|
32
|
-
LocalMcpServerScope["Workspace"] = "workspace";
|
|
33
|
-
})(LocalMcpServerScope || (LocalMcpServerScope = {}));
|
|
34
|
-
let WorkbenchMcpManagementService = class WorkbenchMcpManagementService extends AbstractMcpManagementService {
|
|
35
|
-
constructor(
|
|
36
|
-
mcpManagementService,
|
|
37
|
-
allowedMcpServersService,
|
|
38
|
-
logService,
|
|
39
|
-
userDataProfileService,
|
|
40
|
-
uriIdentityService,
|
|
41
|
-
workspaceContextService,
|
|
42
|
-
remoteAgentService,
|
|
43
|
-
userDataProfilesService,
|
|
44
|
-
remoteUserDataProfilesService,
|
|
45
|
-
instantiationService
|
|
46
|
-
) {
|
|
47
|
-
super(allowedMcpServersService, logService);
|
|
48
|
-
this.mcpManagementService = mcpManagementService;
|
|
49
|
-
this.userDataProfileService = userDataProfileService;
|
|
50
|
-
this.uriIdentityService = uriIdentityService;
|
|
51
|
-
this.workspaceContextService = workspaceContextService;
|
|
52
|
-
this.userDataProfilesService = userDataProfilesService;
|
|
53
|
-
this.remoteUserDataProfilesService = remoteUserDataProfilesService;
|
|
54
|
-
this._onInstallMcpServer = this._register(( new Emitter()));
|
|
55
|
-
this.onInstallMcpServer = this._onInstallMcpServer.event;
|
|
56
|
-
this._onDidInstallMcpServers = this._register(( new Emitter()));
|
|
57
|
-
this.onDidInstallMcpServers = this._onDidInstallMcpServers.event;
|
|
58
|
-
this._onDidUpdateMcpServers = this._register(( new Emitter()));
|
|
59
|
-
this.onDidUpdateMcpServers = this._onDidUpdateMcpServers.event;
|
|
60
|
-
this._onUninstallMcpServer = this._register(( new Emitter()));
|
|
61
|
-
this.onUninstallMcpServer = this._onUninstallMcpServer.event;
|
|
62
|
-
this._onDidUninstallMcpServer = this._register(( new Emitter()));
|
|
63
|
-
this.onDidUninstallMcpServer = this._onDidUninstallMcpServer.event;
|
|
64
|
-
this._onInstallMcpServerInCurrentProfile = this._register(( new Emitter()));
|
|
65
|
-
this.onInstallMcpServerInCurrentProfile = this._onInstallMcpServerInCurrentProfile.event;
|
|
66
|
-
this._onDidInstallMcpServersInCurrentProfile = this._register(( new Emitter()));
|
|
67
|
-
this.onDidInstallMcpServersInCurrentProfile = this._onDidInstallMcpServersInCurrentProfile.event;
|
|
68
|
-
this._onDidUpdateMcpServersInCurrentProfile = this._register(( new Emitter()));
|
|
69
|
-
this.onDidUpdateMcpServersInCurrentProfile = this._onDidUpdateMcpServersInCurrentProfile.event;
|
|
70
|
-
this._onUninstallMcpServerInCurrentProfile = this._register(( new Emitter()));
|
|
71
|
-
this.onUninstallMcpServerInCurrentProfile = this._onUninstallMcpServerInCurrentProfile.event;
|
|
72
|
-
this._onDidUninstallMcpServerInCurrentProfile = this._register(( new Emitter()));
|
|
73
|
-
this.onDidUninstallMcpServerInCurrentProfile = this._onDidUninstallMcpServerInCurrentProfile.event;
|
|
74
|
-
this._onDidChangeProfile = this._register(( new Emitter()));
|
|
75
|
-
this.onDidChangeProfile = this._onDidChangeProfile.event;
|
|
76
|
-
this.workspaceMcpManagementService = this._register(instantiationService.createInstance(WorkspaceMcpManagementService));
|
|
77
|
-
const remoteAgentConnection = remoteAgentService.getConnection();
|
|
78
|
-
if (remoteAgentConnection) {
|
|
79
|
-
this.remoteMcpManagementService = this._register(instantiationService.createInstance(
|
|
80
|
-
McpManagementChannelClient,
|
|
81
|
-
remoteAgentConnection.getChannel("mcpManagement")
|
|
82
|
-
));
|
|
83
|
-
}
|
|
84
|
-
this._register(this.mcpManagementService.onInstallMcpServer(e => {
|
|
85
|
-
this._onInstallMcpServer.fire(e);
|
|
86
|
-
if (uriIdentityService.extUri.isEqual(e.mcpResource, this.userDataProfileService.currentProfile.mcpResource)) {
|
|
87
|
-
this._onInstallMcpServerInCurrentProfile.fire({
|
|
88
|
-
...e,
|
|
89
|
-
scope: LocalMcpServerScope.User
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}));
|
|
93
|
-
this._register(this.mcpManagementService.onDidInstallMcpServers(e => {
|
|
94
|
-
const {
|
|
95
|
-
mcpServerInstallResult,
|
|
96
|
-
mcpServerInstallResultInCurrentProfile
|
|
97
|
-
} = this.createInstallMcpServerResultsFromEvent(e, LocalMcpServerScope.User);
|
|
98
|
-
this._onDidInstallMcpServers.fire(mcpServerInstallResult);
|
|
99
|
-
if (mcpServerInstallResultInCurrentProfile.length) {
|
|
100
|
-
this._onDidInstallMcpServersInCurrentProfile.fire(mcpServerInstallResultInCurrentProfile);
|
|
101
|
-
}
|
|
102
|
-
}));
|
|
103
|
-
this._register(this.mcpManagementService.onDidUpdateMcpServers(e => {
|
|
104
|
-
const {
|
|
105
|
-
mcpServerInstallResult,
|
|
106
|
-
mcpServerInstallResultInCurrentProfile
|
|
107
|
-
} = this.createInstallMcpServerResultsFromEvent(e, LocalMcpServerScope.User);
|
|
108
|
-
this._onDidUpdateMcpServers.fire(mcpServerInstallResult);
|
|
109
|
-
if (mcpServerInstallResultInCurrentProfile.length) {
|
|
110
|
-
this._onDidUpdateMcpServersInCurrentProfile.fire(mcpServerInstallResultInCurrentProfile);
|
|
111
|
-
}
|
|
112
|
-
}));
|
|
113
|
-
this._register(this.mcpManagementService.onUninstallMcpServer(e => {
|
|
114
|
-
this._onUninstallMcpServer.fire(e);
|
|
115
|
-
if (uriIdentityService.extUri.isEqual(e.mcpResource, this.userDataProfileService.currentProfile.mcpResource)) {
|
|
116
|
-
this._onUninstallMcpServerInCurrentProfile.fire({
|
|
117
|
-
...e,
|
|
118
|
-
scope: LocalMcpServerScope.User
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}));
|
|
122
|
-
this._register(this.mcpManagementService.onDidUninstallMcpServer(e => {
|
|
123
|
-
this._onDidUninstallMcpServer.fire(e);
|
|
124
|
-
if (uriIdentityService.extUri.isEqual(e.mcpResource, this.userDataProfileService.currentProfile.mcpResource)) {
|
|
125
|
-
this._onDidUninstallMcpServerInCurrentProfile.fire({
|
|
126
|
-
...e,
|
|
127
|
-
scope: LocalMcpServerScope.User
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}));
|
|
131
|
-
this._register(this.workspaceMcpManagementService.onInstallMcpServer(async e => {
|
|
132
|
-
this._onInstallMcpServer.fire(e);
|
|
133
|
-
this._onInstallMcpServerInCurrentProfile.fire({
|
|
134
|
-
...e,
|
|
135
|
-
scope: LocalMcpServerScope.Workspace
|
|
136
|
-
});
|
|
137
|
-
}));
|
|
138
|
-
this._register(this.workspaceMcpManagementService.onDidInstallMcpServers(async e => {
|
|
139
|
-
const {
|
|
140
|
-
mcpServerInstallResult
|
|
141
|
-
} = this.createInstallMcpServerResultsFromEvent(e, LocalMcpServerScope.Workspace);
|
|
142
|
-
this._onDidInstallMcpServers.fire(mcpServerInstallResult);
|
|
143
|
-
this._onDidInstallMcpServersInCurrentProfile.fire(mcpServerInstallResult);
|
|
144
|
-
}));
|
|
145
|
-
this._register(this.workspaceMcpManagementService.onUninstallMcpServer(async e => {
|
|
146
|
-
this._onUninstallMcpServer.fire(e);
|
|
147
|
-
this._onUninstallMcpServerInCurrentProfile.fire({
|
|
148
|
-
...e,
|
|
149
|
-
scope: LocalMcpServerScope.Workspace
|
|
150
|
-
});
|
|
151
|
-
}));
|
|
152
|
-
this._register(this.workspaceMcpManagementService.onDidUninstallMcpServer(async e => {
|
|
153
|
-
this._onDidUninstallMcpServer.fire(e);
|
|
154
|
-
this._onDidUninstallMcpServerInCurrentProfile.fire({
|
|
155
|
-
...e,
|
|
156
|
-
scope: LocalMcpServerScope.Workspace
|
|
157
|
-
});
|
|
158
|
-
}));
|
|
159
|
-
this._register(this.workspaceMcpManagementService.onDidUpdateMcpServers(e => {
|
|
160
|
-
const {
|
|
161
|
-
mcpServerInstallResult
|
|
162
|
-
} = this.createInstallMcpServerResultsFromEvent(e, LocalMcpServerScope.Workspace);
|
|
163
|
-
this._onDidUpdateMcpServers.fire(mcpServerInstallResult);
|
|
164
|
-
this._onDidUpdateMcpServersInCurrentProfile.fire(mcpServerInstallResult);
|
|
165
|
-
}));
|
|
166
|
-
if (this.remoteMcpManagementService) {
|
|
167
|
-
this._register(this.remoteMcpManagementService.onInstallMcpServer(async e => {
|
|
168
|
-
this._onInstallMcpServer.fire(e);
|
|
169
|
-
const remoteMcpResource = await this.getRemoteMcpResource(this.userDataProfileService.currentProfile.mcpResource);
|
|
170
|
-
if (remoteMcpResource ? uriIdentityService.extUri.isEqual(e.mcpResource, remoteMcpResource) : this.userDataProfileService.currentProfile.isDefault) {
|
|
171
|
-
this._onInstallMcpServerInCurrentProfile.fire({
|
|
172
|
-
...e,
|
|
173
|
-
scope: LocalMcpServerScope.RemoteUser
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}));
|
|
177
|
-
this._register(
|
|
178
|
-
this.remoteMcpManagementService.onDidInstallMcpServers(e => this.handleRemoteInstallMcpServerResultsFromEvent(
|
|
179
|
-
e,
|
|
180
|
-
this._onDidInstallMcpServers,
|
|
181
|
-
this._onDidInstallMcpServersInCurrentProfile
|
|
182
|
-
))
|
|
183
|
-
);
|
|
184
|
-
this._register(
|
|
185
|
-
this.remoteMcpManagementService.onDidUpdateMcpServers(e => this.handleRemoteInstallMcpServerResultsFromEvent(
|
|
186
|
-
e,
|
|
187
|
-
this._onDidInstallMcpServers,
|
|
188
|
-
this._onDidInstallMcpServersInCurrentProfile
|
|
189
|
-
))
|
|
190
|
-
);
|
|
191
|
-
this._register(this.remoteMcpManagementService.onUninstallMcpServer(async e => {
|
|
192
|
-
this._onUninstallMcpServer.fire(e);
|
|
193
|
-
const remoteMcpResource = await this.getRemoteMcpResource(this.userDataProfileService.currentProfile.mcpResource);
|
|
194
|
-
if (remoteMcpResource ? uriIdentityService.extUri.isEqual(e.mcpResource, remoteMcpResource) : this.userDataProfileService.currentProfile.isDefault) {
|
|
195
|
-
this._onUninstallMcpServerInCurrentProfile.fire({
|
|
196
|
-
...e,
|
|
197
|
-
scope: LocalMcpServerScope.RemoteUser
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}));
|
|
201
|
-
this._register(this.remoteMcpManagementService.onDidUninstallMcpServer(async e => {
|
|
202
|
-
this._onDidUninstallMcpServer.fire(e);
|
|
203
|
-
const remoteMcpResource = await this.getRemoteMcpResource(this.userDataProfileService.currentProfile.mcpResource);
|
|
204
|
-
if (remoteMcpResource ? uriIdentityService.extUri.isEqual(e.mcpResource, remoteMcpResource) : this.userDataProfileService.currentProfile.isDefault) {
|
|
205
|
-
this._onDidUninstallMcpServerInCurrentProfile.fire({
|
|
206
|
-
...e,
|
|
207
|
-
scope: LocalMcpServerScope.RemoteUser
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}));
|
|
211
|
-
}
|
|
212
|
-
this._register(userDataProfileService.onDidChangeCurrentProfile(e => {
|
|
213
|
-
if (!this.uriIdentityService.extUri.isEqual(e.previous.mcpResource, e.profile.mcpResource)) {
|
|
214
|
-
this._onDidChangeProfile.fire();
|
|
215
|
-
}
|
|
216
|
-
}));
|
|
217
|
-
}
|
|
218
|
-
createInstallMcpServerResultsFromEvent(e, scope) {
|
|
219
|
-
const mcpServerInstallResult = [];
|
|
220
|
-
const mcpServerInstallResultInCurrentProfile = [];
|
|
221
|
-
for (const result of e) {
|
|
222
|
-
const workbenchResult = {
|
|
223
|
-
...result,
|
|
224
|
-
local: result.local ? this.toWorkspaceMcpServer(result.local, scope) : undefined
|
|
225
|
-
};
|
|
226
|
-
mcpServerInstallResult.push(workbenchResult);
|
|
227
|
-
if (this.uriIdentityService.extUri.isEqual(result.mcpResource, this.userDataProfileService.currentProfile.mcpResource)) {
|
|
228
|
-
mcpServerInstallResultInCurrentProfile.push(workbenchResult);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return {
|
|
232
|
-
mcpServerInstallResult,
|
|
233
|
-
mcpServerInstallResultInCurrentProfile
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
async handleRemoteInstallMcpServerResultsFromEvent(e, emitter, currentProfileEmitter) {
|
|
237
|
-
const mcpServerInstallResult = [];
|
|
238
|
-
const mcpServerInstallResultInCurrentProfile = [];
|
|
239
|
-
const remoteMcpResource = await this.getRemoteMcpResource(this.userDataProfileService.currentProfile.mcpResource);
|
|
240
|
-
for (const result of e) {
|
|
241
|
-
const workbenchResult = {
|
|
242
|
-
...result,
|
|
243
|
-
local: result.local ? this.toWorkspaceMcpServer(result.local, LocalMcpServerScope.RemoteUser) : undefined
|
|
244
|
-
};
|
|
245
|
-
mcpServerInstallResult.push(workbenchResult);
|
|
246
|
-
if (remoteMcpResource ? this.uriIdentityService.extUri.isEqual(result.mcpResource, remoteMcpResource) : this.userDataProfileService.currentProfile.isDefault) {
|
|
247
|
-
mcpServerInstallResultInCurrentProfile.push(workbenchResult);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
emitter.fire(mcpServerInstallResult);
|
|
251
|
-
if (mcpServerInstallResultInCurrentProfile.length) {
|
|
252
|
-
currentProfileEmitter.fire(mcpServerInstallResultInCurrentProfile);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
async getInstalled() {
|
|
256
|
-
const installed = [];
|
|
257
|
-
const [userServers, remoteServers, workspaceServers] = await Promise.all([
|
|
258
|
-
this.mcpManagementService.getInstalled(this.userDataProfileService.currentProfile.mcpResource),
|
|
259
|
-
this.remoteMcpManagementService?.getInstalled(await this.getRemoteMcpResource()) ?? Promise.resolve([]),
|
|
260
|
-
this.workspaceMcpManagementService?.getInstalled() ?? Promise.resolve([])
|
|
261
|
-
]);
|
|
262
|
-
for (const server of userServers) {
|
|
263
|
-
installed.push(this.toWorkspaceMcpServer(server, LocalMcpServerScope.User));
|
|
264
|
-
}
|
|
265
|
-
for (const server of remoteServers) {
|
|
266
|
-
installed.push(this.toWorkspaceMcpServer(server, LocalMcpServerScope.RemoteUser));
|
|
267
|
-
}
|
|
268
|
-
for (const server of workspaceServers) {
|
|
269
|
-
installed.push(this.toWorkspaceMcpServer(server, LocalMcpServerScope.Workspace));
|
|
270
|
-
}
|
|
271
|
-
return installed;
|
|
272
|
-
}
|
|
273
|
-
toWorkspaceMcpServer(server, scope) {
|
|
274
|
-
return {
|
|
275
|
-
...server,
|
|
276
|
-
id: `mcp.config.${this.getConfigId(server, scope)}.${server.name}`,
|
|
277
|
-
scope
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
getConfigId(server, scope) {
|
|
281
|
-
if (scope === LocalMcpServerScope.User) {
|
|
282
|
-
return USER_CONFIG_ID;
|
|
283
|
-
}
|
|
284
|
-
if (scope === LocalMcpServerScope.RemoteUser) {
|
|
285
|
-
return REMOTE_USER_CONFIG_ID;
|
|
286
|
-
}
|
|
287
|
-
if (scope === LocalMcpServerScope.Workspace) {
|
|
288
|
-
const workspace = this.workspaceContextService.getWorkspace();
|
|
289
|
-
if (workspace.configuration && this.uriIdentityService.extUri.isEqual(workspace.configuration, server.mcpResource)) {
|
|
290
|
-
return WORKSPACE_CONFIG_ID;
|
|
291
|
-
}
|
|
292
|
-
const workspaceFolders = workspace.folders;
|
|
293
|
-
for (let index = 0; index < workspaceFolders.length; index++) {
|
|
294
|
-
const workspaceFolder = workspaceFolders[index];
|
|
295
|
-
if (this.uriIdentityService.extUri.isEqual(this.uriIdentityService.extUri.joinPath(
|
|
296
|
-
workspaceFolder.uri,
|
|
297
|
-
WORKSPACE_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY]
|
|
298
|
-
), server.mcpResource)) {
|
|
299
|
-
return `${WORKSPACE_FOLDER_CONFIG_ID_PREFIX}${index}`;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return "unknown";
|
|
304
|
-
}
|
|
305
|
-
async install(server, options) {
|
|
306
|
-
options = options ?? {};
|
|
307
|
-
if (options.target === ConfigurationTarget.WORKSPACE || isWorkspaceFolder(options.target)) {
|
|
308
|
-
const mcpResource = options.target === ConfigurationTarget.WORKSPACE ? this.workspaceContextService.getWorkspace().configuration : options.target.toResource(WORKSPACE_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY]);
|
|
309
|
-
if (!mcpResource) {
|
|
310
|
-
throw ( new Error(`Illegal target: ${options.target}`));
|
|
311
|
-
}
|
|
312
|
-
options.mcpResource = mcpResource;
|
|
313
|
-
const result = await this.workspaceMcpManagementService.install(server, options);
|
|
314
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.Workspace);
|
|
315
|
-
}
|
|
316
|
-
if (options.target === ConfigurationTarget.USER_REMOTE) {
|
|
317
|
-
if (!this.remoteMcpManagementService) {
|
|
318
|
-
throw ( new Error(`Illegal target: ${options.target}`));
|
|
319
|
-
}
|
|
320
|
-
options.mcpResource = await this.getRemoteMcpResource(options.mcpResource);
|
|
321
|
-
const result = await this.remoteMcpManagementService.install(server, options);
|
|
322
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.RemoteUser);
|
|
323
|
-
}
|
|
324
|
-
if (options.target && options.target !== ConfigurationTarget.USER && options.target !== ConfigurationTarget.USER_LOCAL) {
|
|
325
|
-
throw ( new Error(`Illegal target: ${options.target}`));
|
|
326
|
-
}
|
|
327
|
-
options.mcpResource = this.userDataProfileService.currentProfile.mcpResource;
|
|
328
|
-
const result = await this.mcpManagementService.install(server, options);
|
|
329
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.User);
|
|
330
|
-
}
|
|
331
|
-
async installFromGallery(server, options) {
|
|
332
|
-
options = options ?? {};
|
|
333
|
-
if (options.target === ConfigurationTarget.WORKSPACE || isWorkspaceFolder(options.target)) {
|
|
334
|
-
const mcpResource = options.target === ConfigurationTarget.WORKSPACE ? this.workspaceContextService.getWorkspace().configuration : options.target.toResource(WORKSPACE_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY]);
|
|
335
|
-
if (!mcpResource) {
|
|
336
|
-
throw ( new Error(`Illegal target: ${options.target}`));
|
|
337
|
-
}
|
|
338
|
-
options.mcpResource = mcpResource;
|
|
339
|
-
const result = await this.workspaceMcpManagementService.installFromGallery(server, options);
|
|
340
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.Workspace);
|
|
341
|
-
}
|
|
342
|
-
if (options.target === ConfigurationTarget.USER_REMOTE) {
|
|
343
|
-
if (!this.remoteMcpManagementService) {
|
|
344
|
-
throw ( new Error(`Illegal target: ${options.target}`));
|
|
345
|
-
}
|
|
346
|
-
options.mcpResource = await this.getRemoteMcpResource(options.mcpResource);
|
|
347
|
-
const result = await this.remoteMcpManagementService.installFromGallery(server, options);
|
|
348
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.RemoteUser);
|
|
349
|
-
}
|
|
350
|
-
if (options.target && options.target !== ConfigurationTarget.USER && options.target !== ConfigurationTarget.USER_LOCAL) {
|
|
351
|
-
throw ( new Error(`Illegal target: ${options.target}`));
|
|
352
|
-
}
|
|
353
|
-
if (!options.mcpResource) {
|
|
354
|
-
options.mcpResource = this.userDataProfileService.currentProfile.mcpResource;
|
|
355
|
-
}
|
|
356
|
-
const result = await this.mcpManagementService.installFromGallery(server, options);
|
|
357
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.User);
|
|
358
|
-
}
|
|
359
|
-
async updateMetadata(local, server, profileLocation) {
|
|
360
|
-
if (local.scope === LocalMcpServerScope.Workspace) {
|
|
361
|
-
const result = await this.workspaceMcpManagementService.updateMetadata(local, server, profileLocation);
|
|
362
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.Workspace);
|
|
363
|
-
}
|
|
364
|
-
if (local.scope === LocalMcpServerScope.RemoteUser) {
|
|
365
|
-
if (!this.remoteMcpManagementService) {
|
|
366
|
-
throw ( new Error(`Illegal target: ${local.scope}`));
|
|
367
|
-
}
|
|
368
|
-
const result = await this.remoteMcpManagementService.updateMetadata(local, server, profileLocation);
|
|
369
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.RemoteUser);
|
|
370
|
-
}
|
|
371
|
-
const result = await this.mcpManagementService.updateMetadata(local, server, profileLocation);
|
|
372
|
-
return this.toWorkspaceMcpServer(result, LocalMcpServerScope.User);
|
|
373
|
-
}
|
|
374
|
-
async uninstall(server) {
|
|
375
|
-
if (server.scope === LocalMcpServerScope.Workspace) {
|
|
376
|
-
return this.workspaceMcpManagementService.uninstall(server);
|
|
377
|
-
}
|
|
378
|
-
if (server.scope === LocalMcpServerScope.RemoteUser) {
|
|
379
|
-
if (!this.remoteMcpManagementService) {
|
|
380
|
-
throw ( new Error(`Illegal target: ${server.scope}`));
|
|
381
|
-
}
|
|
382
|
-
return this.remoteMcpManagementService.uninstall(server);
|
|
383
|
-
}
|
|
384
|
-
return this.mcpManagementService.uninstall(server, {
|
|
385
|
-
mcpResource: this.userDataProfileService.currentProfile.mcpResource
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
async getRemoteMcpResource(mcpResource) {
|
|
389
|
-
if (!mcpResource && this.userDataProfileService.currentProfile.isDefault) {
|
|
390
|
-
return undefined;
|
|
391
|
-
}
|
|
392
|
-
mcpResource = mcpResource ?? this.userDataProfileService.currentProfile.mcpResource;
|
|
393
|
-
let profile = this.userDataProfilesService.profiles.find(p => this.uriIdentityService.extUri.isEqual(p.mcpResource, mcpResource));
|
|
394
|
-
if (profile) {
|
|
395
|
-
profile = await this.remoteUserDataProfilesService.getRemoteProfile(profile);
|
|
396
|
-
} else {
|
|
397
|
-
profile = (await this.remoteUserDataProfilesService.getRemoteProfiles()).find(p => this.uriIdentityService.extUri.isEqual(p.mcpResource, mcpResource));
|
|
398
|
-
}
|
|
399
|
-
return profile?.mcpResource;
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
WorkbenchMcpManagementService = ( __decorate([( __param(1, IAllowedMcpServersService)), ( __param(2, ILogService)), ( __param(3, IUserDataProfileService)), ( __param(4, IUriIdentityService)), ( __param(5, IWorkspaceContextService)), ( __param(6, IRemoteAgentService)), ( __param(7, IUserDataProfilesService)), ( __param(8, IRemoteUserDataProfilesService)), ( __param(9, IInstantiationService))], WorkbenchMcpManagementService));
|
|
403
|
-
let WorkspaceMcpResourceManagementService = class WorkspaceMcpResourceManagementService extends AbstractMcpResourceManagementService {
|
|
404
|
-
constructor(
|
|
405
|
-
mcpResource,
|
|
406
|
-
target,
|
|
407
|
-
mcpGalleryService,
|
|
408
|
-
fileService,
|
|
409
|
-
uriIdentityService,
|
|
410
|
-
logService,
|
|
411
|
-
mcpResourceScannerService
|
|
412
|
-
) {
|
|
413
|
-
super(
|
|
414
|
-
mcpResource,
|
|
415
|
-
target,
|
|
416
|
-
mcpGalleryService,
|
|
417
|
-
fileService,
|
|
418
|
-
uriIdentityService,
|
|
419
|
-
logService,
|
|
420
|
-
mcpResourceScannerService
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
async installFromGallery(server, options) {
|
|
424
|
-
this.logService.trace("MCP Management Service: installGallery", server.name, server.galleryUrl);
|
|
425
|
-
this._onInstallMcpServer.fire({
|
|
426
|
-
name: server.name,
|
|
427
|
-
mcpResource: this.mcpResource
|
|
428
|
-
});
|
|
429
|
-
try {
|
|
430
|
-
const packageType = options?.packageType ?? server.configuration.packages?.[0]?.registryType ?? RegistryType.REMOTE;
|
|
431
|
-
const {
|
|
432
|
-
mcpServerConfiguration,
|
|
433
|
-
notices
|
|
434
|
-
} = this.getMcpServerConfigurationFromManifest(server.configuration, packageType);
|
|
435
|
-
if (notices.length > 0) {
|
|
436
|
-
this.logService.warn(
|
|
437
|
-
`MCP Management Service: Warnings while installing ${server.name}`,
|
|
438
|
-
notices
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
const installable = {
|
|
442
|
-
name: server.name,
|
|
443
|
-
config: {
|
|
444
|
-
...mcpServerConfiguration.config,
|
|
445
|
-
gallery: server.galleryUrl ?? true,
|
|
446
|
-
version: server.version
|
|
447
|
-
},
|
|
448
|
-
inputs: mcpServerConfiguration.inputs
|
|
449
|
-
};
|
|
450
|
-
await this.mcpResourceScannerService.addMcpServers([installable], this.mcpResource, this.target);
|
|
451
|
-
await this.updateLocal();
|
|
452
|
-
const local = (await this.getInstalled()).find(s => s.name === server.name);
|
|
453
|
-
if (!local) {
|
|
454
|
-
throw ( new Error(`Failed to install MCP server: ${server.name}`));
|
|
455
|
-
}
|
|
456
|
-
return local;
|
|
457
|
-
} catch (e) {
|
|
458
|
-
this._onDidInstallMcpServers.fire([{
|
|
459
|
-
name: server.name,
|
|
460
|
-
source: server,
|
|
461
|
-
error: e,
|
|
462
|
-
mcpResource: this.mcpResource
|
|
463
|
-
}]);
|
|
464
|
-
throw e;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
updateMetadata() {
|
|
468
|
-
throw ( new Error("Not supported"));
|
|
469
|
-
}
|
|
470
|
-
installFromUri() {
|
|
471
|
-
throw ( new Error("Not supported"));
|
|
472
|
-
}
|
|
473
|
-
async getLocalServerInfo(name, mcpServerConfig) {
|
|
474
|
-
if (!mcpServerConfig.gallery) {
|
|
475
|
-
return undefined;
|
|
476
|
-
}
|
|
477
|
-
const [mcpServer] = await this.mcpGalleryService.getMcpServersFromGallery([{
|
|
478
|
-
name
|
|
479
|
-
}]);
|
|
480
|
-
if (!mcpServer) {
|
|
481
|
-
return undefined;
|
|
482
|
-
}
|
|
483
|
-
return {
|
|
484
|
-
name: mcpServer.name,
|
|
485
|
-
version: mcpServerConfig.version,
|
|
486
|
-
displayName: mcpServer.displayName,
|
|
487
|
-
description: mcpServer.description,
|
|
488
|
-
galleryUrl: mcpServer.galleryUrl,
|
|
489
|
-
manifest: mcpServer.configuration,
|
|
490
|
-
publisher: mcpServer.publisher,
|
|
491
|
-
publisherDisplayName: mcpServer.publisherDisplayName,
|
|
492
|
-
repositoryUrl: mcpServer.repositoryUrl,
|
|
493
|
-
icon: mcpServer.icon
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
canInstall(server) {
|
|
497
|
-
throw ( new Error("Not supported"));
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
WorkspaceMcpResourceManagementService = ( __decorate([( __param(2, IMcpGalleryService)), ( __param(3, IFileService)), ( __param(4, IUriIdentityService)), ( __param(5, ILogService)), ( __param(6, IMcpResourceScannerService))], WorkspaceMcpResourceManagementService));
|
|
501
|
-
let WorkspaceMcpManagementService = class WorkspaceMcpManagementService extends AbstractMcpManagementService {
|
|
502
|
-
constructor(
|
|
503
|
-
allowedMcpServersService,
|
|
504
|
-
uriIdentityService,
|
|
505
|
-
logService,
|
|
506
|
-
workspaceContextService,
|
|
507
|
-
instantiationService
|
|
508
|
-
) {
|
|
509
|
-
super(allowedMcpServersService, logService);
|
|
510
|
-
this.uriIdentityService = uriIdentityService;
|
|
511
|
-
this.workspaceContextService = workspaceContextService;
|
|
512
|
-
this.instantiationService = instantiationService;
|
|
513
|
-
this._onInstallMcpServer = this._register(( new Emitter()));
|
|
514
|
-
this.onInstallMcpServer = this._onInstallMcpServer.event;
|
|
515
|
-
this._onDidInstallMcpServers = this._register(( new Emitter()));
|
|
516
|
-
this.onDidInstallMcpServers = this._onDidInstallMcpServers.event;
|
|
517
|
-
this._onDidUpdateMcpServers = this._register(( new Emitter()));
|
|
518
|
-
this.onDidUpdateMcpServers = this._onDidUpdateMcpServers.event;
|
|
519
|
-
this._onUninstallMcpServer = this._register(( new Emitter()));
|
|
520
|
-
this.onUninstallMcpServer = this._onUninstallMcpServer.event;
|
|
521
|
-
this._onDidUninstallMcpServer = this._register(( new Emitter()));
|
|
522
|
-
this.onDidUninstallMcpServer = this._onDidUninstallMcpServer.event;
|
|
523
|
-
this.allMcpServers = [];
|
|
524
|
-
this.workspaceMcpManagementServices = ( new ResourceMap());
|
|
525
|
-
this.initialize();
|
|
526
|
-
}
|
|
527
|
-
async initialize() {
|
|
528
|
-
try {
|
|
529
|
-
await this.onDidChangeWorkbenchState();
|
|
530
|
-
await this.onDidChangeWorkspaceFolders({
|
|
531
|
-
added: this.workspaceContextService.getWorkspace().folders,
|
|
532
|
-
removed: [],
|
|
533
|
-
changed: []
|
|
534
|
-
});
|
|
535
|
-
this._register(
|
|
536
|
-
this.workspaceContextService.onDidChangeWorkspaceFolders(e => this.onDidChangeWorkspaceFolders(e))
|
|
537
|
-
);
|
|
538
|
-
this._register(
|
|
539
|
-
this.workspaceContextService.onDidChangeWorkbenchState(e => this.onDidChangeWorkbenchState())
|
|
540
|
-
);
|
|
541
|
-
} catch (error) {
|
|
542
|
-
this.logService.error("Failed to initialize workspace folders", error);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
async onDidChangeWorkbenchState() {
|
|
546
|
-
if (this.workspaceConfiguration) {
|
|
547
|
-
await this.removeWorkspaceService(this.workspaceConfiguration);
|
|
548
|
-
}
|
|
549
|
-
this.workspaceConfiguration = this.workspaceContextService.getWorkspace().configuration;
|
|
550
|
-
if (this.workspaceConfiguration) {
|
|
551
|
-
await this.addWorkspaceService(this.workspaceConfiguration, ConfigurationTarget.WORKSPACE);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
async onDidChangeWorkspaceFolders(e) {
|
|
555
|
-
try {
|
|
556
|
-
await Promise.allSettled(( e.removed.map(folder => this.removeWorkspaceService(
|
|
557
|
-
folder.toResource(WORKSPACE_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY])
|
|
558
|
-
))));
|
|
559
|
-
} catch (error) {
|
|
560
|
-
this.logService.error(error);
|
|
561
|
-
}
|
|
562
|
-
try {
|
|
563
|
-
await Promise.allSettled(( e.added.map(folder => this.addWorkspaceService(
|
|
564
|
-
folder.toResource(WORKSPACE_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY]),
|
|
565
|
-
ConfigurationTarget.WORKSPACE_FOLDER
|
|
566
|
-
))));
|
|
567
|
-
} catch (error) {
|
|
568
|
-
this.logService.error(error);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
async addWorkspaceService(mcpResource, target) {
|
|
572
|
-
if (( this.workspaceMcpManagementServices.has(mcpResource))) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
const disposables = ( new DisposableStore());
|
|
576
|
-
const service = disposables.add(
|
|
577
|
-
this.instantiationService.createInstance(WorkspaceMcpResourceManagementService, mcpResource, target)
|
|
578
|
-
);
|
|
579
|
-
try {
|
|
580
|
-
const installedServers = await service.getInstalled();
|
|
581
|
-
this.allMcpServers.push(...installedServers);
|
|
582
|
-
if (installedServers.length > 0) {
|
|
583
|
-
const installResults = ( installedServers.map(server => ({
|
|
584
|
-
name: server.name,
|
|
585
|
-
local: server,
|
|
586
|
-
mcpResource: server.mcpResource
|
|
587
|
-
})));
|
|
588
|
-
this._onDidInstallMcpServers.fire(installResults);
|
|
589
|
-
}
|
|
590
|
-
} catch (error) {
|
|
591
|
-
this.logService.warn("Failed to get installed servers from", ( mcpResource.toString()), error);
|
|
592
|
-
}
|
|
593
|
-
disposables.add(service.onInstallMcpServer(e => this._onInstallMcpServer.fire(e)));
|
|
594
|
-
disposables.add(service.onDidInstallMcpServers(e => {
|
|
595
|
-
for (const {
|
|
596
|
-
local
|
|
597
|
-
} of e) {
|
|
598
|
-
if (local) {
|
|
599
|
-
this.allMcpServers.push(local);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
this._onDidInstallMcpServers.fire(e);
|
|
603
|
-
}));
|
|
604
|
-
disposables.add(service.onDidUpdateMcpServers(e => {
|
|
605
|
-
for (const {
|
|
606
|
-
local,
|
|
607
|
-
mcpResource
|
|
608
|
-
} of e) {
|
|
609
|
-
if (local) {
|
|
610
|
-
const index = this.allMcpServers.findIndex(
|
|
611
|
-
server => this.uriIdentityService.extUri.isEqual(server.mcpResource, mcpResource) && server.name === local.name
|
|
612
|
-
);
|
|
613
|
-
if (index !== -1) {
|
|
614
|
-
this.allMcpServers.splice(index, 1, local);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
this._onDidUpdateMcpServers.fire(e);
|
|
619
|
-
}));
|
|
620
|
-
disposables.add(service.onUninstallMcpServer(e => this._onUninstallMcpServer.fire(e)));
|
|
621
|
-
disposables.add(service.onDidUninstallMcpServer(e => {
|
|
622
|
-
const index = this.allMcpServers.findIndex(
|
|
623
|
-
server => this.uriIdentityService.extUri.isEqual(server.mcpResource, e.mcpResource) && server.name === e.name
|
|
624
|
-
);
|
|
625
|
-
if (index !== -1) {
|
|
626
|
-
this.allMcpServers.splice(index, 1);
|
|
627
|
-
this._onDidUninstallMcpServer.fire(e);
|
|
628
|
-
}
|
|
629
|
-
}));
|
|
630
|
-
this.workspaceMcpManagementServices.set(mcpResource, {
|
|
631
|
-
service,
|
|
632
|
-
dispose: () => disposables.dispose()
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
async removeWorkspaceService(mcpResource) {
|
|
636
|
-
const serviceItem = this.workspaceMcpManagementServices.get(mcpResource);
|
|
637
|
-
if (serviceItem) {
|
|
638
|
-
try {
|
|
639
|
-
const installedServers = await serviceItem.service.getInstalled();
|
|
640
|
-
this.allMcpServers = this.allMcpServers.filter(server => !( installedServers.some(
|
|
641
|
-
uninstalled => this.uriIdentityService.extUri.isEqual(uninstalled.mcpResource, server.mcpResource)
|
|
642
|
-
)));
|
|
643
|
-
for (const server of installedServers) {
|
|
644
|
-
this._onDidUninstallMcpServer.fire({
|
|
645
|
-
name: server.name,
|
|
646
|
-
mcpResource: server.mcpResource
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
} catch (error) {
|
|
650
|
-
this.logService.warn("Failed to get installed servers from", ( mcpResource.toString()), error);
|
|
651
|
-
}
|
|
652
|
-
this.workspaceMcpManagementServices.delete(mcpResource);
|
|
653
|
-
serviceItem.dispose();
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
async getInstalled() {
|
|
657
|
-
return this.allMcpServers;
|
|
658
|
-
}
|
|
659
|
-
async install(server, options) {
|
|
660
|
-
if (!options?.mcpResource) {
|
|
661
|
-
throw ( new Error("MCP resource is required"));
|
|
662
|
-
}
|
|
663
|
-
const mcpManagementServiceItem = this.workspaceMcpManagementServices.get(options?.mcpResource);
|
|
664
|
-
if (!mcpManagementServiceItem) {
|
|
665
|
-
throw ( new Error(
|
|
666
|
-
`No MCP management service found for resource: ${options?.mcpResource.toString()}`
|
|
667
|
-
));
|
|
668
|
-
}
|
|
669
|
-
return mcpManagementServiceItem.service.install(server, options);
|
|
670
|
-
}
|
|
671
|
-
async uninstall(server, options) {
|
|
672
|
-
const mcpResource = server.mcpResource;
|
|
673
|
-
const mcpManagementServiceItem = this.workspaceMcpManagementServices.get(mcpResource);
|
|
674
|
-
if (!mcpManagementServiceItem) {
|
|
675
|
-
throw ( new Error(`No MCP management service found for resource: ${( mcpResource.toString())}`));
|
|
676
|
-
}
|
|
677
|
-
return mcpManagementServiceItem.service.uninstall(server, options);
|
|
678
|
-
}
|
|
679
|
-
installFromGallery(gallery, options) {
|
|
680
|
-
if (!options?.mcpResource) {
|
|
681
|
-
throw ( new Error("MCP resource is required"));
|
|
682
|
-
}
|
|
683
|
-
const mcpManagementServiceItem = this.workspaceMcpManagementServices.get(options?.mcpResource);
|
|
684
|
-
if (!mcpManagementServiceItem) {
|
|
685
|
-
throw ( new Error(
|
|
686
|
-
`No MCP management service found for resource: ${options?.mcpResource.toString()}`
|
|
687
|
-
));
|
|
688
|
-
}
|
|
689
|
-
return mcpManagementServiceItem.service.installFromGallery(gallery, options);
|
|
690
|
-
}
|
|
691
|
-
updateMetadata() {
|
|
692
|
-
throw ( new Error("Not supported"));
|
|
693
|
-
}
|
|
694
|
-
dispose() {
|
|
695
|
-
this.workspaceMcpManagementServices.forEach(service => service.dispose());
|
|
696
|
-
this.workspaceMcpManagementServices.clear();
|
|
697
|
-
super.dispose();
|
|
698
|
-
}
|
|
699
|
-
};
|
|
700
|
-
WorkspaceMcpManagementService = ( __decorate([( __param(0, IAllowedMcpServersService)), ( __param(1, IUriIdentityService)), ( __param(2, ILogService)), ( __param(3, IWorkspaceContextService)), ( __param(4, IInstantiationService))], WorkspaceMcpManagementService));
|
|
701
|
-
|
|
702
|
-
export { LocalMcpServerScope, REMOTE_USER_CONFIG_ID, USER_CONFIG_ID, WORKSPACE_CONFIG_ID, WORKSPACE_FOLDER_CONFIG_ID_PREFIX, WorkbenchMcpManagementService };
|