@codingame/monaco-vscode-mcp-service-override 23.2.2 → 24.1.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 +19 -19
- package/package.json +2 -15
- package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.d.ts +1 -1
- package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +2 -2
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.d.ts +2 -2
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +4 -8
- package/vscode/src/vs/platform/mcp/common/mcpManagementIpc.d.ts +2 -2
- package/vscode/src/vs/platform/mcp/common/mcpManagementService.d.ts +2 -2
- package/vscode/src/vs/platform/mcp/common/mcpManagementService.js +3 -3
- package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.d.ts +2 -2
- package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +8 -8
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.d.ts +3 -2
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +43 -27
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +70 -70
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpDiscovery.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.d.ts +10 -4
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +198 -35
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +21 -21
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpMigration.js +9 -9
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.d.ts +24 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.js +178 -51
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.js +35 -35
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.js +37 -37
- 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.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.js +7 -7
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +26 -26
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +12 -12
- package/vscode/src/vs/workbench/contrib/mcp/browser/openPanelChatAndGetWidget.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/browser/openPanelChatAndGetWidget.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +5 -5
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/installedMcpServersDiscovery.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpRemoteDiscovery.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpDevMode.js +4 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +20 -14
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +14 -14
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpResourceFilesystem.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpResourceFilesystem.js +19 -3
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +21 -20
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.d.ts +6 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.js +79 -47
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +8 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.d.ts +47 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.js +229 -14
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpTaskManager.d.ts +68 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpTaskManager.js +168 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +10 -10
- package/vscode/src/vs/workbench/services/mcp/browser/mcpGalleryManifestService.d.ts +17 -2
- package/vscode/src/vs/workbench/services/mcp/browser/mcpGalleryManifestService.js +60 -10
- package/vscode/src/vs/workbench/services/mcp/common/mcpWorkbenchManagementService.d.ts +1 -1
- package/vscode/src/vs/workbench/services/mcp/common/mcpWorkbenchManagementService.js +2 -2
|
@@ -15,13 +15,13 @@ import { IImageResizeService } from '@codingame/monaco-vscode-api/vscode/vs/plat
|
|
|
15
15
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
16
16
|
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
17
17
|
import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
18
|
-
import { getAttachableImageExtension, ChatResponseResource } from '@codingame/monaco-vscode-
|
|
18
|
+
import { getAttachableImageExtension, ChatResponseResource } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
19
19
|
import { LanguageModelPartAudience } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
|
|
20
20
|
import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
|
|
21
21
|
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
22
22
|
import { McpToolResourceLinkMimeType, McpResourceURI } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
23
23
|
import { IMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
|
|
24
|
-
import { mcpServerToSourceData } from '@codingame/monaco-vscode-
|
|
24
|
+
import { mcpServerToSourceData } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypesUtils';
|
|
25
25
|
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
26
26
|
|
|
27
27
|
let McpLanguageModelToolContribution = class McpLanguageModelToolContribution extends Disposable {
|
|
@@ -36,21 +36,27 @@ let McpLanguageModelToolContribution = class McpLanguageModelToolContribution ex
|
|
|
36
36
|
const servers = mcpService.servers.read(reader);
|
|
37
37
|
const toDelete = ( new Set(( previous.keys())));
|
|
38
38
|
for (const server of servers) {
|
|
39
|
-
|
|
39
|
+
const previousRec = previous.get(server);
|
|
40
|
+
if (previousRec) {
|
|
40
41
|
toDelete.delete(server);
|
|
41
|
-
|
|
42
|
+
if (!previousRec.source || equals(previousRec.source, mcpServerToSourceData(server, reader))) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
previousRec.dispose();
|
|
42
46
|
}
|
|
43
47
|
const store = ( new DisposableStore());
|
|
48
|
+
const rec = { dispose: () => store.dispose() };
|
|
44
49
|
const toolSet = ( new Lazy(() => {
|
|
45
|
-
const source = mcpServerToSourceData(server);
|
|
46
|
-
const
|
|
50
|
+
const source = rec.source = mcpServerToSourceData(server);
|
|
51
|
+
const referenceName = server.definition.label.toLowerCase().replace(/\s+/g, '-');
|
|
52
|
+
const toolSet = store.add(this._toolsService.createToolSet(source, server.definition.id, referenceName, {
|
|
47
53
|
icon: Codicon.mcp,
|
|
48
|
-
description: ( localize(
|
|
54
|
+
description: ( localize(8999, "{0}: All Tools", server.definition.label))
|
|
49
55
|
}));
|
|
50
56
|
return { toolSet, source };
|
|
51
57
|
}));
|
|
52
58
|
this._syncTools(server, toolSet, store);
|
|
53
|
-
previous.set(server,
|
|
59
|
+
previous.set(server, rec);
|
|
54
60
|
}
|
|
55
61
|
for (const key of toDelete) {
|
|
56
62
|
previous.deleteAndDispose(key);
|
|
@@ -138,14 +144,14 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
138
144
|
const tool = this._tool;
|
|
139
145
|
const server = this._server;
|
|
140
146
|
const mcpToolWarning = ( localize(
|
|
141
|
-
|
|
147
|
+
9000,
|
|
142
148
|
"Note that MCP servers or malicious conversation content may attempt to misuse '{0}' through tools.",
|
|
143
149
|
this._productService.nameShort
|
|
144
150
|
));
|
|
145
151
|
const title = tool.definition.annotations?.title || tool.definition.title || ('`' + tool.definition.name + '`');
|
|
146
152
|
const confirm = {};
|
|
147
153
|
if (!tool.definition.annotations?.readOnlyHint) {
|
|
148
|
-
confirm.title = ( new MarkdownString(( localize(
|
|
154
|
+
confirm.title = ( new MarkdownString(( localize(9001, "Run {0}", title))));
|
|
149
155
|
confirm.message = ( new MarkdownString(tool.definition.description, { supportThemeIcons: true }));
|
|
150
156
|
confirm.disclaimer = mcpToolWarning;
|
|
151
157
|
confirm.allowAutoConfirm = true;
|
|
@@ -155,9 +161,9 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
155
161
|
}
|
|
156
162
|
return {
|
|
157
163
|
confirmationMessages: confirm,
|
|
158
|
-
invocationMessage: ( new MarkdownString(( localize(
|
|
159
|
-
pastTenseMessage: ( new MarkdownString(( localize(
|
|
160
|
-
originMessage: ( localize(
|
|
164
|
+
invocationMessage: ( new MarkdownString(( localize(9002, "Running {0}", title)))),
|
|
165
|
+
pastTenseMessage: ( new MarkdownString(( localize(9003, "Ran {0} ", title)))),
|
|
166
|
+
originMessage: ( localize(9004, "{0} (MCP Server)", server.definition.label)),
|
|
161
167
|
toolSpecificData: {
|
|
162
168
|
kind: 'input',
|
|
163
169
|
rawInput: context.parameters
|
|
@@ -270,7 +276,7 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
270
276
|
asResource: true,
|
|
271
277
|
});
|
|
272
278
|
if (isForModel) {
|
|
273
|
-
const permalink = invocation.context && ChatResponseResource.createUri(invocation.context.
|
|
279
|
+
const permalink = invocation.context && ChatResponseResource.createUri(invocation.context.sessionResource, invocation.callId, result.content.length, basename(uri));
|
|
274
280
|
addAsLinkedResource(permalink || uri, item.resource.mimeType);
|
|
275
281
|
}
|
|
276
282
|
}
|
|
@@ -18,7 +18,7 @@ import { ExtensionIdentifier } from '@codingame/monaco-vscode-api/vscode/vs/plat
|
|
|
18
18
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
19
19
|
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
20
20
|
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
21
|
-
import { McpAccessValue, mcpAccessConfig } from '@codingame/monaco-vscode-
|
|
21
|
+
import { McpAccessValue, mcpAccessConfig } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement';
|
|
22
22
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
|
|
23
23
|
import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
|
|
24
24
|
import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
|
|
@@ -251,7 +251,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
251
251
|
const originURI = r.definition.presentation?.origin?.uri || r.collection.presentation?.origin;
|
|
252
252
|
let labelWithOrigin = originURI ? `[\`${r.definition.label}\`](${originURI})` : '`' + r.definition.label + '`';
|
|
253
253
|
if (r.collection.source instanceof ExtensionIdentifier) {
|
|
254
|
-
labelWithOrigin += ` (${( localize(
|
|
254
|
+
labelWithOrigin += ` (${( localize(9005, 'from {0}', r.collection.source.value))})`;
|
|
255
255
|
}
|
|
256
256
|
return labelWithOrigin;
|
|
257
257
|
}
|
|
@@ -259,12 +259,12 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
259
259
|
const def = definitions[0];
|
|
260
260
|
const originURI = def.definition.presentation?.origin?.uri;
|
|
261
261
|
const { result } = await this._dialogService.prompt({
|
|
262
|
-
message: ( localize(
|
|
262
|
+
message: ( localize(9006, 'Trust and run MCP server {0}?', def.definition.label)),
|
|
263
263
|
custom: {
|
|
264
264
|
icon: Codicon.shield,
|
|
265
265
|
markdownDetails: [{
|
|
266
266
|
markdown: ( new MarkdownString(( localize(
|
|
267
|
-
|
|
267
|
+
9007,
|
|
268
268
|
'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?',
|
|
269
269
|
labelFor(def)
|
|
270
270
|
)))),
|
|
@@ -275,20 +275,20 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
275
275
|
}]
|
|
276
276
|
},
|
|
277
277
|
buttons: [
|
|
278
|
-
{ label: ( localize(
|
|
279
|
-
{ label: ( localize(
|
|
278
|
+
{ label: ( localize(9008, 'Trust')), run: () => true },
|
|
279
|
+
{ label: ( localize(9009, 'Do not trust')), run: () => false }
|
|
280
280
|
],
|
|
281
281
|
});
|
|
282
282
|
return result === undefined ? undefined : (result ? [def.definition.id] : []);
|
|
283
283
|
}
|
|
284
284
|
const list = ( definitions.map(d => `- ${labelFor(d)}`)).join('\n');
|
|
285
285
|
const { result } = await this._dialogService.prompt({
|
|
286
|
-
message: ( localize(
|
|
286
|
+
message: ( localize(9010, 'Trust and run {0} MCP servers?', definitions.length)),
|
|
287
287
|
custom: {
|
|
288
288
|
icon: Codicon.shield,
|
|
289
289
|
markdownDetails: [{
|
|
290
290
|
markdown: ( new MarkdownString(( localize(
|
|
291
|
-
|
|
291
|
+
9011,
|
|
292
292
|
'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?',
|
|
293
293
|
list
|
|
294
294
|
)))),
|
|
@@ -299,9 +299,9 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
299
299
|
}]
|
|
300
300
|
},
|
|
301
301
|
buttons: [
|
|
302
|
-
{ label: ( localize(
|
|
303
|
-
{ label: ( localize(
|
|
304
|
-
{ label: ( localize(
|
|
302
|
+
{ label: ( localize(9008, 'Trust')), run: () => 'all' },
|
|
303
|
+
{ label: ( localize(9012, 'Pick Trusted')), run: () => 'pick' },
|
|
304
|
+
{ label: ( localize(9009, 'Do not trust')), run: () => 'none' },
|
|
305
305
|
],
|
|
306
306
|
});
|
|
307
307
|
if (result === undefined) {
|
|
@@ -440,7 +440,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
440
440
|
}
|
|
441
441
|
this._notificationService.notify({
|
|
442
442
|
severity: Severity.Error,
|
|
443
|
-
message: ( localize(
|
|
443
|
+
message: ( localize(9013, 'Error starting {0}: {1}', definition.label, String(e))),
|
|
444
444
|
actions: {
|
|
445
445
|
primary: collection.presentation?.origin && [
|
|
446
446
|
{
|
|
@@ -448,7 +448,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
448
448
|
class: undefined,
|
|
449
449
|
enabled: true,
|
|
450
450
|
tooltip: '',
|
|
451
|
-
label: ( localize(
|
|
451
|
+
label: ( localize(9014, 'Open Configuration')),
|
|
452
452
|
run: () => this._editorService.openEditor({
|
|
453
453
|
resource: collection.presentation.origin,
|
|
454
454
|
options: { selection: definition.presentation?.origin?.range }
|
|
@@ -459,7 +459,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
459
459
|
});
|
|
460
460
|
return;
|
|
461
461
|
}
|
|
462
|
-
return this._instantiationService.createInstance(McpServerConnection, collection, definition, delegate, launch, logger, opts.errorOnUserInteraction);
|
|
462
|
+
return this._instantiationService.createInstance(McpServerConnection, collection, definition, delegate, launch, logger, opts.errorOnUserInteraction, opts.taskManager);
|
|
463
463
|
}
|
|
464
464
|
};
|
|
465
465
|
McpRegistry = ( __decorate([
|
|
@@ -6,10 +6,12 @@ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
|
6
6
|
import { FileSystemProviderCapabilities, FileType, IFileChange, IFileDeleteOptions, IFileOverwriteOptions, IFileReadStreamOptions, IFileSystemProviderWithFileAtomicReadCapability, IFileSystemProviderWithFileReadStreamCapability, IFileSystemProviderWithFileReadWriteCapability, IFileWriteOptions, IStat, IWatchOptions } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files";
|
|
7
7
|
import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
|
|
8
8
|
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
9
|
+
import { IWebContentExtractorService } from "@codingame/monaco-vscode-api/vscode/vs/platform/webContentExtractor/common/webContentExtractor.service";
|
|
9
10
|
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
10
11
|
export declare class McpResourceFilesystem extends Disposable implements IWorkbenchContribution, IFileSystemProviderWithFileReadWriteCapability, IFileSystemProviderWithFileAtomicReadCapability, IFileSystemProviderWithFileReadStreamCapability {
|
|
11
12
|
private readonly _instantiationService;
|
|
12
13
|
private readonly _fileService;
|
|
14
|
+
private readonly _webContentExtractorService;
|
|
13
15
|
/** Defer getting the MCP service since this is a BlockRestore and no need to make it unnecessarily. */
|
|
14
16
|
private readonly _mcpServiceLazy;
|
|
15
17
|
/**
|
|
@@ -24,7 +26,7 @@ export declare class McpResourceFilesystem extends Disposable implements IWorkbe
|
|
|
24
26
|
private readonly _onDidChangeFile;
|
|
25
27
|
readonly onDidChangeFile: Event<readonly IFileChange[]>;
|
|
26
28
|
readonly capabilities: FileSystemProviderCapabilities;
|
|
27
|
-
constructor(_instantiationService: IInstantiationService, _fileService: IFileService);
|
|
29
|
+
constructor(_instantiationService: IInstantiationService, _fileService: IFileService, _webContentExtractorService: IWebContentExtractorService);
|
|
28
30
|
readFile(resource: URI): Promise<Uint8Array>;
|
|
29
31
|
readFileStream(resource: URI, opts: IFileReadStreamOptions, token: CancellationToken): ReadableStreamEvents<Uint8Array>;
|
|
30
32
|
watch(uri: URI, _opts: IWatchOptions): IDisposable;
|
|
@@ -15,9 +15,11 @@ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
|
15
15
|
import { FileSystemProviderCapabilities, FileChangeType, createFileSystemProviderError, FileSystemProviderErrorCode, FileType } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
16
16
|
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
17
17
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
18
|
+
import { IWebContentExtractorService } from '@codingame/monaco-vscode-api/vscode/vs/platform/webContentExtractor/common/webContentExtractor.service';
|
|
18
19
|
import { McpServer } from './mcpServer.js';
|
|
19
20
|
import { McpResourceURI, McpCapability } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
20
21
|
import { IMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
|
|
22
|
+
import { canLoadMcpNetworkResourceDirectly } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypesUtils';
|
|
21
23
|
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
22
24
|
|
|
23
25
|
const MOMENTARY_CACHE_DURATION = 3000;
|
|
@@ -25,10 +27,11 @@ let McpResourceFilesystem = class McpResourceFilesystem extends Disposable {
|
|
|
25
27
|
get _mcpService() {
|
|
26
28
|
return this._mcpServiceLazy.value;
|
|
27
29
|
}
|
|
28
|
-
constructor(_instantiationService, _fileService) {
|
|
30
|
+
constructor(_instantiationService, _fileService, _webContentExtractorService) {
|
|
29
31
|
super();
|
|
30
32
|
this._instantiationService = _instantiationService;
|
|
31
33
|
this._fileService = _fileService;
|
|
34
|
+
this._webContentExtractorService = _webContentExtractorService;
|
|
32
35
|
this._mcpServiceLazy = ( new Lazy(() => this._instantiationService.invokeFunction(a => a.get(IMcpService))));
|
|
33
36
|
this._momentaryCache = ( new ResourceMap());
|
|
34
37
|
this.onDidChangeCapabilities = Event.None;
|
|
@@ -197,17 +200,30 @@ let McpResourceFilesystem = class McpResourceFilesystem extends Disposable {
|
|
|
197
200
|
}
|
|
198
201
|
async _readURIInner(uri, token) {
|
|
199
202
|
const { resourceURI, server } = this._decodeURI(uri);
|
|
203
|
+
const matchedServer = this._mcpService.servers.get().find(s => s.definition.id === server.definition.id);
|
|
204
|
+
if (canLoadMcpNetworkResourceDirectly(resourceURI, matchedServer)) {
|
|
205
|
+
const extractURI = ( URI.parse(( resourceURI.toString())));
|
|
206
|
+
const result = (await this._webContentExtractorService.extract([extractURI], { followRedirects: false })).at(0);
|
|
207
|
+
if (result?.status === 'ok') {
|
|
208
|
+
return {
|
|
209
|
+
contents: [{ uri: ( resourceURI.toString()), text: result.result }],
|
|
210
|
+
resourceURI,
|
|
211
|
+
forSameURI: [{ uri: ( resourceURI.toString()), text: result.result }]
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
200
215
|
const res = await McpServer.callOn(server, r => r.readResource({ uri: ( resourceURI.toString()) }, token), token);
|
|
201
216
|
return {
|
|
202
217
|
contents: res.contents,
|
|
203
218
|
resourceURI,
|
|
204
|
-
forSameURI: res.contents.filter(c => equalsUrlPath(c.uri, resourceURI))
|
|
219
|
+
forSameURI: res.contents.filter(c => equalsUrlPath(c.uri, resourceURI))
|
|
205
220
|
};
|
|
206
221
|
}
|
|
207
222
|
};
|
|
208
223
|
McpResourceFilesystem = ( __decorate([
|
|
209
224
|
( __param(0, IInstantiationService)),
|
|
210
|
-
( __param(1, IFileService))
|
|
225
|
+
( __param(1, IFileService)),
|
|
226
|
+
( __param(2, IWebContentExtractorService))
|
|
211
227
|
], McpResourceFilesystem));
|
|
212
228
|
function equalsUrlPath(a, b) {
|
|
213
229
|
return equalsIgnoreCase(( new URL(a)).pathname, b.pathname);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
3
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
4
|
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
5
|
-
import { observableMemento } from '@codingame/monaco-vscode-
|
|
5
|
+
import { observableMemento } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/observableMemento';
|
|
6
6
|
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
7
7
|
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
8
8
|
|
|
@@ -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(9015, '{0} total requests in the last 7 days.', total)));
|
|
45
45
|
parts.push(this._formatRecentRequests(record));
|
|
46
46
|
return parts.join('\n');
|
|
47
47
|
}
|
|
@@ -6,7 +6,7 @@ import { IDialogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/
|
|
|
6
6
|
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
7
7
|
import { INotificationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service";
|
|
8
8
|
import { ILanguageModelsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service";
|
|
9
|
-
import { IMcpServerSamplingConfiguration } from "@codingame/monaco-vscode-
|
|
9
|
+
import { IMcpServerSamplingConfiguration } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration";
|
|
10
10
|
import { IMcpServer, ISamplingOptions, ISamplingResult } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
|
|
11
11
|
import { IMcpSamplingService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service";
|
|
12
12
|
export declare class McpSamplingService extends Disposable implements IMcpSamplingService {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { asArray } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
3
4
|
import { mapFindFirst } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arraysFind';
|
|
4
5
|
import { Sequencer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
5
6
|
import { decodeBase64 } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
@@ -18,8 +19,8 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/noti
|
|
|
18
19
|
import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
|
|
19
20
|
import { ChatMessageRole } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
|
|
20
21
|
import { ILanguageModelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service';
|
|
21
|
-
import { McpCommandIds } from '@codingame/monaco-vscode-
|
|
22
|
-
import { mcpServerSamplingSection } from '@codingame/monaco-vscode-
|
|
22
|
+
import { McpCommandIds } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpCommandIds';
|
|
23
|
+
import { mcpServerSamplingSection } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
23
24
|
import { McpSamplingLog } from './mcpSamplingLog.js';
|
|
24
25
|
import { McpError } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
25
26
|
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
@@ -48,17 +49,17 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
48
49
|
}
|
|
49
50
|
async sample(opts, token = CancellationToken.None) {
|
|
50
51
|
const messages = ( opts.params.messages.map((message) => {
|
|
51
|
-
const content = message.content.type === 'text'
|
|
52
|
-
? { type: 'text', value:
|
|
53
|
-
:
|
|
54
|
-
? { type: 'image_url', value: { mimeType:
|
|
55
|
-
: undefined;
|
|
56
|
-
if (!content) {
|
|
52
|
+
const content = ( asArray(message.content).map((part) => part.type === 'text'
|
|
53
|
+
? { type: 'text', value: part.text }
|
|
54
|
+
: part.type === 'image' || part.type === 'audio'
|
|
55
|
+
? { type: 'image_url', value: { mimeType: part.mimeType, data: decodeBase64(part.data) } }
|
|
56
|
+
: undefined)).filter(isDefined);
|
|
57
|
+
if (!content.length) {
|
|
57
58
|
return undefined;
|
|
58
59
|
}
|
|
59
60
|
return {
|
|
60
61
|
role: message.role === 'assistant' ? ChatMessageRole.Assistant : ChatMessageRole.User,
|
|
61
|
-
content
|
|
62
|
+
content,
|
|
62
63
|
};
|
|
63
64
|
})).filter(isDefined);
|
|
64
65
|
if (opts.params.systemPrompt) {
|
|
@@ -106,11 +107,11 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
106
107
|
const model = await this._getMatchingModelInner(opts.server, opts.isDuringToolCall, opts.params.modelPreferences);
|
|
107
108
|
if (model === ModelMatch.UnsureAllowedDuringChat) {
|
|
108
109
|
const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
|
|
109
|
-
|
|
110
|
+
9016,
|
|
110
111
|
'Allow MCP tools from "{0}" to make LLM requests?',
|
|
111
112
|
opts.server.definition.label
|
|
112
113
|
)), ( localize(
|
|
113
|
-
|
|
114
|
+
9017,
|
|
114
115
|
'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?',
|
|
115
116
|
opts.server.definition.label
|
|
116
117
|
)), this.allowButtons(opts.server, 'allowedDuringChat'));
|
|
@@ -121,11 +122,11 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
121
122
|
}
|
|
122
123
|
else if (model === ModelMatch.UnsureAllowedOutsideChat) {
|
|
123
124
|
const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
|
|
124
|
-
|
|
125
|
+
9018,
|
|
125
126
|
'Allow MCP server "{0}" to make LLM requests?',
|
|
126
127
|
opts.server.definition.label
|
|
127
128
|
)), ( localize(
|
|
128
|
-
|
|
129
|
+
9019,
|
|
129
130
|
'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?',
|
|
130
131
|
opts.server.definition.label
|
|
131
132
|
)), this.allowButtons(opts.server, 'allowedOutsideChat'));
|
|
@@ -141,12 +142,12 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
141
142
|
const newlyPickedModels = opts.isDuringToolCall
|
|
142
143
|
? await this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server)
|
|
143
144
|
: await this._notify(( localize(
|
|
144
|
-
|
|
145
|
+
9020,
|
|
145
146
|
'MCP server "{0}" triggered a language model request, but it has no allowlisted models.',
|
|
146
147
|
opts.server.definition.label
|
|
147
148
|
)), {
|
|
148
|
-
[( localize(
|
|
149
|
-
[( localize(
|
|
149
|
+
[( localize(9021, 'Configure'))]: () => this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server),
|
|
150
|
+
[( localize(9022, 'Cancel'))]: () => Promise.resolve(undefined),
|
|
150
151
|
});
|
|
151
152
|
if (newlyPickedModels) {
|
|
152
153
|
return this._getMatchingModel(opts);
|
|
@@ -157,19 +158,19 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
157
158
|
}
|
|
158
159
|
allowButtons(server, key) {
|
|
159
160
|
return {
|
|
160
|
-
[( localize(
|
|
161
|
+
[( localize(9023, 'Allow in this Session'))]: async () => {
|
|
161
162
|
this._sessionSets[key].set(server.definition.id, true);
|
|
162
163
|
return true;
|
|
163
164
|
},
|
|
164
|
-
[( localize(
|
|
165
|
+
[( localize(9024, 'Always'))]: async () => {
|
|
165
166
|
await this.updateConfig(server, c => c[key] = true);
|
|
166
167
|
return true;
|
|
167
168
|
},
|
|
168
|
-
[( localize(
|
|
169
|
+
[( localize(9025, 'Not Now'))]: async () => {
|
|
169
170
|
this._sessionSets[key].set(server.definition.id, false);
|
|
170
171
|
return false;
|
|
171
172
|
},
|
|
172
|
-
[( localize(
|
|
173
|
+
[( localize(9026, 'Never'))]: async () => {
|
|
173
174
|
await this.updateConfig(server, c => c[key] = false);
|
|
174
175
|
return false;
|
|
175
176
|
},
|
|
@@ -130,6 +130,8 @@ export declare class McpServer extends Disposable implements IMcpServer {
|
|
|
130
130
|
private readonly _openerService;
|
|
131
131
|
private readonly _samplingService;
|
|
132
132
|
private readonly _elicitationService;
|
|
133
|
+
/** Shared task manager that survives reconnections */
|
|
134
|
+
private readonly _taskManager;
|
|
133
135
|
/**
|
|
134
136
|
* Helper function to call the function on the handler once it's online. The
|
|
135
137
|
* connection started if it is not already.
|
|
@@ -189,14 +191,16 @@ export declare class McpServer extends Disposable implements IMcpServer {
|
|
|
189
191
|
export declare class McpTool implements IMcpTool {
|
|
190
192
|
private readonly _server;
|
|
191
193
|
private readonly _definition;
|
|
194
|
+
private readonly _elicitationService;
|
|
192
195
|
readonly id: string;
|
|
193
196
|
readonly referenceName: string;
|
|
194
197
|
readonly icons: IMcpIcons;
|
|
195
198
|
get definition(): MCP.Tool;
|
|
196
|
-
constructor(_server: McpServer, idPrefix: string, _definition: ValidatedMcpTool);
|
|
199
|
+
constructor(_server: McpServer, idPrefix: string, _definition: ValidatedMcpTool, _elicitationService: IMcpElicitationService);
|
|
197
200
|
call(params: Record<string, unknown>, context?: IMcpToolCallContext, token?: CancellationToken): Promise<MCP.CallToolResult>;
|
|
198
201
|
callWithProgress(params: Record<string, unknown>, progress: ToolProgress, context?: IMcpToolCallContext, token?: CancellationToken): Promise<MCP.CallToolResult>;
|
|
199
|
-
_callWithProgress(params: Record<string, unknown>, progress: ToolProgress, context?: IMcpToolCallContext, token?: CancellationToken
|
|
202
|
+
_callWithProgress(params: Record<string, unknown>, progress: ToolProgress | undefined, context?: IMcpToolCallContext, token?: Readonly<CancellationToken>, allowRetry?: boolean): Promise<MCP.CallToolResult>;
|
|
203
|
+
private _handleElicitationErr;
|
|
200
204
|
compare(other: IMcpTool): number;
|
|
201
205
|
}
|
|
202
206
|
export {};
|