@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,18 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
3
|
-
import { assertNever } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
|
4
|
-
import { IntervalTimer, DeferredPromise, disposableTimeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
|
+
import { softAssertNever, assertNever } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
|
4
|
+
import { IntervalTimer, isThenable, DeferredPromise, disposableTimeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
5
5
|
import { CancellationToken, CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
6
6
|
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
7
7
|
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
8
8
|
import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
|
|
9
|
+
import { JsonRpcProtocol, JsonRpcError } from '../../../../base/common/jsonRpcProtocol.js';
|
|
9
10
|
import { Disposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
10
11
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
11
12
|
import { LogLevel, canLog, log } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log';
|
|
12
13
|
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
13
14
|
import { McpConnectionState, MpcResponseError, McpError } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
14
15
|
import { translateMcpLogMessage, isTaskResult } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypesUtils';
|
|
15
|
-
import { MCP } from '@codingame/monaco-vscode-api/vscode/vs/
|
|
16
|
+
import { MCP } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/modelContextProtocol';
|
|
16
17
|
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
17
18
|
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
18
19
|
import { transaction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/transaction';
|
|
@@ -111,8 +112,6 @@ class McpServerRequestHandler extends Disposable {
|
|
|
111
112
|
}
|
|
112
113
|
) {
|
|
113
114
|
super();
|
|
114
|
-
this._nextRequestId = 1;
|
|
115
|
-
this._pendingRequests = ( new Map());
|
|
116
115
|
this._hasAnnouncedRoots = false;
|
|
117
116
|
this._roots = [];
|
|
118
117
|
this._onDidReceiveCancelledNotification = this._register(( new Emitter()));
|
|
@@ -135,6 +134,10 @@ class McpServerRequestHandler extends Disposable {
|
|
|
135
134
|
this._createMessageRequestHandler = createMessageRequestHandler;
|
|
136
135
|
this._elicitationRequestHandler = elicitationRequestHandler;
|
|
137
136
|
this._taskManager = taskManager;
|
|
137
|
+
this._rpc = this._register(( new JsonRpcProtocol(message => this.send(message), {
|
|
138
|
+
handleRequest: (request, token) => this.handleServerRequest(request, token),
|
|
139
|
+
handleNotification: notification => this.handleServerNotification(notification)
|
|
140
|
+
})));
|
|
138
141
|
this._taskManager.setHandler(this);
|
|
139
142
|
this._register(this._taskManager.onDidUpdateTask(task => {
|
|
140
143
|
this.send({
|
|
@@ -144,7 +147,16 @@ class McpServerRequestHandler extends Disposable {
|
|
|
144
147
|
});
|
|
145
148
|
}));
|
|
146
149
|
this._register(toDisposable(() => this._taskManager.setHandler(undefined)));
|
|
147
|
-
this._register(launch.onDidReceiveMessage(message =>
|
|
150
|
+
this._register(launch.onDidReceiveMessage(message => {
|
|
151
|
+
if (canLog(this.logger.getLevel(), this._requestLogLevel)) {
|
|
152
|
+
log(
|
|
153
|
+
this.logger,
|
|
154
|
+
this._requestLogLevel,
|
|
155
|
+
`[server -> editor] ${JSON.stringify(message)}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
void this._rpc.handleMessage(message);
|
|
159
|
+
}));
|
|
148
160
|
this._register(autorun(reader => {
|
|
149
161
|
const state = launch.state.read(reader).state;
|
|
150
162
|
if (state === McpConnectionState.Kind.Error || state === McpConnectionState.Kind.Stopped) {
|
|
@@ -159,35 +171,17 @@ class McpServerRequestHandler extends Disposable {
|
|
|
159
171
|
if (this._store.isDisposed) {
|
|
160
172
|
return Promise.reject(( new CancellationError()));
|
|
161
173
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
...request
|
|
167
|
-
};
|
|
168
|
-
const promise = ( new DeferredPromise());
|
|
169
|
-
this._pendingRequests.set(id, {
|
|
170
|
-
promise
|
|
171
|
-
});
|
|
172
|
-
const cancelListener = token.onCancellationRequested(() => {
|
|
173
|
-
if (!promise.isSettled) {
|
|
174
|
-
this._pendingRequests.delete(id);
|
|
175
|
-
this.sendNotification({
|
|
176
|
-
method: "notifications/cancelled",
|
|
177
|
-
params: {
|
|
178
|
-
requestId: id
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
promise.cancel();
|
|
174
|
+
return this._rpc.sendRequest(request, token, id => this.sendNotification({
|
|
175
|
+
method: "notifications/cancelled",
|
|
176
|
+
params: {
|
|
177
|
+
requestId: id
|
|
182
178
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
this._pendingRequests.delete(id);
|
|
179
|
+
})).catch(error => {
|
|
180
|
+
if (error instanceof JsonRpcError) {
|
|
181
|
+
throw ( new MpcResponseError(error.message, error.code, error.data));
|
|
182
|
+
}
|
|
183
|
+
throw error;
|
|
189
184
|
});
|
|
190
|
-
return ret;
|
|
191
185
|
}
|
|
192
186
|
send(mcp) {
|
|
193
187
|
if (canLog(this.logger.getLevel(), this._requestLogLevel)) {
|
|
@@ -220,54 +214,21 @@ class McpServerRequestHandler extends Disposable {
|
|
|
220
214
|
jsonrpc: MCP.JSONRPC_VERSION
|
|
221
215
|
});
|
|
222
216
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this._requestLogLevel,
|
|
228
|
-
`[server -> editor] ${JSON.stringify(message)}`
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
if ("id" in message) {
|
|
232
|
-
if ("result" in message) {
|
|
233
|
-
this.handleResult(message);
|
|
234
|
-
} else if ("error" in message) {
|
|
235
|
-
this.handleError(message);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if ("method" in message) {
|
|
239
|
-
if ("id" in message) {
|
|
240
|
-
this.handleServerRequest(message);
|
|
241
|
-
} else {
|
|
242
|
-
this.handleServerNotification(message);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
handleResult(response) {
|
|
247
|
-
if (response.id !== undefined) {
|
|
248
|
-
const request = this._pendingRequests.get(response.id);
|
|
249
|
-
if (request) {
|
|
250
|
-
this._pendingRequests.delete(response.id);
|
|
251
|
-
request.promise.complete(response.result);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
handleError(response) {
|
|
256
|
-
if (response.id !== undefined) {
|
|
257
|
-
const request = this._pendingRequests.get(response.id);
|
|
258
|
-
if (request) {
|
|
259
|
-
this._pendingRequests.delete(response.id);
|
|
260
|
-
request.promise.error(( new MpcResponseError(response.error.message, response.error.code, response.error.data)));
|
|
217
|
+
handleServerRequest(request, token) {
|
|
218
|
+
const mapError = error => {
|
|
219
|
+
if (error instanceof McpError) {
|
|
220
|
+
return ( new JsonRpcError(error.code, error.message, error.data));
|
|
261
221
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
222
|
+
this.logger.error(`Error handling request ${request.method}:`, error);
|
|
223
|
+
const mcpError = McpError.unknown(error instanceof Error ? error : ( new Error(String(error))));
|
|
224
|
+
return ( new JsonRpcError(mcpError.code, mcpError.message, mcpError.data));
|
|
225
|
+
};
|
|
265
226
|
try {
|
|
266
|
-
let
|
|
227
|
+
let result;
|
|
267
228
|
if (request.method === "ping") {
|
|
268
|
-
|
|
229
|
+
result = this.handlePing(request);
|
|
269
230
|
} else if (request.method === "roots/list") {
|
|
270
|
-
|
|
231
|
+
result = this.handleRootsList(request);
|
|
271
232
|
} else if (request.method === "sampling/createMessage" && this._createMessageRequestHandler) {
|
|
272
233
|
if (request.params.task) {
|
|
273
234
|
const taskResult = this._taskManager.createTask(
|
|
@@ -278,9 +239,9 @@ class McpServerRequestHandler extends Disposable {
|
|
|
278
239
|
taskResult._meta["io.modelcontextprotocol/related-task"] = {
|
|
279
240
|
taskId: taskResult.task.taskId
|
|
280
241
|
};
|
|
281
|
-
|
|
242
|
+
result = taskResult;
|
|
282
243
|
} else {
|
|
283
|
-
|
|
244
|
+
result = this._createMessageRequestHandler(request.params, token);
|
|
284
245
|
}
|
|
285
246
|
} else if (request.method === "elicitation/create" && this._elicitationRequestHandler) {
|
|
286
247
|
if (request.params.task) {
|
|
@@ -292,89 +253,75 @@ class McpServerRequestHandler extends Disposable {
|
|
|
292
253
|
taskResult._meta["io.modelcontextprotocol/related-task"] = {
|
|
293
254
|
taskId: taskResult.task.taskId
|
|
294
255
|
};
|
|
295
|
-
|
|
256
|
+
result = taskResult;
|
|
296
257
|
} else {
|
|
297
|
-
|
|
258
|
+
result = this._elicitationRequestHandler(request.params, token);
|
|
298
259
|
}
|
|
299
260
|
} else if (request.method === "tasks/get") {
|
|
300
|
-
|
|
261
|
+
result = this._taskManager.getTask(request.params.taskId);
|
|
301
262
|
} else if (request.method === "tasks/result") {
|
|
302
|
-
|
|
263
|
+
result = this._taskManager.getTaskResult(request.params.taskId);
|
|
303
264
|
} else if (request.method === "tasks/cancel") {
|
|
304
|
-
|
|
265
|
+
result = this._taskManager.cancelTask(request.params.taskId);
|
|
305
266
|
} else if (request.method === "tasks/list") {
|
|
306
|
-
|
|
267
|
+
result = this._taskManager.listTasks();
|
|
307
268
|
} else {
|
|
308
269
|
throw McpError.methodNotFound(request.method);
|
|
309
270
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
e = McpError.unknown(e);
|
|
271
|
+
if (isThenable(result)) {
|
|
272
|
+
return result.then(undefined, error => {
|
|
273
|
+
throw mapError(error);
|
|
274
|
+
});
|
|
315
275
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
error: {
|
|
320
|
-
code: e.code,
|
|
321
|
-
message: e.message,
|
|
322
|
-
data: e.data
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
this.send(errorResponse);
|
|
276
|
+
return result;
|
|
277
|
+
} catch (e) {
|
|
278
|
+
throw mapError(e);
|
|
326
279
|
}
|
|
327
280
|
}
|
|
328
281
|
handleServerNotification(request) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
282
|
+
try {
|
|
283
|
+
switch (request.method) {
|
|
284
|
+
case "notifications/message":
|
|
285
|
+
return this.handleLoggingNotification(request);
|
|
286
|
+
case "notifications/cancelled":
|
|
287
|
+
this._onDidReceiveCancelledNotification.fire(request);
|
|
288
|
+
return this.handleCancelledNotification(request);
|
|
289
|
+
case "notifications/progress":
|
|
290
|
+
this._onDidReceiveProgressNotification.fire(request);
|
|
291
|
+
return;
|
|
292
|
+
case "notifications/resources/list_changed":
|
|
293
|
+
this._onDidChangeResourceList.fire();
|
|
294
|
+
return;
|
|
295
|
+
case "notifications/resources/updated":
|
|
296
|
+
this._onDidUpdateResource.fire(request);
|
|
297
|
+
return;
|
|
298
|
+
case "notifications/tools/list_changed":
|
|
299
|
+
this._onDidChangeToolList.fire();
|
|
300
|
+
return;
|
|
301
|
+
case "notifications/prompts/list_changed":
|
|
302
|
+
this._onDidChangePromptList.fire();
|
|
303
|
+
return;
|
|
304
|
+
case "notifications/elicitation/complete":
|
|
305
|
+
this._onDidReceiveElicitationCompleteNotification.fire(request);
|
|
306
|
+
return;
|
|
307
|
+
case "notifications/tasks/status":
|
|
308
|
+
this._taskManager.getClientTask(request.params.taskId)?.onDidUpdateState(request.params);
|
|
309
|
+
return;
|
|
310
|
+
default:
|
|
311
|
+
softAssertNever(request);
|
|
312
|
+
}
|
|
313
|
+
} catch (error) {
|
|
314
|
+
this.logger.error(`Error handling notification ${request.method}:`, error);
|
|
356
315
|
}
|
|
357
316
|
}
|
|
358
317
|
handleCancelledNotification(request) {
|
|
359
318
|
if (request.params.requestId) {
|
|
360
|
-
|
|
361
|
-
if (pendingRequest) {
|
|
362
|
-
this._pendingRequests.delete(request.params.requestId);
|
|
363
|
-
pendingRequest.promise.cancel();
|
|
364
|
-
}
|
|
319
|
+
this._rpc.cancelPendingRequest(request.params.requestId);
|
|
365
320
|
}
|
|
366
321
|
}
|
|
367
322
|
handleLoggingNotification(request) {
|
|
368
323
|
translateMcpLogMessage(this.logger, request.params);
|
|
369
324
|
}
|
|
370
|
-
respondToRequest(request, result) {
|
|
371
|
-
const response = {
|
|
372
|
-
jsonrpc: MCP.JSONRPC_VERSION,
|
|
373
|
-
id: request.id,
|
|
374
|
-
result
|
|
375
|
-
};
|
|
376
|
-
this.send(response);
|
|
377
|
-
}
|
|
378
325
|
handlePing(_request) {
|
|
379
326
|
return {};
|
|
380
327
|
}
|
|
@@ -385,8 +332,7 @@ class McpServerRequestHandler extends Disposable {
|
|
|
385
332
|
};
|
|
386
333
|
}
|
|
387
334
|
cancelAllRequests() {
|
|
388
|
-
this.
|
|
389
|
-
this._pendingRequests.clear();
|
|
335
|
+
this._rpc.cancelAllRequests();
|
|
390
336
|
}
|
|
391
337
|
dispose() {
|
|
392
338
|
this.cancelAllRequests();
|
|
@@ -458,13 +404,13 @@ class McpServerRequestHandler extends Disposable {
|
|
|
458
404
|
this.sendRequestPaginated("tools/list", result => result.tools, params, token)
|
|
459
405
|
);
|
|
460
406
|
}
|
|
461
|
-
async callTool(params, token) {
|
|
407
|
+
async callTool(params, token, onStatusMessage) {
|
|
462
408
|
const response = await this.sendRequest({
|
|
463
409
|
method: "tools/call",
|
|
464
410
|
params
|
|
465
411
|
}, token);
|
|
466
412
|
if (isTaskResult(response)) {
|
|
467
|
-
const task = ( new McpTask(response.task, token));
|
|
413
|
+
const task = ( new McpTask(response.task, token, onStatusMessage));
|
|
468
414
|
this._taskManager.adoptClientTask(task);
|
|
469
415
|
task.setHandler(this);
|
|
470
416
|
return task.result.finally(() => {
|
|
@@ -519,9 +465,10 @@ class McpTask extends Disposable {
|
|
|
519
465
|
get id() {
|
|
520
466
|
return this._task.taskId;
|
|
521
467
|
}
|
|
522
|
-
constructor(_task, _token = CancellationToken.None) {
|
|
468
|
+
constructor(_task, _token = CancellationToken.None, _onStatusMessage) {
|
|
523
469
|
super();
|
|
524
470
|
this._task = _task;
|
|
471
|
+
this._onStatusMessage = _onStatusMessage;
|
|
525
472
|
this.promise = ( new DeferredPromise());
|
|
526
473
|
this._handler = observableValue("mcpTaskHandler", undefined);
|
|
527
474
|
const expiresAt = _task.ttl ? (Date.now() + _task.ttl) : undefined;
|
|
@@ -657,6 +604,9 @@ class McpTask extends Disposable {
|
|
|
657
604
|
}
|
|
658
605
|
onDidUpdateState(task) {
|
|
659
606
|
this._lastTaskState.set(task, undefined);
|
|
607
|
+
if (task.statusMessage && this._onStatusMessage) {
|
|
608
|
+
this._onStatusMessage(task.statusMessage);
|
|
609
|
+
}
|
|
660
610
|
}
|
|
661
611
|
setHandler(handler) {
|
|
662
612
|
this._handler.set(handler, undefined);
|
|
@@ -120,7 +120,7 @@ let AuthenticationMcpService = class AuthenticationMcpService extends Disposable
|
|
|
120
120
|
numberOfRequests += ( Object.keys(accessRequest)).length;
|
|
121
121
|
});
|
|
122
122
|
if (numberOfRequests > 0) {
|
|
123
|
-
const badge = ( new NumberBadge(numberOfRequests, () => ( localize(
|
|
123
|
+
const badge = ( new NumberBadge(numberOfRequests, () => ( localize(15424, "Sign in requested"))));
|
|
124
124
|
this._accountBadgeDisposable.value = this.activityService.showAccountsActivity({
|
|
125
125
|
badge
|
|
126
126
|
});
|
|
@@ -194,17 +194,17 @@ let AuthenticationMcpService = class AuthenticationMcpService extends Disposable
|
|
|
194
194
|
} = await this.dialogService.prompt({
|
|
195
195
|
type: Severity.Info,
|
|
196
196
|
message: ( localize(
|
|
197
|
-
|
|
197
|
+
15425,
|
|
198
198
|
"The MCP server '{0}' wants to access the {1} account '{2}'.",
|
|
199
199
|
mcpServerName,
|
|
200
200
|
provider.label,
|
|
201
201
|
accountName
|
|
202
202
|
)),
|
|
203
203
|
buttons: [{
|
|
204
|
-
label: ( localize(
|
|
204
|
+
label: ( localize(15426, "&&Allow")),
|
|
205
205
|
run: () => SessionPromptChoice.Allow
|
|
206
206
|
}, {
|
|
207
|
-
label: ( localize(
|
|
207
|
+
label: ( localize(15427, "&&Deny")),
|
|
208
208
|
run: () => SessionPromptChoice.Deny
|
|
209
209
|
}],
|
|
210
210
|
cancelButton: {
|
|
@@ -246,17 +246,17 @@ let AuthenticationMcpService = class AuthenticationMcpService extends Disposable
|
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
items.push({
|
|
249
|
-
label: ( localize(
|
|
249
|
+
label: ( localize(15428, "Sign in to another account"))
|
|
250
250
|
});
|
|
251
251
|
quickPick.items = items;
|
|
252
252
|
quickPick.title = ( localize(
|
|
253
|
-
|
|
253
|
+
15429,
|
|
254
254
|
"The MCP server '{0}' wants to access a {1} account",
|
|
255
255
|
mcpServerName,
|
|
256
256
|
this._authenticationService.getProvider(providerId).label
|
|
257
257
|
));
|
|
258
258
|
quickPick.placeholder = ( localize(
|
|
259
|
-
|
|
259
|
+
15430,
|
|
260
260
|
"Select an account for '{0}' to use or Esc to cancel",
|
|
261
261
|
mcpServerName
|
|
262
262
|
));
|
|
@@ -336,7 +336,7 @@ let AuthenticationMcpService = class AuthenticationMcpService extends Disposable
|
|
|
336
336
|
group: "3_accessRequests",
|
|
337
337
|
command: {
|
|
338
338
|
id: `${providerId}${mcpServerId}Access`,
|
|
339
|
-
title: ( localize(
|
|
339
|
+
title: ( localize(15431, "Grant access to {0} for {1}... (1)", provider.label, mcpServerName))
|
|
340
340
|
}
|
|
341
341
|
}));
|
|
342
342
|
const accessCommand = CommandsRegistry.registerCommand({
|
|
@@ -380,7 +380,7 @@ let AuthenticationMcpService = class AuthenticationMcpService extends Disposable
|
|
|
380
380
|
group: "2_signInRequests",
|
|
381
381
|
command: {
|
|
382
382
|
id: commandId,
|
|
383
|
-
title: ( localize(
|
|
383
|
+
title: ( localize(15432, "Sign in with {0} to use {1} (1)", provider.label, mcpServerName))
|
|
384
384
|
}
|
|
385
385
|
}));
|
|
386
386
|
const signInCommand = CommandsRegistry.registerCommand({
|
|
@@ -5,7 +5,7 @@ import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/plat
|
|
|
5
5
|
import { IRemoteAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service";
|
|
6
6
|
import { IUserDataProfilesService } from "@codingame/monaco-vscode-api/vscode/vs/platform/userDataProfile/common/userDataProfile.service";
|
|
7
7
|
import { IRemoteUserDataProfilesService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.service";
|
|
8
|
-
import { WorkbenchMcpManagementService as BaseWorkbenchMcpManagementService } from "
|
|
8
|
+
import { WorkbenchMcpManagementService as BaseWorkbenchMcpManagementService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/mcp/common/mcpWorkbenchManagementService";
|
|
9
9
|
import { IAllowedMcpServersService } from "@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement.service";
|
|
10
10
|
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
11
11
|
export declare class WorkbenchMcpManagementService extends BaseWorkbenchMcpManagementService {
|
|
@@ -8,9 +8,9 @@ import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/plat
|
|
|
8
8
|
import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
9
9
|
import { IUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
|
|
10
10
|
import { IRemoteUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/remoteUserDataProfiles.service';
|
|
11
|
-
import { WorkbenchMcpManagementService as WorkbenchMcpManagementService$1 } from '
|
|
11
|
+
import { WorkbenchMcpManagementService as WorkbenchMcpManagementService$1 } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/mcp/common/mcpWorkbenchManagementService';
|
|
12
12
|
import { IAllowedMcpServersService } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement.service';
|
|
13
|
-
import { McpManagementService } from '
|
|
13
|
+
import { McpManagementService } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagementService';
|
|
14
14
|
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
15
15
|
|
|
16
16
|
let WorkbenchMcpManagementService = class WorkbenchMcpManagementService extends WorkbenchMcpManagementService$1 {
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
2
|
-
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
3
|
-
import { IURITransformer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uriIpc";
|
|
4
|
-
import { IChannel, IServerChannel } from "@codingame/monaco-vscode-api/vscode/vs/base/parts/ipc/common/ipc";
|
|
5
|
-
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
6
|
-
import { RemoteAgentConnectionContext } from "@codingame/monaco-vscode-api/vscode/vs/platform/remote/common/remoteAgentEnvironment";
|
|
7
|
-
import { DidUninstallMcpServerEvent, IGalleryMcpServer, ILocalMcpServer, IInstallableMcpServer, InstallMcpServerEvent, InstallMcpServerResult, InstallOptions, UninstallMcpServerEvent, UninstallOptions } from "@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement";
|
|
8
|
-
import { IAllowedMcpServersService } from "@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement.service";
|
|
9
|
-
import { IMcpManagementService } from "@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement.service";
|
|
10
|
-
import { AbstractMcpManagementService } from "./mcpManagementService.js";
|
|
11
|
-
export declare class McpManagementChannel<TContext = RemoteAgentConnectionContext | string> implements IServerChannel<TContext> {
|
|
12
|
-
private service;
|
|
13
|
-
private getUriTransformer;
|
|
14
|
-
readonly onInstallMcpServer: Event<InstallMcpServerEvent>;
|
|
15
|
-
readonly onDidInstallMcpServers: Event<readonly InstallMcpServerResult[]>;
|
|
16
|
-
readonly onDidUpdateMcpServers: Event<readonly InstallMcpServerResult[]>;
|
|
17
|
-
readonly onUninstallMcpServer: Event<UninstallMcpServerEvent>;
|
|
18
|
-
readonly onDidUninstallMcpServer: Event<DidUninstallMcpServerEvent>;
|
|
19
|
-
constructor(service: IMcpManagementService, getUriTransformer: (requestContext: TContext) => IURITransformer | null);
|
|
20
|
-
listen<T>(context: TContext, event: string): Event<T>;
|
|
21
|
-
call<T>(context: TContext, command: string, args?: unknown): Promise<T>;
|
|
22
|
-
}
|
|
23
|
-
export declare class McpManagementChannelClient extends AbstractMcpManagementService implements IMcpManagementService {
|
|
24
|
-
private readonly channel;
|
|
25
|
-
readonly _serviceBrand: undefined;
|
|
26
|
-
private readonly _onInstallMcpServer;
|
|
27
|
-
get onInstallMcpServer(): Event<InstallMcpServerEvent>;
|
|
28
|
-
private readonly _onDidInstallMcpServers;
|
|
29
|
-
get onDidInstallMcpServers(): Event<readonly InstallMcpServerResult[]>;
|
|
30
|
-
private readonly _onUninstallMcpServer;
|
|
31
|
-
get onUninstallMcpServer(): Event<UninstallMcpServerEvent>;
|
|
32
|
-
private readonly _onDidUninstallMcpServer;
|
|
33
|
-
get onDidUninstallMcpServer(): Event<DidUninstallMcpServerEvent>;
|
|
34
|
-
private readonly _onDidUpdateMcpServers;
|
|
35
|
-
get onDidUpdateMcpServers(): Event<InstallMcpServerResult[]>;
|
|
36
|
-
constructor(channel: IChannel, allowedMcpServersService: IAllowedMcpServersService, logService: ILogService);
|
|
37
|
-
install(server: IInstallableMcpServer, options?: InstallOptions): Promise<ILocalMcpServer>;
|
|
38
|
-
installFromGallery(extension: IGalleryMcpServer, installOptions?: InstallOptions): Promise<ILocalMcpServer>;
|
|
39
|
-
uninstall(extension: ILocalMcpServer, options?: UninstallOptions): Promise<void>;
|
|
40
|
-
getInstalled(mcpResource?: URI): Promise<ILocalMcpServer[]>;
|
|
41
|
-
updateMetadata(local: ILocalMcpServer, gallery: IGalleryMcpServer, mcpResource?: URI): Promise<ILocalMcpServer>;
|
|
42
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
4
|
-
import '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
5
|
-
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
6
|
-
import { DefaultURITransformer, transformAndReviveIncomingURIs } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uriIpc';
|
|
7
|
-
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
8
|
-
import { IAllowedMcpServersService } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement.service';
|
|
9
|
-
import { AbstractMcpManagementService } from './mcpManagementService.js';
|
|
10
|
-
|
|
11
|
-
function transformIncomingURI(uri, transformer) {
|
|
12
|
-
return uri ? URI.revive(uri) : undefined;
|
|
13
|
-
}
|
|
14
|
-
function transformIncomingServer(mcpServer, transformer) {
|
|
15
|
-
transformer = transformer ? transformer : DefaultURITransformer;
|
|
16
|
-
const manifest = mcpServer.manifest;
|
|
17
|
-
const transformed = transformAndReviveIncomingURIs({
|
|
18
|
-
...mcpServer,
|
|
19
|
-
...{
|
|
20
|
-
manifest: undefined
|
|
21
|
-
}
|
|
22
|
-
}, transformer);
|
|
23
|
-
return {
|
|
24
|
-
...transformed,
|
|
25
|
-
...{
|
|
26
|
-
manifest
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
let McpManagementChannelClient = class McpManagementChannelClient extends AbstractMcpManagementService {
|
|
31
|
-
get onInstallMcpServer() {
|
|
32
|
-
return this._onInstallMcpServer.event;
|
|
33
|
-
}
|
|
34
|
-
get onDidInstallMcpServers() {
|
|
35
|
-
return this._onDidInstallMcpServers.event;
|
|
36
|
-
}
|
|
37
|
-
get onUninstallMcpServer() {
|
|
38
|
-
return this._onUninstallMcpServer.event;
|
|
39
|
-
}
|
|
40
|
-
get onDidUninstallMcpServer() {
|
|
41
|
-
return this._onDidUninstallMcpServer.event;
|
|
42
|
-
}
|
|
43
|
-
get onDidUpdateMcpServers() {
|
|
44
|
-
return this._onDidUpdateMcpServers.event;
|
|
45
|
-
}
|
|
46
|
-
constructor(channel, allowedMcpServersService, logService) {
|
|
47
|
-
super(allowedMcpServersService, logService);
|
|
48
|
-
this.channel = channel;
|
|
49
|
-
this._onInstallMcpServer = this._register(( new Emitter()));
|
|
50
|
-
this._onDidInstallMcpServers = this._register(( new Emitter()));
|
|
51
|
-
this._onUninstallMcpServer = this._register(( new Emitter()));
|
|
52
|
-
this._onDidUninstallMcpServer = this._register(( new Emitter()));
|
|
53
|
-
this._onDidUpdateMcpServers = this._register(( new Emitter()));
|
|
54
|
-
this._register(
|
|
55
|
-
this.channel.listen("onInstallMcpServer")(e => this._onInstallMcpServer.fire(({
|
|
56
|
-
...e,
|
|
57
|
-
mcpResource: transformIncomingURI(e.mcpResource)
|
|
58
|
-
})))
|
|
59
|
-
);
|
|
60
|
-
this._register(
|
|
61
|
-
this.channel.listen("onDidInstallMcpServers")(results => this._onDidInstallMcpServers.fire(( results.map(e => ({
|
|
62
|
-
...e,
|
|
63
|
-
local: e.local ? transformIncomingServer(e.local, null) : e.local,
|
|
64
|
-
mcpResource: transformIncomingURI(e.mcpResource)
|
|
65
|
-
})))))
|
|
66
|
-
);
|
|
67
|
-
this._register(
|
|
68
|
-
this.channel.listen("onDidUpdateMcpServers")(results => this._onDidUpdateMcpServers.fire(( results.map(e => ({
|
|
69
|
-
...e,
|
|
70
|
-
local: e.local ? transformIncomingServer(e.local, null) : e.local,
|
|
71
|
-
mcpResource: transformIncomingURI(e.mcpResource)
|
|
72
|
-
})))))
|
|
73
|
-
);
|
|
74
|
-
this._register(
|
|
75
|
-
this.channel.listen("onUninstallMcpServer")(e => this._onUninstallMcpServer.fire(({
|
|
76
|
-
...e,
|
|
77
|
-
mcpResource: transformIncomingURI(e.mcpResource)
|
|
78
|
-
})))
|
|
79
|
-
);
|
|
80
|
-
this._register(
|
|
81
|
-
this.channel.listen("onDidUninstallMcpServer")(e => this._onDidUninstallMcpServer.fire(({
|
|
82
|
-
...e,
|
|
83
|
-
mcpResource: transformIncomingURI(e.mcpResource)
|
|
84
|
-
})))
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
install(server, options) {
|
|
88
|
-
return Promise.resolve(this.channel.call("install", [server, options])).then(local => transformIncomingServer(local, null));
|
|
89
|
-
}
|
|
90
|
-
installFromGallery(extension, installOptions) {
|
|
91
|
-
return Promise.resolve(this.channel.call("installFromGallery", [extension, installOptions])).then(local => transformIncomingServer(local, null));
|
|
92
|
-
}
|
|
93
|
-
uninstall(extension, options) {
|
|
94
|
-
return Promise.resolve(this.channel.call("uninstall", [extension, options]));
|
|
95
|
-
}
|
|
96
|
-
getInstalled(mcpResource) {
|
|
97
|
-
return Promise.resolve(this.channel.call("getInstalled", [mcpResource])).then(servers => ( servers.map(server => transformIncomingServer(server, null))));
|
|
98
|
-
}
|
|
99
|
-
updateMetadata(local, gallery, mcpResource) {
|
|
100
|
-
return Promise.resolve(this.channel.call("updateMetadata", [local, gallery, mcpResource])).then(local => transformIncomingServer(local, null));
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
McpManagementChannelClient = ( __decorate([( __param(1, IAllowedMcpServersService)), ( __param(2, ILogService))], McpManagementChannelClient));
|
|
104
|
-
|
|
105
|
-
export { McpManagementChannelClient };
|