@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.
Files changed (66) hide show
  1. package/index.js +8 -2
  2. package/package.json +2 -2
  3. package/vscode/src/vs/base/common/jsonRpcProtocol.d.ts +66 -0
  4. package/vscode/src/vs/base/common/jsonRpcProtocol.js +216 -0
  5. package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +1 -1
  6. package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +2 -2
  7. package/vscode/src/vs/platform/mcp/common/mcpGateway.d.ts +39 -0
  8. package/vscode/src/vs/platform/mcp/common/mcpGateway.js +6 -0
  9. package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.d.ts +3 -1
  10. package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.js +12 -5
  11. package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +15 -5
  12. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +2 -2
  13. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +58 -58
  14. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +27 -28
  15. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayService.d.ts +20 -0
  16. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayService.js +51 -0
  17. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayToolBrokerContribution.d.ts +7 -0
  18. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayToolBrokerContribution.js +16 -0
  19. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +18 -18
  20. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpMigration.js +4 -4
  21. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.js +8 -8
  22. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.d.ts +4 -1
  23. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +42 -24
  24. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.d.ts +1 -1
  25. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +13 -12
  26. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +4 -4
  27. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/installedMcpServersDiscovery.js +3 -1
  28. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +1 -1
  29. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.js +2 -1
  30. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/pluginMcpDiscovery.d.ts +15 -0
  31. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/pluginMcpDiscovery.js +106 -0
  32. package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +4 -4
  33. package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.d.ts +39 -0
  34. package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.js +302 -0
  35. package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +25 -17
  36. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.d.ts +3 -1
  37. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +27 -18
  38. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +1 -1
  39. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.d.ts +1 -0
  40. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +28 -18
  41. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.d.ts +47 -0
  42. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.js +385 -0
  43. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.d.ts +6 -1
  44. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +61 -3
  45. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.d.ts +4 -20
  46. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.js +95 -145
  47. package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +9 -9
  48. package/vscode/src/vs/workbench/services/mcp/browser/mcpWorkbenchManagementService.d.ts +1 -1
  49. package/vscode/src/vs/workbench/services/mcp/browser/mcpWorkbenchManagementService.js +2 -2
  50. package/vscode/src/vs/platform/mcp/common/mcpManagementIpc.d.ts +0 -42
  51. package/vscode/src/vs/platform/mcp/common/mcpManagementIpc.js +0 -105
  52. package/vscode/src/vs/platform/mcp/common/mcpManagementService.d.ts +0 -130
  53. package/vscode/src/vs/platform/mcp/common/mcpManagementService.js +0 -665
  54. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.d.ts +0 -259
  55. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.js +0 -1225
  56. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.d.ts +0 -72
  57. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.js +0 -996
  58. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.d.ts +0 -17
  59. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.js +0 -49
  60. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerIcons.d.ts +0 -5
  61. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerIcons.js +0 -12
  62. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.d.ts +0 -88
  63. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.js +0 -464
  64. package/vscode/src/vs/workbench/contrib/mcp/browser/media/mcpServerEditor.css +0 -94
  65. package/vscode/src/vs/workbench/services/mcp/common/mcpWorkbenchManagementService.d.ts +0 -87
  66. package/vscode/src/vs/workbench/services/mcp/common/mcpWorkbenchManagementService.js +0 -702
