@codingame/monaco-vscode-mcp-service-override 37.2.0 → 37.3.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/common.d.ts +2 -0
- package/common.js +56 -0
- package/index.d.ts +1 -2
- package/index.js +1 -52
- package/package.json +10 -2
- package/session.d.ts +1 -0
- package/session.js +2 -0
- package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +3 -3
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +8 -8
- package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.js +7 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadMcp.js +18 -18
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +3 -3
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +108 -108
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +47 -47
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayService.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +37 -37
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpMigration.js +20 -16
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.js +52 -50
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.js +45 -43
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerIcons.js +5 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.js +5 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +18 -18
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +14 -14
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +8 -6
- 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 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +13 -13
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +7 -7
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +25 -25
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpResourceFilesystem.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +28 -24
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.js +6 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +3 -3
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +13 -11
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +13 -18
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpUsageService.js +3 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpDevMode.service.d.ts +0 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpDevMode.service.js +0 -6
|
@@ -29,7 +29,7 @@ import { IConfigurationResolverService } from '@codingame/monaco-vscode-api/vsco
|
|
|
29
29
|
import { ConfigurationResolverExpression } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolverExpression';
|
|
30
30
|
import { AUX_WINDOW_GROUP } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService';
|
|
31
31
|
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
32
|
-
import { IMcpDevModeDebugging } from '
|
|
32
|
+
import { IMcpDevModeDebugging } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpDevMode.service';
|
|
33
33
|
import { McpRegistryInputStorage } from './mcpRegistryInputStorage.js';
|
|
34
34
|
import { IMcpSandboxService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpSandboxService.service';
|
|
35
35
|
import { McpServerConnection } from './mcpServerConnection.js';
|
|
@@ -139,7 +139,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
139
139
|
if (toReplace && !toReplace.lazy) {
|
|
140
140
|
return Disposable.None;
|
|
141
141
|
} else if (toReplace) {
|
|
142
|
-
this._collections.set(
|
|
142
|
+
this._collections.set(currentCollections.map(c => c === toReplace ? collection : c), undefined);
|
|
143
143
|
} else {
|
|
144
144
|
this._collections.set(
|
|
145
145
|
[...currentCollections, collection].sort((a, b) => a.order - b.order),
|
|
@@ -154,8 +154,8 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
getServerDefinition(collectionRef, definitionRef) {
|
|
157
|
-
const collectionObs =
|
|
158
|
-
return
|
|
157
|
+
const collectionObs = this._collections.map(cols => cols.find(c => c.id === collectionRef.id));
|
|
158
|
+
return collectionObs.map((collection, reader) => {
|
|
159
159
|
if (collection && !this.isCollectionAllowed(collection, this._strictPluginOnlyCustomization.read(reader))) {
|
|
160
160
|
return {
|
|
161
161
|
collection: undefined,
|
|
@@ -167,7 +167,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
167
167
|
collection,
|
|
168
168
|
server
|
|
169
169
|
};
|
|
170
|
-
})
|
|
170
|
+
});
|
|
171
171
|
}
|
|
172
172
|
async discoverCollections() {
|
|
173
173
|
const strictPluginOnly = this._strictPluginOnlyCustomization.get();
|
|
@@ -175,7 +175,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
175
175
|
c => this.isCollectionAllowed(c, strictPluginOnly) && c.lazy && !c.lazy.isCached
|
|
176
176
|
);
|
|
177
177
|
this._ongoingLazyActivations.set(this._ongoingLazyActivations.get() + 1, undefined);
|
|
178
|
-
await Promise.all(
|
|
178
|
+
await Promise.all(toDiscover.map(c => c.lazy?.load())).finally(() => {
|
|
179
179
|
this._ongoingLazyActivations.set(this._ongoingLazyActivations.get() - 1, undefined);
|
|
180
180
|
});
|
|
181
181
|
const found = [];
|
|
@@ -245,7 +245,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
245
245
|
if (errorOnUserInteraction) {
|
|
246
246
|
throw ( new UserInteractionRequiredError("workspaceTrust"));
|
|
247
247
|
} else if (!(await this._workspaceTrustRequestService.requestWorkspaceTrust({
|
|
248
|
-
message: ( localize(
|
|
248
|
+
message: ( localize(16259, "This MCP server definition is defined in your workspace files."))
|
|
249
249
|
}))) {
|
|
250
250
|
return false;
|
|
251
251
|
}
|
|
@@ -308,7 +308,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
310
|
reader.dispose();
|
|
311
|
-
interaction.choice ??= this._promptForTrustOpenDialog(
|
|
311
|
+
interaction.choice ??= this._promptForTrustOpenDialog([...( map.values())].map(v => v.s === "waiting" ? v : undefined).filter(isDefined));
|
|
312
312
|
resolve(interaction.choice);
|
|
313
313
|
});
|
|
314
314
|
}));
|
|
@@ -323,7 +323,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
323
323
|
const originURI = r.definition.presentation?.origin?.uri || r.collection.presentation?.origin;
|
|
324
324
|
let labelWithOrigin = originURI ? `[\`${r.definition.label}\`](${originURI})` : "`" + r.definition.label + "`";
|
|
325
325
|
if (r.collection.source instanceof ExtensionIdentifier) {
|
|
326
|
-
labelWithOrigin += ` (${( localize(
|
|
326
|
+
labelWithOrigin += ` (${( localize(16260, "from {0}", r.collection.source.value))})`;
|
|
327
327
|
}
|
|
328
328
|
return labelWithOrigin;
|
|
329
329
|
}
|
|
@@ -333,12 +333,12 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
333
333
|
const {
|
|
334
334
|
result
|
|
335
335
|
} = await this._dialogService.prompt({
|
|
336
|
-
message: ( localize(
|
|
336
|
+
message: ( localize(16261, "Trust and run MCP server {0}?", def.definition.label)),
|
|
337
337
|
custom: {
|
|
338
338
|
icon: Codicon.shield,
|
|
339
339
|
markdownDetails: [{
|
|
340
340
|
markdown: ( new MarkdownString(( localize(
|
|
341
|
-
|
|
341
|
+
16262,
|
|
342
342
|
"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?",
|
|
343
343
|
labelFor(def)
|
|
344
344
|
)))),
|
|
@@ -351,25 +351,25 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
351
351
|
}]
|
|
352
352
|
},
|
|
353
353
|
buttons: [{
|
|
354
|
-
label: ( localize(
|
|
354
|
+
label: ( localize(16263, "Trust")),
|
|
355
355
|
run: () => true
|
|
356
356
|
}, {
|
|
357
|
-
label: ( localize(
|
|
357
|
+
label: ( localize(16264, "Do not trust")),
|
|
358
358
|
run: () => false
|
|
359
359
|
}]
|
|
360
360
|
});
|
|
361
361
|
return result === undefined ? undefined : (result ? [def.definition.id] : []);
|
|
362
362
|
}
|
|
363
|
-
const list =
|
|
363
|
+
const list = definitions.map(d => `- ${labelFor(d)}`).join("\n");
|
|
364
364
|
const {
|
|
365
365
|
result
|
|
366
366
|
} = await this._dialogService.prompt({
|
|
367
|
-
message: ( localize(
|
|
367
|
+
message: ( localize(16265, "Trust and run {0} MCP servers?", definitions.length)),
|
|
368
368
|
custom: {
|
|
369
369
|
icon: Codicon.shield,
|
|
370
370
|
markdownDetails: [{
|
|
371
371
|
markdown: ( new MarkdownString(( localize(
|
|
372
|
-
|
|
372
|
+
16266,
|
|
373
373
|
"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?",
|
|
374
374
|
list
|
|
375
375
|
)))),
|
|
@@ -382,20 +382,20 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
382
382
|
}]
|
|
383
383
|
},
|
|
384
384
|
buttons: [{
|
|
385
|
-
label: ( localize(
|
|
385
|
+
label: ( localize(16263, "Trust")),
|
|
386
386
|
run: () => "all"
|
|
387
387
|
}, {
|
|
388
|
-
label: ( localize(
|
|
388
|
+
label: ( localize(16267, "Pick Trusted")),
|
|
389
389
|
run: () => "pick"
|
|
390
390
|
}, {
|
|
391
|
-
label: ( localize(
|
|
391
|
+
label: ( localize(16264, "Do not trust")),
|
|
392
392
|
run: () => "none"
|
|
393
393
|
}]
|
|
394
394
|
});
|
|
395
395
|
if (result === undefined) {
|
|
396
396
|
return undefined;
|
|
397
397
|
} else if (result === "all") {
|
|
398
|
-
return
|
|
398
|
+
return definitions.map(d => d.definition.id);
|
|
399
399
|
} else if (result === "none") {
|
|
400
400
|
return [];
|
|
401
401
|
}
|
|
@@ -407,7 +407,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
407
407
|
useSeparators: false
|
|
408
408
|
}));
|
|
409
409
|
picker.canSelectMany = true;
|
|
410
|
-
picker.items =
|
|
410
|
+
picker.items = definitions.map((
|
|
411
411
|
{
|
|
412
412
|
definition,
|
|
413
413
|
collection
|
|
@@ -435,7 +435,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
435
435
|
picked: false,
|
|
436
436
|
buttons
|
|
437
437
|
};
|
|
438
|
-
})
|
|
438
|
+
});
|
|
439
439
|
picker.placeholder = "Select MCP servers to trust";
|
|
440
440
|
picker.ignoreFocusOut = true;
|
|
441
441
|
store.add(picker.onDidTriggerItemButton(e => {
|
|
@@ -445,7 +445,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
445
445
|
}));
|
|
446
446
|
return ( new Promise(resolve => {
|
|
447
447
|
store.add(picker.onDidAccept(() => {
|
|
448
|
-
resolve(
|
|
448
|
+
resolve(picker.selectedItems.map(item => item.definitonId));
|
|
449
449
|
picker.hide();
|
|
450
450
|
}));
|
|
451
451
|
store.add(picker.onDidHide(() => {
|
|
@@ -565,14 +565,14 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
565
565
|
}
|
|
566
566
|
this._notificationService.notify({
|
|
567
567
|
severity: Severity.Error,
|
|
568
|
-
message: ( localize(
|
|
568
|
+
message: ( localize(16268, "Error starting {0}: {1}", definition.label, String(e))),
|
|
569
569
|
actions: {
|
|
570
570
|
primary: collection.presentation?.origin && [{
|
|
571
571
|
id: "mcp.launchError.openConfig",
|
|
572
572
|
class: undefined,
|
|
573
573
|
enabled: true,
|
|
574
574
|
tooltip: "",
|
|
575
|
-
label: ( localize(
|
|
575
|
+
label: ( localize(16269, "Open Configuration")),
|
|
576
576
|
run: () => this._editorService.openEditor({
|
|
577
577
|
resource: collection.presentation.origin,
|
|
578
578
|
options: {
|
|
@@ -44,7 +44,7 @@ let McpResourceFilesystem = class McpResourceFilesystem extends Disposable {
|
|
|
44
44
|
return this._readFile(resource);
|
|
45
45
|
}
|
|
46
46
|
readFileStream(resource, opts, token) {
|
|
47
|
-
const stream = newWriteableStream(data => VSBuffer.concat(
|
|
47
|
+
const stream = newWriteableStream(data => VSBuffer.concat(data.map(data => VSBuffer.wrap(data))).buffer);
|
|
48
48
|
this._readFile(resource, token).then(data => {
|
|
49
49
|
if (opts.position) {
|
|
50
50
|
data = data.slice(opts.position);
|
|
@@ -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(
|
|
44
|
+
parts.push(( localize(16270, "{0} total requests in the last 7 days.", total)));
|
|
45
45
|
parts.push(this._formatRecentRequests(record));
|
|
46
46
|
return parts.join("\n");
|
|
47
47
|
}
|
|
@@ -55,8 +55,8 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
55
55
|
this._logs = this._register(instaService.createInstance(McpSamplingLog));
|
|
56
56
|
}
|
|
57
57
|
async sample(opts, token = CancellationToken.None) {
|
|
58
|
-
const messages =
|
|
59
|
-
const content =
|
|
58
|
+
const messages = opts.params.messages.map(message => {
|
|
59
|
+
const content = asArray(message.content).map(part => part.type === "text" ? {
|
|
60
60
|
type: "text",
|
|
61
61
|
value: part.text
|
|
62
62
|
} : part.type === "image" || part.type === "audio" ? {
|
|
@@ -65,7 +65,7 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
65
65
|
mimeType: part.mimeType,
|
|
66
66
|
data: decodeBase64(part.data)
|
|
67
67
|
}
|
|
68
|
-
} : undefined)
|
|
68
|
+
} : undefined).filter(isDefined);
|
|
69
69
|
if (!content.length) {
|
|
70
70
|
return undefined;
|
|
71
71
|
}
|
|
@@ -73,7 +73,7 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
73
73
|
role: message.role === "assistant" ? ChatMessageRole.Assistant : ChatMessageRole.User,
|
|
74
74
|
content
|
|
75
75
|
};
|
|
76
|
-
})
|
|
76
|
+
}).filter(isDefined);
|
|
77
77
|
if (opts.params.systemPrompt) {
|
|
78
78
|
messages.unshift({
|
|
79
79
|
role: ChatMessageRole.System,
|
|
@@ -131,11 +131,11 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
131
131
|
return this._getMatchingModel(opts);
|
|
132
132
|
}
|
|
133
133
|
const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
|
|
134
|
-
|
|
134
|
+
16271,
|
|
135
135
|
"Allow MCP tools from \"{0}\" to make LLM requests?",
|
|
136
136
|
opts.server.definition.label
|
|
137
137
|
)), ( localize(
|
|
138
|
-
|
|
138
|
+
16272,
|
|
139
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?",
|
|
140
140
|
opts.server.definition.label
|
|
141
141
|
)), this.allowButtons(opts.server, "allowedDuringChat"));
|
|
@@ -149,11 +149,11 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
149
149
|
return this._getMatchingModel(opts);
|
|
150
150
|
}
|
|
151
151
|
const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
|
|
152
|
-
|
|
152
|
+
16273,
|
|
153
153
|
"Allow MCP server \"{0}\" to make LLM requests?",
|
|
154
154
|
opts.server.definition.label
|
|
155
155
|
)), ( localize(
|
|
156
|
-
|
|
156
|
+
16274,
|
|
157
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?",
|
|
158
158
|
opts.server.definition.label
|
|
159
159
|
)), this.allowButtons(opts.server, "allowedOutsideChat"));
|
|
@@ -165,12 +165,12 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
165
165
|
throw McpError.notAllowed();
|
|
166
166
|
} else if (model === ModelMatch.NoMatchingModel) {
|
|
167
167
|
const newlyPickedModels = opts.isDuringToolCall ? await this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server) : await this._notify(( localize(
|
|
168
|
-
|
|
168
|
+
16275,
|
|
169
169
|
"MCP server \"{0}\" triggered a language model request, but it has no allowlisted models.",
|
|
170
170
|
opts.server.definition.label
|
|
171
171
|
)), {
|
|
172
|
-
[( localize(
|
|
173
|
-
[( localize(
|
|
172
|
+
[( localize(16276, "Configure"))]: () => this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server),
|
|
173
|
+
[( localize(16277, "Cancel"))]: () => Promise.resolve(undefined)
|
|
174
174
|
});
|
|
175
175
|
if (newlyPickedModels) {
|
|
176
176
|
return this._getMatchingModel(opts);
|
|
@@ -181,19 +181,19 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
181
181
|
}
|
|
182
182
|
allowButtons(server, key) {
|
|
183
183
|
return {
|
|
184
|
-
[( localize(
|
|
184
|
+
[( localize(16278, "Allow in this Session"))]: async () => {
|
|
185
185
|
this._sessionSets[key].set(server.definition.id, true);
|
|
186
186
|
return true;
|
|
187
187
|
},
|
|
188
|
-
[( localize(
|
|
188
|
+
[( localize(16279, "Always"))]: async () => {
|
|
189
189
|
await this.updateConfig(server, c => c[key] = true);
|
|
190
190
|
return true;
|
|
191
191
|
},
|
|
192
|
-
[( localize(
|
|
192
|
+
[( localize(16280, "Not Now"))]: async () => {
|
|
193
193
|
this._sessionSets[key].set(server.definition.id, false);
|
|
194
194
|
return false;
|
|
195
195
|
},
|
|
196
|
-
[( localize(
|
|
196
|
+
[( localize(16281, "Never"))]: async () => {
|
|
197
197
|
await this.updateConfig(server, c => c[key] = false);
|
|
198
198
|
return false;
|
|
199
199
|
}
|
|
@@ -205,10 +205,10 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
205
205
|
type: "question",
|
|
206
206
|
title: title,
|
|
207
207
|
message,
|
|
208
|
-
buttons:
|
|
208
|
+
buttons: Object.entries(buttons).map(([label, run]) => ({
|
|
209
209
|
label,
|
|
210
210
|
run
|
|
211
|
-
}))
|
|
211
|
+
}))
|
|
212
212
|
});
|
|
213
213
|
return await result.result;
|
|
214
214
|
} else {
|
|
@@ -217,10 +217,14 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
217
217
|
}
|
|
218
218
|
async _notify(message, buttons) {
|
|
219
219
|
return await ( new Promise(resolve => {
|
|
220
|
-
const handle = this._notificationService.prompt(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
const handle = this._notificationService.prompt(
|
|
221
|
+
Severity.Info,
|
|
222
|
+
message,
|
|
223
|
+
Object.entries(buttons).map(([label, action]) => ({
|
|
224
|
+
label,
|
|
225
|
+
run: () => resolve(action())
|
|
226
|
+
}))
|
|
227
|
+
);
|
|
224
228
|
Event.once(handle.onDidClose)(() => resolve(undefined));
|
|
225
229
|
}));
|
|
226
230
|
}
|
|
@@ -247,18 +251,18 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
247
251
|
return foundModelIds[0];
|
|
248
252
|
}
|
|
249
253
|
_getDefaultModels() {
|
|
250
|
-
const candidates =
|
|
254
|
+
const candidates = this._languageModelsService.getLanguageModelIds().map(m => {
|
|
251
255
|
const model = this._languageModelsService.lookupLanguageModel(m);
|
|
252
256
|
return model && !model.multiplierNumeric && !model.targetChatSessionType ? {
|
|
253
257
|
model,
|
|
254
258
|
id: m
|
|
255
259
|
} : undefined;
|
|
256
|
-
})
|
|
260
|
+
}).filter(isDefined);
|
|
257
261
|
const someDefault = candidates.findIndex(c => ( ( Object.values(c.model.isDefaultForLocation)).some(Boolean)));
|
|
258
262
|
if (someDefault !== -1) {
|
|
259
263
|
[candidates[0], candidates[someDefault]] = [candidates[someDefault], candidates[0]];
|
|
260
264
|
}
|
|
261
|
-
return
|
|
265
|
+
return candidates.map(c => c.id);
|
|
262
266
|
}
|
|
263
267
|
_configKey(server) {
|
|
264
268
|
return `${server.collection.label}: ${server.definition.label}`;
|
|
@@ -88,7 +88,7 @@ let McpSandboxService = class McpSandboxService extends Disposable {
|
|
|
88
88
|
);
|
|
89
89
|
const launchDetails = await this._resolveSandboxLaunchDetails(configTarget, remoteAuthority, launch.sandbox, launchCwd);
|
|
90
90
|
const quotedCommand = this._quoteShellArgument(launch.command);
|
|
91
|
-
const quotedArgs =
|
|
91
|
+
const quotedArgs = launch.args.map(arg => this._quoteShellArgument(arg));
|
|
92
92
|
const sandboxArgs = this._getSandboxCommandArgs(quotedCommand, quotedArgs, launchDetails.sandboxConfigPath);
|
|
93
93
|
const sandboxEnv = await this._getSandboxEnvVariables(launch.env, launchDetails.tempDir, launchDetails.rgPath, remoteAuthority);
|
|
94
94
|
if (launchDetails.srtPath) {
|
|
@@ -130,12 +130,12 @@ let McpSandboxService = class McpSandboxService extends Disposable {
|
|
|
130
130
|
const allowedDomainsList = suggestions.allowedDomains;
|
|
131
131
|
const suggestionLines = [];
|
|
132
132
|
if (allowedDomainsList.length) {
|
|
133
|
-
const shown =
|
|
134
|
-
suggestionLines.push(( localize(
|
|
133
|
+
const shown = allowedDomainsList.map(domain => `"${domain}"`).join(", ");
|
|
134
|
+
suggestionLines.push(( localize(16282, "Add to `sandbox.network.allowedDomains`: {0}", shown)));
|
|
135
135
|
}
|
|
136
136
|
if (allowWriteList.length) {
|
|
137
|
-
const shown =
|
|
138
|
-
suggestionLines.push(( localize(
|
|
137
|
+
const shown = allowWriteList.map(path => `"${path}"`).join(", ");
|
|
138
|
+
suggestionLines.push(( localize(16283, "Add to `sandbox.filesystem.allowWrite`: {0}", shown)));
|
|
139
139
|
}
|
|
140
140
|
const sandboxConfig = {};
|
|
141
141
|
if (allowedDomainsList.length) {
|
|
@@ -150,7 +150,7 @@ let McpSandboxService = class McpSandboxService extends Disposable {
|
|
|
150
150
|
}
|
|
151
151
|
return {
|
|
152
152
|
message: ( localize(
|
|
153
|
-
|
|
153
|
+
16284,
|
|
154
154
|
"The MCP server {0} reported potential sandbox blocks. VS Code found possible sandbox configuration updates:\n{1}",
|
|
155
155
|
serverLabel,
|
|
156
156
|
suggestionLines.join("\n")
|
|
@@ -52,7 +52,7 @@ let McpServerConnection = class McpServerConnection extends Disposable {
|
|
|
52
52
|
this._state.set({
|
|
53
53
|
state: McpConnectionState.Kind.Starting
|
|
54
54
|
}, undefined);
|
|
55
|
-
this._logger.info(( localize(
|
|
55
|
+
this._logger.info(( localize(16300, "Starting server {0}", this.definition.label)));
|
|
56
56
|
try {
|
|
57
57
|
const launch = this._delegate.start(this._collection, this.definition, this.launchDefinition, {
|
|
58
58
|
errorOnUserInteraction: this._errorOnUserInteraction
|
|
@@ -89,7 +89,7 @@ let McpServerConnection = class McpServerConnection extends Disposable {
|
|
|
89
89
|
store.add(autorun(reader => {
|
|
90
90
|
const state = launch.state.read(reader);
|
|
91
91
|
this._state.set(state, undefined);
|
|
92
|
-
this._logger.info(( localize(
|
|
92
|
+
this._logger.info(( localize(16301, "Connection state: {0}", (McpConnectionState.toString(state)))));
|
|
93
93
|
if (state.state === McpConnectionState.Kind.Running && !didStart) {
|
|
94
94
|
didStart = true;
|
|
95
95
|
McpServerRequestHandler.create(this._instantiationService, {
|
|
@@ -128,7 +128,7 @@ let McpServerConnection = class McpServerConnection extends Disposable {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
async stop() {
|
|
131
|
-
this._logger.info(( localize(
|
|
131
|
+
this._logger.info(( localize(16302, "Stopping server {0}", this.definition.label)));
|
|
132
132
|
this._launch.value?.object.stop();
|
|
133
133
|
await this._waitForState(McpConnectionState.Kind.Stopped, McpConnectionState.Kind.Error);
|
|
134
134
|
}
|
|
@@ -569,7 +569,7 @@ class McpTask extends Disposable {
|
|
|
569
569
|
});
|
|
570
570
|
}, pollInterval));
|
|
571
571
|
}));
|
|
572
|
-
const lastStatus =
|
|
572
|
+
const lastStatus = this._lastTaskState.map(task => task.status);
|
|
573
573
|
store.add(autorun(reader => {
|
|
574
574
|
const status = lastStatus.read(reader);
|
|
575
575
|
if (status === "failed") {
|
|
@@ -41,7 +41,7 @@ let McpService = class McpService extends Disposable {
|
|
|
41
41
|
this.configurationService = configurationService;
|
|
42
42
|
this._currentAutoStarts = ( new Set());
|
|
43
43
|
this._servers = observableValue(this, []);
|
|
44
|
-
this.servers =
|
|
44
|
+
this.servers = this._servers.map(servers => servers.map(s => s.object));
|
|
45
45
|
this._prefixGenerator = ( new McpPrefixGenerator());
|
|
46
46
|
const baseEnablement = this._register(( new EnablementModel("mcp.enablement", storageService)));
|
|
47
47
|
const collisionBehavior = observableConfigValue(
|
|
@@ -119,11 +119,11 @@ let McpService = class McpService extends Disposable {
|
|
|
119
119
|
const requiringInteraction = [];
|
|
120
120
|
const update = () => state.set({
|
|
121
121
|
working: todo.size > 0,
|
|
122
|
-
starting:
|
|
122
|
+
starting: [...todo].map(t => t.definition),
|
|
123
123
|
serversRequiringInteraction: requiringInteraction
|
|
124
124
|
}, undefined);
|
|
125
125
|
update();
|
|
126
|
-
await Promise.all(
|
|
126
|
+
await Promise.all([...todo].map(async (server, i) => {
|
|
127
127
|
try {
|
|
128
128
|
await startServerAndWaitForLiveTools(server, {
|
|
129
129
|
interaction,
|
|
@@ -143,7 +143,7 @@ let McpService = class McpService extends Disposable {
|
|
|
143
143
|
update();
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
}))
|
|
146
|
+
}));
|
|
147
147
|
}
|
|
148
148
|
resetCaches() {
|
|
149
149
|
this.userCache.reset();
|
|
@@ -158,15 +158,17 @@ let McpService = class McpService extends Disposable {
|
|
|
158
158
|
async _activateCollections() {
|
|
159
159
|
const collections = await this._mcpRegistry.discoverCollections();
|
|
160
160
|
this.updateCollectedServers();
|
|
161
|
-
return ( new Set(
|
|
161
|
+
return ( new Set(collections.map(c => c.id)));
|
|
162
162
|
}
|
|
163
163
|
updateCollectedServers() {
|
|
164
|
-
const definitions = this._mcpRegistry.collections.get().flatMap(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
164
|
+
const definitions = this._mcpRegistry.collections.get().flatMap(
|
|
165
|
+
collectionDefinition => collectionDefinition.serverDefinitions.get().map(serverDefinition => {
|
|
166
|
+
return {
|
|
167
|
+
serverDefinition,
|
|
168
|
+
collectionDefinition
|
|
169
|
+
};
|
|
170
|
+
})
|
|
171
|
+
);
|
|
170
172
|
const nextDefinitions = ( new Set(definitions));
|
|
171
173
|
const currentServers = this._servers.get();
|
|
172
174
|
const nextServers = [];
|
|
@@ -6,7 +6,7 @@ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
|
6
6
|
import { MenuRegistry, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
7
7
|
import { CommandsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands';
|
|
8
8
|
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
9
|
-
import
|
|
9
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
|
|
10
10
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
|
|
11
11
|
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
12
12
|
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
@@ -18,7 +18,7 @@ import { IAuthenticationMcpUsageService } from '@codingame/monaco-vscode-api/vsc
|
|
|
18
18
|
import { IAuthenticationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
19
19
|
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
20
20
|
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
21
|
-
import
|
|
21
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
22
22
|
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
23
23
|
|
|
24
24
|
const SCOPESLIST_SEPARATOR = " ";
|
|
@@ -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(21565, "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
|
+
21566,
|
|
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(21567, "&&Allow")),
|
|
205
205
|
run: () => SessionPromptChoice.Allow
|
|
206
206
|
}, {
|
|
207
|
-
label: ( localize(
|
|
207
|
+
label: ( localize(21568, "&&Deny")),
|
|
208
208
|
run: () => SessionPromptChoice.Deny
|
|
209
209
|
}],
|
|
210
210
|
cancelButton: {
|
|
@@ -230,13 +230,13 @@ let AuthenticationMcpService = class AuthenticationMcpService extends Disposable
|
|
|
230
230
|
const quickPick = disposables.add(this.quickInputService.createQuickPick());
|
|
231
231
|
quickPick.ignoreFocusOut = true;
|
|
232
232
|
const accountsWithSessions = ( new Set());
|
|
233
|
-
const items =
|
|
233
|
+
const items =
|
|
234
234
|
availableSessions.filter(session => !( accountsWithSessions.has(session.account.label)) && accountsWithSessions.add(session.account.label)).map(session => {
|
|
235
235
|
return {
|
|
236
236
|
label: session.account.label,
|
|
237
237
|
session: session
|
|
238
238
|
};
|
|
239
|
-
})
|
|
239
|
+
});
|
|
240
240
|
allAccounts.forEach(account => {
|
|
241
241
|
if (!( accountsWithSessions.has(account.label))) {
|
|
242
242
|
items.push({
|
|
@@ -246,17 +246,17 @@ let AuthenticationMcpService = class AuthenticationMcpService extends Disposable
|
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
items.push({
|
|
249
|
-
label: ( localize(
|
|
249
|
+
label: ( localize(21569, "Sign in to another account"))
|
|
250
250
|
});
|
|
251
251
|
quickPick.items = items;
|
|
252
252
|
quickPick.title = ( localize(
|
|
253
|
-
|
|
253
|
+
21570,
|
|
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
|
+
21571,
|
|
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(21572, "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(21573, "Sign in with {0} to use {1} (1)", provider.label, mcpServerName))
|
|
384
384
|
}
|
|
385
385
|
}));
|
|
386
386
|
const signInCommand = CommandsRegistry.registerCommand({
|
|
@@ -418,10 +418,5 @@ let AuthenticationMcpService = class AuthenticationMcpService extends Disposable
|
|
|
418
418
|
}
|
|
419
419
|
};
|
|
420
420
|
AuthenticationMcpService = ( __decorate([( __param(0, IActivityService)), ( __param(1, IStorageService)), ( __param(2, IDialogService)), ( __param(3, IQuickInputService)), ( __param(4, IProductService)), ( __param(5, IAuthenticationService)), ( __param(6, IAuthenticationMcpUsageService)), ( __param(7, IAuthenticationMcpAccessService))], AuthenticationMcpService));
|
|
421
|
-
( registerSingleton(
|
|
422
|
-
IAuthenticationMcpService,
|
|
423
|
-
AuthenticationMcpService,
|
|
424
|
-
InstantiationType.Delayed
|
|
425
|
-
));
|
|
426
421
|
|
|
427
422
|
export { AuthenticationMcpService };
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpUsageService.js
CHANGED
|
@@ -35,7 +35,9 @@ let AuthenticationMcpUsageService = class AuthenticationMcpUsageService extends
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
async initializeUsageCache() {
|
|
38
|
-
await this._queue.queue(() => Promise.all(
|
|
38
|
+
await this._queue.queue(() => Promise.all(
|
|
39
|
+
this._authenticationService.getProviderIds().map(providerId => this._addToCache(providerId))
|
|
40
|
+
));
|
|
39
41
|
}
|
|
40
42
|
async hasUsedAuth(mcpServerId) {
|
|
41
43
|
await this._queue.whenIdle();
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { McpServerDefinition, McpServerLaunch } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
|
|
2
|
-
export interface IMcpDevModeDebugging {
|
|
3
|
-
readonly _serviceBrand: undefined;
|
|
4
|
-
transform(definition: McpServerDefinition, launch: McpServerLaunch): Promise<McpServerLaunch>;
|
|
5
|
-
}
|
|
6
|
-
export declare const IMcpDevModeDebugging: import("@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation").ServiceIdentifier<IMcpDevModeDebugging>;
|