@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
|
@@ -4,7 +4,7 @@ import { raceCancellationError, Sequencer, AsyncIterableProducer } from '@coding
|
|
|
4
4
|
import { CancellationToken, CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
5
5
|
import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
|
|
6
6
|
import { parseTree, findNodeAtOffset, getNodePath } from '@codingame/monaco-vscode-api/vscode/vs/base/common/json';
|
|
7
|
-
import { Disposable, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import { Disposable, toDisposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
8
8
|
import { LRUCache } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
9
9
|
import { mapValues } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
|
10
10
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
@@ -27,12 +27,14 @@ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench
|
|
|
27
27
|
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
28
28
|
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
29
29
|
import { IOutputService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output.service';
|
|
30
|
-
import { mcpActivationEvent } from '@codingame/monaco-vscode-
|
|
30
|
+
import { mcpActivationEvent } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
31
31
|
import { McpDevModeServerAttache } from './mcpDevMode.js';
|
|
32
32
|
import { McpIcons, parseAndValidateMcpIcon } from './mcpIcons.js';
|
|
33
33
|
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
34
|
-
import {
|
|
34
|
+
import { McpTaskManager } from './mcpTaskManager.js';
|
|
35
|
+
import { McpConnectionState, McpConnectionFailedError, McpServerCacheState, McpServerStaticToolAvailability, extensionMcpCollectionPrefix, UserInteractionRequiredError, McpServerTransportType, mcpPromptReplaceSpecialChars, McpCapability, McpToolName, MpcResponseError, ElicitationKind, McpResourceURI } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
35
36
|
import { IMcpSamplingService, IMcpElicitationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
|
|
37
|
+
import { MCP } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/modelContextProtocol';
|
|
36
38
|
import { UriTemplate } from './uriTemplate.js';
|
|
37
39
|
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
38
40
|
import { observableValue, disposableObservableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
@@ -197,6 +199,7 @@ let McpServer = McpServer_1 = class McpServer extends Disposable {
|
|
|
197
199
|
this._openerService = _openerService;
|
|
198
200
|
this._samplingService = _samplingService;
|
|
199
201
|
this._elicitationService = _elicitationService;
|
|
202
|
+
this._taskManager = this._register(( new McpTaskManager()));
|
|
200
203
|
this._connectionSequencer = ( new Sequencer());
|
|
201
204
|
this._connection = this._register(disposableObservableValue(this, undefined));
|
|
202
205
|
this.connection = this._connection;
|
|
@@ -271,7 +274,9 @@ let McpServer = McpServer_1 = class McpServer extends Disposable {
|
|
|
271
274
|
const tools = m?.tools?.filter(t => t.availability === McpServerStaticToolAvailability.Initial).map(t => t.definition);
|
|
272
275
|
return tools?.length ? ( new ObservablePromise(this._getValidatedTools(tools))) : undefined;
|
|
273
276
|
}))
|
|
274
|
-
.map((o, reader) => o?.promiseResult.read(reader)?.data)), (entry) => entry.tools, (entry) => ( entry.map(
|
|
277
|
+
.map((o, reader) => o?.promiseResult.read(reader)?.data)), (entry) => entry.tools, (entry) => ( entry.map(
|
|
278
|
+
def => this._instantiationService.createInstance(McpTool, this, toolPrefix, def)
|
|
279
|
+
)).sort((a, b) => a.compare(b)), []));
|
|
275
280
|
this._prompts = ( new CachedPrimitive(
|
|
276
281
|
this.definition.id,
|
|
277
282
|
this._primitiveCache,
|
|
@@ -347,6 +352,7 @@ let McpServer = McpServer_1 = class McpServer extends Disposable {
|
|
|
347
352
|
definitionRef: this.definition,
|
|
348
353
|
debug,
|
|
349
354
|
errorOnUserInteraction,
|
|
355
|
+
taskManager: this._taskManager,
|
|
350
356
|
});
|
|
351
357
|
if (!connection) {
|
|
352
358
|
return { state: McpConnectionState.Kind.Stopped };
|
|
@@ -362,12 +368,12 @@ let McpServer = McpServer_1 = class McpServer extends Disposable {
|
|
|
362
368
|
}
|
|
363
369
|
const start = Date.now();
|
|
364
370
|
let state = await connection.start({
|
|
365
|
-
createMessageRequestHandler: params => this._samplingService.sample({
|
|
371
|
+
createMessageRequestHandler: (params, token) => this._samplingService.sample({
|
|
366
372
|
isDuringToolCall: this.runningToolCalls.size > 0,
|
|
367
373
|
server: this,
|
|
368
374
|
params,
|
|
369
|
-
}).then(r => r.sample),
|
|
370
|
-
elicitationRequestHandler: req => {
|
|
375
|
+
}, token).then(r => r.sample),
|
|
376
|
+
elicitationRequestHandler: async (req, token) => {
|
|
371
377
|
const serverInfo = connection.handler.get()?.serverInfo;
|
|
372
378
|
if (serverInfo) {
|
|
373
379
|
this._telemetryService.publicLog2('mcp.elicitationRequested', {
|
|
@@ -375,7 +381,9 @@ let McpServer = McpServer_1 = class McpServer extends Disposable {
|
|
|
375
381
|
serverVersion: serverInfo.version,
|
|
376
382
|
});
|
|
377
383
|
}
|
|
378
|
-
|
|
384
|
+
const r = await this._elicitationService.elicit(this, Iterable.first(this.runningToolCalls), req, token || CancellationToken.None);
|
|
385
|
+
r.dispose();
|
|
386
|
+
return r.value;
|
|
379
387
|
}
|
|
380
388
|
});
|
|
381
389
|
this._telemetryService.publicLog2('mcp/serverBootState', {
|
|
@@ -426,29 +434,29 @@ let McpServer = McpServer_1 = class McpServer extends Disposable {
|
|
|
426
434
|
break;
|
|
427
435
|
}
|
|
428
436
|
const options = [{
|
|
429
|
-
label: ( localize(
|
|
437
|
+
label: ( localize(9027, "Show Output")),
|
|
430
438
|
run: () => this.showOutput(),
|
|
431
439
|
}];
|
|
432
440
|
if (cnx.definition.devMode?.debug?.type === 'debugpy' && debug) {
|
|
433
441
|
this._notificationService.prompt(Severity.Error, ( localize(
|
|
434
|
-
|
|
442
|
+
9028,
|
|
435
443
|
'The command "{0}" was not found. You can specify the path to debugpy in the `dev.debug.debugpyPath` option.',
|
|
436
444
|
cnx.launchDefinition.command,
|
|
437
445
|
cnx.definition.label
|
|
438
446
|
)), [...options, {
|
|
439
|
-
label: ( localize(
|
|
447
|
+
label: ( localize(9029, 'View Docs')),
|
|
440
448
|
run: () => this._openerService.open(( URI.parse('https://aka.ms/vscode-mcp-install/debugpy'))),
|
|
441
449
|
}]);
|
|
442
450
|
return;
|
|
443
451
|
}
|
|
444
452
|
if (docsLink) {
|
|
445
453
|
options.push({
|
|
446
|
-
label: ( localize(
|
|
454
|
+
label: ( localize(9030, 'Install {0}', cnx.launchDefinition.command)),
|
|
447
455
|
run: () => this._openerService.open(( URI.parse(docsLink))),
|
|
448
456
|
});
|
|
449
457
|
}
|
|
450
458
|
this._notificationService.prompt(Severity.Error, ( localize(
|
|
451
|
-
|
|
459
|
+
9031,
|
|
452
460
|
'The command "{0}" needed to run {1} was not found.',
|
|
453
461
|
cnx.launchDefinition.command,
|
|
454
462
|
cnx.definition.label
|
|
@@ -456,7 +464,7 @@ let McpServer = McpServer_1 = class McpServer extends Disposable {
|
|
|
456
464
|
}
|
|
457
465
|
else {
|
|
458
466
|
this._notificationService.warn(( localize(
|
|
459
|
-
|
|
467
|
+
9032,
|
|
460
468
|
'The MCP server {0} could not be started: {1}',
|
|
461
469
|
cnx.definition.label,
|
|
462
470
|
error.message
|
|
@@ -522,7 +530,7 @@ let McpServer = McpServer_1 = class McpServer extends Disposable {
|
|
|
522
530
|
const validated = [];
|
|
523
531
|
for (const [i, result] of validations.entries()) {
|
|
524
532
|
if ('error' in result) {
|
|
525
|
-
error += ( localize(
|
|
533
|
+
error += ( localize(9033, 'Tool `{0}` has invalid JSON parameters:', tools[i].name)) + '\n';
|
|
526
534
|
for (const message of result.error) {
|
|
527
535
|
error += `\t- ${message}\n`;
|
|
528
536
|
}
|
|
@@ -687,35 +695,22 @@ function encodeCapabilities(cap) {
|
|
|
687
695
|
}
|
|
688
696
|
return out;
|
|
689
697
|
}
|
|
690
|
-
class McpTool {
|
|
698
|
+
let McpTool = class McpTool {
|
|
691
699
|
get definition() { return this._definition; }
|
|
692
|
-
constructor(_server, idPrefix, _definition) {
|
|
700
|
+
constructor(_server, idPrefix, _definition, _elicitationService) {
|
|
693
701
|
this._server = _server;
|
|
694
702
|
this._definition = _definition;
|
|
703
|
+
this._elicitationService = _elicitationService;
|
|
695
704
|
this.referenceName = _definition.name.replaceAll('.', '_');
|
|
696
705
|
this.id = (idPrefix + _definition.name).replaceAll('.', '_').slice(0, McpToolName.MaxLength);
|
|
697
706
|
this.icons = McpIcons.fromStored(this._definition._icons);
|
|
698
707
|
}
|
|
699
708
|
async call(params, context, token) {
|
|
700
|
-
const name = this._definition.serverToolName ?? this._definition.name;
|
|
701
709
|
if (context) {
|
|
702
710
|
this._server.runningToolCalls.add(context);
|
|
703
711
|
}
|
|
704
712
|
try {
|
|
705
|
-
|
|
706
|
-
if (context?.chatSessionId) {
|
|
707
|
-
meta['vscode.conversationId'] = context.chatSessionId;
|
|
708
|
-
}
|
|
709
|
-
if (context?.chatRequestId) {
|
|
710
|
-
meta['vscode.requestId'] = context.chatRequestId;
|
|
711
|
-
}
|
|
712
|
-
const result = await McpServer.callOn(this._server, h => h.callTool({
|
|
713
|
-
name,
|
|
714
|
-
arguments: params,
|
|
715
|
-
_meta: ( Object.keys(meta)).length > 0 ? meta : undefined
|
|
716
|
-
}, token), token);
|
|
717
|
-
await this._server.awaitToolRefresh();
|
|
718
|
-
return result;
|
|
713
|
+
return await this._callWithProgress(params, undefined, context, token);
|
|
719
714
|
}
|
|
720
715
|
finally {
|
|
721
716
|
if (context) {
|
|
@@ -736,18 +731,21 @@ class McpTool {
|
|
|
736
731
|
}
|
|
737
732
|
}
|
|
738
733
|
}
|
|
739
|
-
_callWithProgress(params, progress, context, token, allowRetry = true) {
|
|
734
|
+
_callWithProgress(params, progress, context, token = CancellationToken.None, allowRetry = true) {
|
|
740
735
|
const name = this._definition.serverToolName ?? this._definition.name;
|
|
741
|
-
const progressToken = generateUuid();
|
|
736
|
+
const progressToken = progress ? generateUuid() : undefined;
|
|
737
|
+
const store = ( new DisposableStore());
|
|
742
738
|
return McpServer.callOn(this._server, async (h) => {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
739
|
+
if (progress) {
|
|
740
|
+
store.add(h.onDidReceiveProgressNotification((e) => {
|
|
741
|
+
if (e.params.progressToken === progressToken) {
|
|
742
|
+
progress.report({
|
|
743
|
+
message: e.params.message,
|
|
744
|
+
progress: e.params.total !== undefined && e.params.progress !== undefined ? e.params.progress / e.params.total : undefined,
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
}));
|
|
748
|
+
}
|
|
751
749
|
const meta = { progressToken };
|
|
752
750
|
if (context?.chatSessionId) {
|
|
753
751
|
meta['vscode.conversationId'] = context.chatSessionId;
|
|
@@ -755,12 +753,24 @@ class McpTool {
|
|
|
755
753
|
if (context?.chatRequestId) {
|
|
756
754
|
meta['vscode.requestId'] = context.chatRequestId;
|
|
757
755
|
}
|
|
756
|
+
const taskHint = this._definition.execution?.taskSupport;
|
|
757
|
+
const serverSupportsTasksForTools = h.capabilities.tasks?.requests?.tools?.call !== undefined;
|
|
758
|
+
const shouldUseTask = serverSupportsTasksForTools && (taskHint === 'required' || taskHint === 'optional');
|
|
758
759
|
try {
|
|
759
|
-
const result = await h.callTool({
|
|
760
|
+
const result = await h.callTool({
|
|
761
|
+
name,
|
|
762
|
+
arguments: params,
|
|
763
|
+
task: shouldUseTask ? {} : undefined,
|
|
764
|
+
_meta: meta,
|
|
765
|
+
}, token);
|
|
760
766
|
await this._server.awaitToolRefresh();
|
|
761
767
|
return result;
|
|
762
768
|
}
|
|
763
769
|
catch (err) {
|
|
770
|
+
if (err instanceof MpcResponseError && err.code === MCP.URL_ELICITATION_REQUIRED && allowRetry) {
|
|
771
|
+
await this._handleElicitationErr(err, context, token);
|
|
772
|
+
return this._callWithProgress(params, progress, context, token, false);
|
|
773
|
+
}
|
|
764
774
|
const state = this._server.connectionState.get();
|
|
765
775
|
if (allowRetry && state.state === McpConnectionState.Kind.Error && state.shouldRetry) {
|
|
766
776
|
return this._callWithProgress(params, progress, context, token, false);
|
|
@@ -770,14 +780,36 @@ class McpTool {
|
|
|
770
780
|
}
|
|
771
781
|
}
|
|
772
782
|
finally {
|
|
773
|
-
|
|
783
|
+
store.dispose();
|
|
774
784
|
}
|
|
775
785
|
}, token);
|
|
776
786
|
}
|
|
787
|
+
async _handleElicitationErr(err, context, token) {
|
|
788
|
+
const elicitations = err.data?.elicitations;
|
|
789
|
+
if (Array.isArray(elicitations) && elicitations.length > 0) {
|
|
790
|
+
for (const elicitation of elicitations) {
|
|
791
|
+
const elicitResult = await this._elicitationService.elicit(this._server, context, elicitation, token);
|
|
792
|
+
try {
|
|
793
|
+
if (elicitResult.value.action !== 'accept') {
|
|
794
|
+
throw err;
|
|
795
|
+
}
|
|
796
|
+
if (elicitResult.kind === ElicitationKind.URL) {
|
|
797
|
+
await elicitResult.wait;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
finally {
|
|
801
|
+
elicitResult.dispose();
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
777
806
|
compare(other) {
|
|
778
807
|
return this._definition.name.localeCompare(other.definition.name);
|
|
779
808
|
}
|
|
780
|
-
}
|
|
809
|
+
};
|
|
810
|
+
McpTool = ( __decorate([
|
|
811
|
+
( __param(3, IMcpElicitationService))
|
|
812
|
+
], McpTool));
|
|
781
813
|
function warnInvalidTools(instaService, serverName, errorText) {
|
|
782
814
|
instaService.invokeFunction((accessor) => {
|
|
783
815
|
const notificationService = accessor.get(INotificationService);
|
|
@@ -785,7 +817,7 @@ function warnInvalidTools(instaService, serverName, errorText) {
|
|
|
785
817
|
notificationService.notify({
|
|
786
818
|
severity: Severity.Warning,
|
|
787
819
|
message: ( localize(
|
|
788
|
-
|
|
820
|
+
9034,
|
|
789
821
|
'MCP server `{0}` has tools with invalid parameters which will be omitted.',
|
|
790
822
|
serverName
|
|
791
823
|
)),
|
|
@@ -795,7 +827,7 @@ function warnInvalidTools(instaService, serverName, errorText) {
|
|
|
795
827
|
enabled: true,
|
|
796
828
|
id: 'mcpBadSchema.show',
|
|
797
829
|
tooltip: '',
|
|
798
|
-
label: ( localize(
|
|
830
|
+
label: ( localize(9035, 'Show')),
|
|
799
831
|
run: () => {
|
|
800
832
|
editorService.openEditor({
|
|
801
833
|
resource: undefined,
|
|
@@ -4,6 +4,7 @@ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/pl
|
|
|
4
4
|
import { ILogger } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log";
|
|
5
5
|
import { IMcpHostDelegate } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes";
|
|
6
6
|
import { McpServerRequestHandler } from "./mcpServerRequestHandler.js";
|
|
7
|
+
import { McpTaskManager } from "./mcpTaskManager.js";
|
|
7
8
|
import { IMcpClientMethods, IMcpServerConnection, McpCollectionDefinition, McpConnectionState, McpServerDefinition, McpServerLaunch } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
|
|
8
9
|
export declare class McpServerConnection extends Disposable implements IMcpServerConnection {
|
|
9
10
|
private readonly _collection;
|
|
@@ -12,13 +13,14 @@ export declare class McpServerConnection extends Disposable implements IMcpServe
|
|
|
12
13
|
readonly launchDefinition: McpServerLaunch;
|
|
13
14
|
private readonly _logger;
|
|
14
15
|
private readonly _errorOnUserInteraction;
|
|
16
|
+
private readonly _taskManager;
|
|
15
17
|
private readonly _instantiationService;
|
|
16
18
|
private readonly _launch;
|
|
17
19
|
private readonly _state;
|
|
18
20
|
private readonly _requestHandler;
|
|
19
21
|
readonly state: IObservable<McpConnectionState>;
|
|
20
22
|
readonly handler: IObservable<McpServerRequestHandler | undefined>;
|
|
21
|
-
constructor(_collection: McpCollectionDefinition, definition: McpServerDefinition, _delegate: IMcpHostDelegate, launchDefinition: McpServerLaunch, _logger: ILogger, _errorOnUserInteraction: boolean | undefined, _instantiationService: IInstantiationService);
|
|
23
|
+
constructor(_collection: McpCollectionDefinition, definition: McpServerDefinition, _delegate: IMcpHostDelegate, launchDefinition: McpServerLaunch, _logger: ILogger, _errorOnUserInteraction: boolean | undefined, _taskManager: McpTaskManager, _instantiationService: IInstantiationService);
|
|
22
24
|
/** @inheritdoc */
|
|
23
25
|
start(methods: IMcpClientMethods): Promise<McpConnectionState>;
|
|
24
26
|
private adoptLaunch;
|
|
@@ -13,7 +13,7 @@ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/com
|
|
|
13
13
|
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
14
14
|
|
|
15
15
|
let McpServerConnection = class McpServerConnection extends Disposable {
|
|
16
|
-
constructor(_collection, definition, _delegate, launchDefinition, _logger, _errorOnUserInteraction, _instantiationService) {
|
|
16
|
+
constructor(_collection, definition, _delegate, launchDefinition, _logger, _errorOnUserInteraction, _taskManager, _instantiationService) {
|
|
17
17
|
super();
|
|
18
18
|
this._collection = _collection;
|
|
19
19
|
this.definition = definition;
|
|
@@ -21,6 +21,7 @@ let McpServerConnection = class McpServerConnection extends Disposable {
|
|
|
21
21
|
this.launchDefinition = launchDefinition;
|
|
22
22
|
this._logger = _logger;
|
|
23
23
|
this._errorOnUserInteraction = _errorOnUserInteraction;
|
|
24
|
+
this._taskManager = _taskManager;
|
|
24
25
|
this._instantiationService = _instantiationService;
|
|
25
26
|
this._launch = this._register(( new MutableDisposable()));
|
|
26
27
|
this._state = observableValue('mcpServerState', { state: McpConnectionState.Kind.Stopped });
|
|
@@ -35,7 +36,7 @@ let McpServerConnection = class McpServerConnection extends Disposable {
|
|
|
35
36
|
}
|
|
36
37
|
this._launch.value = undefined;
|
|
37
38
|
this._state.set({ state: McpConnectionState.Kind.Starting }, undefined);
|
|
38
|
-
this._logger.info(( localize(
|
|
39
|
+
this._logger.info(( localize(9036, 'Starting server {0}', this.definition.label)));
|
|
39
40
|
try {
|
|
40
41
|
const launch = this._delegate.start(this._collection, this.definition, this.launchDefinition, { errorOnUserInteraction: this._errorOnUserInteraction });
|
|
41
42
|
this._launch.value = this.adoptLaunch(launch, methods);
|
|
@@ -62,14 +63,15 @@ let McpServerConnection = class McpServerConnection extends Disposable {
|
|
|
62
63
|
store.add(autorun(reader => {
|
|
63
64
|
const state = launch.state.read(reader);
|
|
64
65
|
this._state.set(state, undefined);
|
|
65
|
-
this._logger.info(( localize(
|
|
66
|
+
this._logger.info(( localize(9037, 'Connection state: {0}', (McpConnectionState.toString(state)))));
|
|
66
67
|
if (state.state === McpConnectionState.Kind.Running && !didStart) {
|
|
67
68
|
didStart = true;
|
|
68
69
|
McpServerRequestHandler.create(this._instantiationService, {
|
|
70
|
+
...methods,
|
|
69
71
|
launch,
|
|
70
72
|
logger: this._logger,
|
|
71
73
|
requestLogLevel: this.definition.devMode ? LogLevel.Info : LogLevel.Debug,
|
|
72
|
-
|
|
74
|
+
taskManager: this._taskManager,
|
|
73
75
|
}, cts.token).then(handler => {
|
|
74
76
|
if (!store.isDisposed) {
|
|
75
77
|
this._requestHandler.set(handler, undefined);
|
|
@@ -96,7 +98,7 @@ let McpServerConnection = class McpServerConnection extends Disposable {
|
|
|
96
98
|
return { dispose: () => store.dispose(), object: launch };
|
|
97
99
|
}
|
|
98
100
|
async stop() {
|
|
99
|
-
this._logger.info(( localize(
|
|
101
|
+
this._logger.info(( localize(9038, 'Stopping server {0}', this.definition.label)));
|
|
100
102
|
this._launch.value?.object.stop();
|
|
101
103
|
await this._waitForState(McpConnectionState.Kind.Stopped, McpConnectionState.Kind.Error);
|
|
102
104
|
}
|
|
@@ -122,7 +124,7 @@ let McpServerConnection = class McpServerConnection extends Disposable {
|
|
|
122
124
|
}
|
|
123
125
|
};
|
|
124
126
|
McpServerConnection = ( __decorate([
|
|
125
|
-
( __param(
|
|
127
|
+
( __param(7, IInstantiationService))
|
|
126
128
|
], McpServerConnection));
|
|
127
129
|
|
|
128
130
|
export { McpServerConnection };
|
|
@@ -3,6 +3,7 @@ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/l
|
|
|
3
3
|
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
4
4
|
import { ILogger, LogLevel } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log";
|
|
5
5
|
import { IMcpMessageTransport } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes";
|
|
6
|
+
import { IMcpTaskInternal, McpTaskManager } from "./mcpTaskManager.js";
|
|
6
7
|
import { IMcpClientMethods } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
|
|
7
8
|
import { MCP } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/modelContextProtocol";
|
|
8
9
|
export interface McpRoot {
|
|
@@ -16,6 +17,8 @@ export interface IMcpServerRequestHandlerOptions extends IMcpClientMethods {
|
|
|
16
17
|
logger: ILogger;
|
|
17
18
|
/** Log level MCP messages is logged at */
|
|
18
19
|
requestLogLevel?: LogLevel;
|
|
20
|
+
/** Task manager for server-side MCP tasks (shared across reconnections) */
|
|
21
|
+
taskManager: McpTaskManager;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* Request handler for communicating with an MCP server.
|
|
@@ -37,6 +40,8 @@ export declare class McpServerRequestHandler extends Disposable {
|
|
|
37
40
|
readonly onDidReceiveCancelledNotification: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<MCP.CancelledNotification>;
|
|
38
41
|
private readonly _onDidReceiveProgressNotification;
|
|
39
42
|
readonly onDidReceiveProgressNotification: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<MCP.ProgressNotification>;
|
|
43
|
+
private readonly _onDidReceiveElicitationCompleteNotification;
|
|
44
|
+
readonly onDidReceiveElicitationCompleteNotification: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<MCP.ElicitationCompleteNotification>;
|
|
40
45
|
private readonly _onDidChangeResourceList;
|
|
41
46
|
readonly onDidChangeResourceList: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<void>;
|
|
42
47
|
private readonly _onDidUpdateResource;
|
|
@@ -55,7 +60,8 @@ export declare class McpServerRequestHandler extends Disposable {
|
|
|
55
60
|
private readonly _requestLogLevel;
|
|
56
61
|
private readonly _createMessageRequestHandler;
|
|
57
62
|
private readonly _elicitationRequestHandler;
|
|
58
|
-
|
|
63
|
+
private readonly _taskManager;
|
|
64
|
+
protected constructor({ launch, logger, createMessageRequestHandler, elicitationRequestHandler, requestLogLevel, taskManager, }: IMcpServerRequestHandlerOptions);
|
|
59
65
|
/**
|
|
60
66
|
* Send a client request to the server and return the response.
|
|
61
67
|
*
|
|
@@ -158,7 +164,7 @@ export declare class McpServerRequestHandler extends Disposable {
|
|
|
158
164
|
*/
|
|
159
165
|
listTools(params?: MCP.ListToolsRequest["params"], token?: CancellationToken): Promise<MCP.Tool[]>;
|
|
160
166
|
/**
|
|
161
|
-
* Call a specific tool
|
|
167
|
+
* Call a specific tool. Supports tasks automatically if `task` is set on the request.
|
|
162
168
|
*/
|
|
163
169
|
callTool(params: MCP.CallToolRequest["params"] & MCP.Request["params"], token?: CancellationToken): Promise<MCP.CallToolResult>;
|
|
164
170
|
/**
|
|
@@ -169,4 +175,43 @@ export declare class McpServerRequestHandler extends Disposable {
|
|
|
169
175
|
* Find completions for an argument
|
|
170
176
|
*/
|
|
171
177
|
complete(params: MCP.CompleteRequest["params"], token?: CancellationToken): Promise<MCP.CompleteResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Get task status
|
|
180
|
+
*/
|
|
181
|
+
getTask(params: {
|
|
182
|
+
taskId: string;
|
|
183
|
+
}, token?: CancellationToken): Promise<MCP.GetTaskResult>;
|
|
184
|
+
/**
|
|
185
|
+
* Get task result
|
|
186
|
+
*/
|
|
187
|
+
getTaskResult(params: {
|
|
188
|
+
taskId: string;
|
|
189
|
+
}, token?: CancellationToken): Promise<MCP.GetTaskPayloadResult>;
|
|
190
|
+
/**
|
|
191
|
+
* Cancel a task
|
|
192
|
+
*/
|
|
193
|
+
cancelTask(params: {
|
|
194
|
+
taskId: string;
|
|
195
|
+
}, token?: CancellationToken): Promise<MCP.CancelTaskResult>;
|
|
196
|
+
/**
|
|
197
|
+
* List all tasks
|
|
198
|
+
*/
|
|
199
|
+
listTasks(params?: MCP.ListTasksRequest["params"], token?: CancellationToken): Promise<MCP.Task[]>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Implementation of a task that handles polling, status notifications, and handler reconnections. It implements the task polling loop internally and can also be
|
|
203
|
+
* updated externally via `onDidUpdateState`, when notifications are received
|
|
204
|
+
* for example.
|
|
205
|
+
* @internal
|
|
206
|
+
*/
|
|
207
|
+
export declare class McpTask<T extends MCP.Result> extends Disposable implements IMcpTaskInternal {
|
|
208
|
+
private readonly _task;
|
|
209
|
+
private readonly promise;
|
|
210
|
+
get result(): Promise<T>;
|
|
211
|
+
get id(): string;
|
|
212
|
+
private _lastTaskState;
|
|
213
|
+
private _handler;
|
|
214
|
+
constructor(_task: MCP.Task, _token?: CancellationToken);
|
|
215
|
+
onDidUpdateState(task: MCP.Task): void;
|
|
216
|
+
setHandler(handler: McpServerRequestHandler | undefined): void;
|
|
172
217
|
}
|