@@ -25,6 +25,7 @@ import { McpToolVisibility, McpToolResourceLinkMimeType, McpResourceURI } from '
25
25
  import { IMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
26
26
  import { mcpServerToSourceData } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypesUtils';
27
27
  import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
28
+ import { McpServer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpServer';
28
29
  import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
29
30
 
30
31
  let McpLanguageModelToolContribution = class McpLanguageModelToolContribution extends Disposable {
@@ -66,7 +67,7 @@ let McpLanguageModelToolContribution = class McpLanguageModelToolContribution ex
66
67
  const toolSet = store.add(
67
68
  this._toolsService.createToolSet(source, server.definition.id, referenceName, {
68
69
  icon: Codicon.mcp,
69
- description: ( localize(9533, "{0}: All Tools", server.definition.label))
70
+ description: ( localize(10423, "{0}: All Tools", server.definition.label))
70
71
  })
71
72
  );
72
73
  return {
@@ -181,30 +182,37 @@ let McpToolImplementation = class McpToolImplementation {
181
182
  async prepareToolInvocation(context) {
182
183
  const tool = this._tool;
183
184
  const server = this._server;
185
+ const sandboxEnabled = await McpServer.callOn(server, async (_handler, connection) => {
186
+ return connection.definition.sandboxEnabled;
187
+ });
188
+ const isSandboxedServer = sandboxEnabled === true;
184
189
  const mcpToolWarning = ( localize(
185
- 9534,
190
+ 10424,
186
191
  "Note that MCP servers or malicious conversation content may attempt to misuse '{0}' through tools.",
187
192
  this._productService.nameShort
188
193
  ));
189
194
  const title = tool.definition.annotations?.title || tool.definition.title || ("`" + tool.definition.name + "`");
190
- const confirm = {};
191
- if (!tool.definition.annotations?.readOnlyHint) {
192
- confirm.title = ( new MarkdownString(( localize(9535, "Run {0}", title))));
193
- confirm.message = ( new MarkdownString(tool.definition.description, {
194
- supportThemeIcons: true
195
- }));
196
- confirm.disclaimer = mcpToolWarning;
197
- confirm.allowAutoConfirm = true;
198
- }
199
- if (tool.definition.annotations?.openWorldHint) {
200
- confirm.confirmResults = true;
195
+ let confirm;
196
+ if (!isSandboxedServer) {
197
+ confirm = {};
198
+ if (!tool.definition.annotations?.readOnlyHint) {
199
+ confirm.title = ( new MarkdownString(( localize(10425, "Run {0}", title))));
200
+ confirm.message = ( new MarkdownString(tool.definition.description, {
201
+ supportThemeIcons: true
202
+ }));
203
+ confirm.disclaimer = mcpToolWarning;
204
+ confirm.allowAutoConfirm = true;
205
+ }
206
+ if (tool.definition.annotations?.openWorldHint) {
207
+ confirm.confirmResults = true;
208
+ }
201
209
  }
202
210
  const mcpUiEnabled = this._configurationService.getValue(mcpAppsEnabledConfig);
203
211
  return {
204
212
  confirmationMessages: confirm,
205
- invocationMessage: ( new MarkdownString(( localize(9536, "Running {0}", title)))),
206
- pastTenseMessage: ( new MarkdownString(( localize(9537, "Ran {0} ", title)))),
207
- originMessage: ( localize(9538, "{0} (MCP Server)", server.definition.label)),
213
+ invocationMessage: ( new MarkdownString(( localize(10426, "Running {0}", title)))),
214
+ pastTenseMessage: ( new MarkdownString(( localize(10427, "Ran {0} ", title)))),
215
+ originMessage: ( localize(10428, "{0} (MCP Server)", server.definition.label)),
208
216
  toolSpecificData: {
209
217
  kind: "input",
210
218
  rawInput: context.parameters,
@@ -222,7 +230,7 @@ let McpToolImplementation = class McpToolImplementation {
222
230
  };
223
231
  const callResult = await this._tool.callWithProgress(invocation.parameters, progress, {
224
232
  chatRequestId: invocation.chatRequestId,
225
- chatSessionId: invocation.context?.sessionId
233
+ chatSessionResource: invocation.context?.sessionResource
226
234
  }, token);
227
235
  const details = {
228
236
  input: JSON.stringify(invocation.parameters, undefined, 2),
@@ -17,6 +17,7 @@ import { IResolvedValue } from "@codingame/monaco-vscode-api/vscode/vs/workbench
17
17
  import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
18
18
  import { IMcpHostDelegate, IMcpResolveConnectionOptions } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes";
19
19
  import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
20
+ import { IMcpSandboxService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpSandboxService.service";
20
21
  import { IMcpServerConnection, LazyCollectionState, McpCollectionDefinition, McpDefinitionReference, McpServerDefinition } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
21
22
  export declare class McpRegistry extends Disposable implements IMcpRegistry {
22
23
  private readonly _instantiationService;
@@ -27,6 +28,7 @@ export declare class McpRegistry extends Disposable implements IMcpRegistry {
27
28
  private readonly _quickInputService;
28
29
  private readonly _labelService;
29
30
  private readonly _logService;
31
+ private readonly _mcpSandboxService;
30
32
  private readonly _workspaceTrustManagementService;
31
33
  private readonly _workspaceTrustRequestService;
32
34
  readonly _serviceBrand: undefined;
@@ -44,7 +46,7 @@ export declare class McpRegistry extends Disposable implements IMcpRegistry {
44
46
  get delegates(): IObservable<readonly IMcpHostDelegate[]>;
45
47
  private readonly _onDidChangeInputs;
46
48
  readonly onDidChangeInputs: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<void>;
47
- constructor(_instantiationService: IInstantiationService, _configurationResolverService: IConfigurationResolverService, _dialogService: IDialogService, _notificationService: INotificationService, _editorService: IEditorService, configurationService: IConfigurationService, _quickInputService: IQuickInputService, _labelService: ILabelService, _logService: ILogService, _workspaceTrustManagementService: IWorkspaceTrustManagementService, _workspaceTrustRequestService: IWorkspaceTrustRequestService);
49
+ constructor(_instantiationService: IInstantiationService, _configurationResolverService: IConfigurationResolverService, _dialogService: IDialogService, _notificationService: INotificationService, _editorService: IEditorService, configurationService: IConfigurationService, _quickInputService: IQuickInputService, _labelService: ILabelService, _logService: ILogService, _mcpSandboxService: IMcpSandboxService, _workspaceTrustManagementService: IWorkspaceTrustManagementService, _workspaceTrustRequestService: IWorkspaceTrustRequestService);
48
50
  registerDelegate(delegate: IMcpHostDelegate): IDisposable;
49
51
  registerCollection(collection: McpCollectionDefinition): IDisposable;
50
52
  getServerDefinition(collectionRef: McpDefinitionReference, definitionRef: McpDefinitionReference): IObservable<{
@@ -31,6 +31,7 @@ import { AUX_WINDOW_GROUP } from '@codingame/monaco-vscode-api/vscode/vs/workben
31
31
  import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
32
32
  import { IMcpDevModeDebugging } from './mcpDevMode.service.js';
33
33
  import { McpRegistryInputStorage } from './mcpRegistryInputStorage.js';
34
+ import { IMcpSandboxService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpSandboxService.service';
34
35
  import { McpServerConnection } from './mcpServerConnection.js';
35
36
  import { LazyCollectionState, UserInteractionRequiredError, McpServerTrust, McpStartServerInteraction } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
36
37
  import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
@@ -53,6 +54,7 @@ let McpRegistry = class McpRegistry extends Disposable {
53
54
  _quickInputService,
54
55
  _labelService,
55
56
  _logService,
57
+ _mcpSandboxService,
56
58
  _workspaceTrustManagementService,
57
59
  _workspaceTrustRequestService
58
60
  ) {
@@ -65,6 +67,7 @@ let McpRegistry = class McpRegistry extends Disposable {
65
67
  this._quickInputService = _quickInputService;
66
68
  this._labelService = _labelService;
67
69
  this._logService = _logService;
70
+ this._mcpSandboxService = _mcpSandboxService;
68
71
  this._workspaceTrustManagementService = _workspaceTrustManagementService;
69
72
  this._workspaceTrustRequestService = _workspaceTrustRequestService;
70
73
  this._collections = observableValue("collections", []);
@@ -224,7 +227,7 @@ let McpRegistry = class McpRegistry extends Disposable {
224
227
  if (errorOnUserInteraction) {
225
228
  throw ( new UserInteractionRequiredError("workspaceTrust"));
226
229
  } else if (!(await this._workspaceTrustRequestService.requestWorkspaceTrust({
227
- message: ( localize(9539, "This MCP server definition is defined in your workspace files."))
230
+ message: ( localize(10429, "This MCP server definition is defined in your workspace files."))
228
231
  }))) {
229
232
  return false;
230
233
  }
@@ -302,7 +305,7 @@ let McpRegistry = class McpRegistry extends Disposable {
302
305
  const originURI = r.definition.presentation?.origin?.uri || r.collection.presentation?.origin;
303
306
  let labelWithOrigin = originURI ? `[\`${r.definition.label}\`](${originURI})` : "`" + r.definition.label + "`";
304
307
  if (r.collection.source instanceof ExtensionIdentifier) {
305
- labelWithOrigin += ` (${( localize(9540, "from {0}", r.collection.source.value))})`;
308
+ labelWithOrigin += ` (${( localize(10430, "from {0}", r.collection.source.value))})`;
306
309
  }
307
310
  return labelWithOrigin;
308
311
  }
@@ -312,12 +315,12 @@ let McpRegistry = class McpRegistry extends Disposable {
312
315
  const {
313
316
  result
314
317
  } = await this._dialogService.prompt({
315
- message: ( localize(9541, "Trust and run MCP server {0}?", def.definition.label)),
318
+ message: ( localize(10431, "Trust and run MCP server {0}?", def.definition.label)),
316
319
  custom: {
317
320
  icon: Codicon.shield,
318
321
  markdownDetails: [{
319
322
  markdown: ( new MarkdownString(( localize(
320
- 9542,
323
+ 10432,
321
324
  "The MCP server {0} was updated. MCP servers may add context to your chat session and lead to unexpected behavior. Do you want to trust and run this server?",
322
325
  labelFor(def)
323
326
  )))),
@@ -330,10 +333,10 @@ let McpRegistry = class McpRegistry extends Disposable {
330
333
  }]
331
334
  },
332
335
  buttons: [{
333
- label: ( localize(9543, "Trust")),
336
+ label: ( localize(10433, "Trust")),
334
337
  run: () => true
335
338
  }, {
336
- label: ( localize(9544, "Do not trust")),
339
+ label: ( localize(10434, "Do not trust")),
337
340
  run: () => false
338
341
  }]
339
342
  });
@@ -343,12 +346,12 @@ let McpRegistry = class McpRegistry extends Disposable {
343
346
  const {
344
347
  result
345
348
  } = await this._dialogService.prompt({
346
- message: ( localize(9545, "Trust and run {0} MCP servers?", definitions.length)),
349
+ message: ( localize(10435, "Trust and run {0} MCP servers?", definitions.length)),
347
350
  custom: {
348
351
  icon: Codicon.shield,
349
352
  markdownDetails: [{
350
353
  markdown: ( new MarkdownString(( localize(
351
- 9546,
354
+ 10436,
352
355
  "Several updated MCP servers were discovered:\n\n{0}\n\n MCP servers may add context to your chat session and lead to unexpected behavior. Do you want to trust and run these server?",
353
356
  list
354
357
  )))),
@@ -361,13 +364,13 @@ let McpRegistry = class McpRegistry extends Disposable {
361
364
  }]
362
365
  },
363
366
  buttons: [{
364
- label: ( localize(9543, "Trust")),
367
+ label: ( localize(10433, "Trust")),
365
368
  run: () => "all"
366
369
  }, {
367
- label: ( localize(9547, "Pick Trusted")),
370
+ label: ( localize(10437, "Pick Trusted")),
368
371
  run: () => "pick"
369
372
  }, {
370
- label: ( localize(9544, "Do not trust")),
373
+ label: ( localize(10434, "Do not trust")),
371
374
  run: () => "none"
372
375
  }]
373
376
  });
@@ -423,13 +426,13 @@ let McpRegistry = class McpRegistry extends Disposable {
423
426
  }
424
427
  }));
425
428
  return ( new Promise(resolve => {
426
- picker.onDidAccept(() => {
429
+ store.add(picker.onDidAccept(() => {
427
430
  resolve(( picker.selectedItems.map(item => item.definitonId)));
428
431
  picker.hide();
429
- });
430
- picker.onDidHide(() => {
432
+ }));
433
+ store.add(picker.onDidHide(() => {
431
434
  resolve(undefined);
432
- });
435
+ }));
433
436
  picker.show();
434
437
  })).finally(() => store.dispose());
435
438
  }
@@ -518,20 +521,26 @@ let McpRegistry = class McpRegistry extends Disposable {
518
521
  accessor => accessor.get(IMcpDevModeDebugging).transform(definition, launch)
519
522
  );
520
523
  }
524
+ launch = await this._mcpSandboxService.launchInSandboxIfEnabled(
525
+ definition,
526
+ launch,
527
+ collection.remoteAuthority ?? undefined,
528
+ collection.configTarget
529
+ );
521
530
  } catch (e) {
522
531
  if (e instanceof UserInteractionRequiredError) {
523
532
  throw e;
524
533
  }
525
534
  this._notificationService.notify({
526
535
  severity: Severity.Error,
527
- message: ( localize(9548, "Error starting {0}: {1}", definition.label, String(e))),
536
+ message: ( localize(10438, "Error starting {0}: {1}", definition.label, String(e))),
528
537
  actions: {
529
538
  primary: collection.presentation?.origin && [{
530
539
  id: "mcp.launchError.openConfig",
531
540
  class: undefined,
532
541
  enabled: true,
533
542
  tooltip: "",
534
- label: ( localize(9549, "Open Configuration")),
543
+ label: ( localize(10439, "Open Configuration")),
535
544
  run: () => this._editorService.openEditor({
536
545
  resource: collection.presentation.origin,
537
546
  options: {
@@ -555,6 +564,6 @@ let McpRegistry = class McpRegistry extends Disposable {
555
564
  );
556
565
  }
557
566
  };
558
- McpRegistry = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, IConfigurationResolverService)), ( __param(2, IDialogService)), ( __param(3, INotificationService)), ( __param(4, IEditorService)), ( __param(5, IConfigurationService)), ( __param(6, IQuickInputService)), ( __param(7, ILabelService)), ( __param(8, ILogService)), ( __param(9, IWorkspaceTrustManagementService)), ( __param(10, IWorkspaceTrustRequestService))], McpRegistry));
567
+ McpRegistry = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, IConfigurationResolverService)), ( __param(2, IDialogService)), ( __param(3, INotificationService)), ( __param(4, IEditorService)), ( __param(5, IConfigurationService)), ( __param(6, IQuickInputService)), ( __param(7, ILabelService)), ( __param(8, ILogService)), ( __param(9, IMcpSandboxService)), ( __param(10, IWorkspaceTrustManagementService)), ( __param(11, IWorkspaceTrustRequestService))], McpRegistry));
559
568
 
560
569
  export { McpRegistry };
@@ -41,7 +41,7 @@ let McpSamplingLog = class McpSamplingLog extends Disposable {
41
41
  }
42
42
  const parts = [];
43
43
  const total = record.bins.reduce((sum, value) => sum + value, 0);
44
- parts.push(( localize(9550, "{0} total requests in the last 7 days.", total)));
44
+ parts.push(( localize(10440, "{0} total requests in the last 7 days.", total)));
45
45
  parts.push(this._formatRecentRequests(record));
46
46
  return parts.join("\n");
47
47
  }
@@ -32,6 +32,7 @@ export declare class McpSamplingService extends Disposable implements IMcpSampli
32
32
  * a reason why no model could be selected.
33
33
  */
34
34
  private _getMatchingModelInner;
35
+ private _getDefaultModels;
35
36
  private _configKey;
36
37
  getConfig(server: IMcpServer): IMcpServerSamplingConfiguration;
37
38
  /**
@@ -13,11 +13,10 @@ import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform
13
13
  import { ConfigurationTarget, getConfigValueInTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
14
14
  import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
15
15
  import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
16
- import { ExtensionIdentifier } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
17
16
  import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
18
17
  import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
19
18
  import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
20
- import { ChatConfiguration, ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
19
+ import { ChatConfiguration } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
21
20
  import { ChatMessageRole } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
22
21
  import { ILanguageModelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service';
23
22
  import { McpCommandIds } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpCommandIds';
@@ -85,7 +84,7 @@ let McpSamplingService = class McpSamplingService extends Disposable {
85
84
  });
86
85
  }
87
86
  const model = await this._modelSequencer.queue(() => this._getMatchingModel(opts));
88
- const response = await this._languageModelsService.sendChatRequest(model, ( new ExtensionIdentifier("core")), messages, {}, token);
87
+ const response = await this._languageModelsService.sendChatRequest(model, undefined, messages, {}, token);
89
88
  let responseText = "";
90
89
  const streaming = (async () => {
91
90
  for await (const part of response.stream) {
@@ -132,11 +131,11 @@ let McpSamplingService = class McpSamplingService extends Disposable {
132
131
  return this._getMatchingModel(opts);
133
132
  }
134
133
  const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
135
- 9551,
134
+ 10441,
136
135
  "Allow MCP tools from \"{0}\" to make LLM requests?",
137
136
  opts.server.definition.label
138
137
  )), ( localize(
139
- 9552,
138
+ 10442,
140
139
  "The MCP server \"{0}\" has issued a request to make a language model call. Do you want to allow it to make requests during chat?",
141
140
  opts.server.definition.label
142
141
  )), this.allowButtons(opts.server, "allowedDuringChat"));
@@ -150,11 +149,11 @@ let McpSamplingService = class McpSamplingService extends Disposable {
150
149
  return this._getMatchingModel(opts);
151
150
  }
152
151
  const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
153
- 9553,
152
+ 10443,
154
153
  "Allow MCP server \"{0}\" to make LLM requests?",
155
154
  opts.server.definition.label
156
155
  )), ( localize(
157
- 9554,
156
+ 10444,
158
157
  "The MCP server \"{0}\" has issued a request to make a language model call. Do you want to allow it to make requests, outside of tool calls during chat?",
159
158
  opts.server.definition.label
160
159
  )), this.allowButtons(opts.server, "allowedOutsideChat"));
@@ -166,12 +165,12 @@ let McpSamplingService = class McpSamplingService extends Disposable {
166
165
  throw McpError.notAllowed();
167
166
  } else if (model === ModelMatch.NoMatchingModel) {
168
167
  const newlyPickedModels = opts.isDuringToolCall ? await this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server) : await this._notify(( localize(
169
- 9555,
168
+ 10445,
170
169
  "MCP server \"{0}\" triggered a language model request, but it has no allowlisted models.",
171
170
  opts.server.definition.label
172
171
  )), {
173
- [( localize(9556, "Configure"))]: () => this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server),
174
- [( localize(9557, "Cancel"))]: () => Promise.resolve(undefined)
172
+ [( localize(10446, "Configure"))]: () => this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server),
173
+ [( localize(10447, "Cancel"))]: () => Promise.resolve(undefined)
175
174
  });
176
175
  if (newlyPickedModels) {
177
176
  return this._getMatchingModel(opts);
@@ -182,19 +181,19 @@ let McpSamplingService = class McpSamplingService extends Disposable {
182
181
  }
183
182
  allowButtons(server, key) {
184
183
  return {
185
- [( localize(9558, "Allow in this Session"))]: async () => {
184
+ [( localize(10448, "Allow in this Session"))]: async () => {
186
185
  this._sessionSets[key].set(server.definition.id, true);
187
186
  return true;
188
187
  },
189
- [( localize(9559, "Always"))]: async () => {
188
+ [( localize(10449, "Always"))]: async () => {
190
189
  await this.updateConfig(server, c => c[key] = true);
191
190
  return true;
192
191
  },
193
- [( localize(9560, "Not Now"))]: async () => {
192
+ [( localize(10450, "Not Now"))]: async () => {
194
193
  this._sessionSets[key].set(server.definition.id, false);
195
194
  return false;
196
195
  },
197
- [( localize(9561, "Never"))]: async () => {
196
+ [( localize(10451, "Never"))]: async () => {
198
197
  await this.updateConfig(server, c => c[key] = false);
199
198
  return false;
200
199
  }
@@ -232,10 +231,7 @@ let McpSamplingService = class McpSamplingService extends Disposable {
232
231
  } else if (!isDuringToolCall && !config.allowedOutsideChat && !( this._sessionSets.allowedOutsideChat.has(server.definition.id))) {
233
232
  return config.allowedOutsideChat === undefined ? ModelMatch.UnsureAllowedOutsideChat : ModelMatch.NotAllowed;
234
233
  }
235
- const foundModelIdsDeep = config.allowedModels?.filter(m => !!this._languageModelsService.lookupLanguageModel(m)) || this._languageModelsService.getLanguageModelIds().filter(
236
- m => this._languageModelsService.lookupLanguageModel(m)?.isDefaultForLocation[ChatAgentLocation.Chat]
237
- );
238
- const foundModelIds = foundModelIdsDeep.flat().sort((a, b) => b.length - a.length);
234
+ const foundModelIds = config.allowedModels?.filter(m => !!this._languageModelsService.lookupLanguageModel(m)) || this._getDefaultModels();
239
235
  if (!foundModelIds.length) {
240
236
  return ModelMatch.NoMatchingModel;
241
237
  }
@@ -250,6 +246,20 @@ let McpSamplingService = class McpSamplingService extends Disposable {
250
246
  }
251
247
  return foundModelIds[0];
252
248
  }
249
+ _getDefaultModels() {
250
+ const candidates = ( this._languageModelsService.getLanguageModelIds().map(m => {
251
+ const model = this._languageModelsService.lookupLanguageModel(m);
252
+ return model && !model.multiplierNumeric && !model.targetChatSessionType ? {
253
+ model,
254
+ id: m
255
+ } : undefined;
256
+ })).filter(isDefined);
257
+ const someDefault = candidates.findIndex(c => ( ( Object.values(c.model.isDefaultForLocation)).some(Boolean)));
258
+ if (someDefault !== -1) {
259
+ [candidates[0], candidates[someDefault]] = [candidates[someDefault], candidates[0]];
260
+ }
261
+ return ( candidates.map(c => c.id));
262
+ }
253
263
  _configKey(server) {
254
264
  return `${server.collection.label}: ${server.definition.label}`;
255
265
  }
@@ -0,0 +1,47 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
3
+ import { ConfigurationTarget } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration";
4
+ import { IEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service";
5
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
6
+ import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
7
+ import { IMcpResourceScannerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpResourceScannerService.service";
8
+ import { IRemoteAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service";
9
+ import { IMcpSandboxConfiguration } from "@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpPlatformTypes";
10
+ import { IMcpPotentialSandboxBlock, McpServerDefinition, McpServerLaunch } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
11
+ import { IMcpSandboxService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpSandboxService.service";
12
+ export type SandboxConfigSuggestionResult = {
13
+ message: string;
14
+ sandboxConfig: IMcpSandboxConfiguration;
15
+ };
16
+ export declare class McpSandboxService extends Disposable implements IMcpSandboxService {
17
+ private readonly _fileService;
18
+ private readonly _environmentService;
19
+ private readonly _logService;
20
+ private readonly _mcpResourceScannerService;
21
+ private readonly _remoteAgentService;
22
+ readonly _serviceBrand: undefined;
23
+ private _sandboxSettingsId;
24
+ private _remoteEnvDetailsPromise;
25
+ private readonly _defaultAllowedDomains;
26
+ private _sandboxConfigPerConfigurationTarget;
27
+ constructor(_fileService: IFileService, _environmentService: IEnvironmentService, _logService: ILogService, _mcpResourceScannerService: IMcpResourceScannerService, _remoteAgentService: IRemoteAgentService);
28
+ isEnabled(serverDef: McpServerDefinition, remoteAuthority?: string): Promise<boolean>;
29
+ launchInSandboxIfEnabled(serverDef: McpServerDefinition, launch: McpServerLaunch, remoteAuthority: string | undefined, configTarget: ConfigurationTarget): Promise<McpServerLaunch>;
30
+ getSandboxConfigSuggestionMessage(serverLabel: string, potentialBlocks: readonly IMcpPotentialSandboxBlock[], existingSandboxConfig?: IMcpSandboxConfiguration): SandboxConfigSuggestionResult | undefined;
31
+ applySandboxConfigSuggestion(serverDef: McpServerDefinition, mcpResource: URI, configTarget: ConfigurationTarget, potentialBlocks: readonly IMcpPotentialSandboxBlock[], suggestedSandboxConfig?: IMcpSandboxConfiguration): Promise<boolean>;
32
+ private _getSandboxConfigSuggestions;
33
+ private _toMcpResourceTarget;
34
+ private _resolveSandboxLaunchDetails;
35
+ private _getExecPath;
36
+ private _getSandboxEnvVariables;
37
+ private _getSandboxCommandArgs;
38
+ private _getRemoteEnv;
39
+ private _getOperatingSystem;
40
+ private _getAppRoot;
41
+ private _getTempDir;
42
+ private _updateSandboxConfig;
43
+ private _withDefaultSandboxConfig;
44
+ private _getDefaultAllowWrite;
45
+ private _pathJoin;
46
+ private _getPathDelimiter;
47
+ }