@codingame/monaco-vscode-mcp-service-override 17.2.0 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +20 -2
- package/package.json +14 -5
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.d.ts +26 -0
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +170 -0
- package/vscode/src/vs/platform/mcp/common/mcpManagementService.d.ts +35 -0
- package/vscode/src/vs/platform/mcp/common/mcpManagementService.js +292 -0
- package/vscode/src/vs/platform/mcp/common/mcpPlatformTypes.d.ts +65 -0
- package/vscode/src/vs/platform/mcp/common/mcpPlatformTypes.js +9 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +64 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +76 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpDiscovery.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +73 -27
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.d.ts +106 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.js +423 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.d.ts +61 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.js +542 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.js +45 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.d.ts +54 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.js +272 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +193 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.d.ts +56 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +176 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/configMcpDiscovery.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/configMcpDiscovery.js +27 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +8 -6
- 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 +6 -4
- 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 +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.js +4 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigPathsService.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpDevMode.d.ts +23 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpDevMode.js +89 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpDevMode.service.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpDevMode.service.js +6 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.d.ts +8 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +30 -47
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpResourceFilesystem.d.ts +35 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpResourceFilesystem.js +206 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +110 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +256 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.d.ts +29 -13
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.js +313 -116
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +15 -17
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.d.ts +16 -7
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.js +58 -39
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +109 -46
- package/vscode/src/vs/workbench/contrib/mcp/common/uriTemplate.d.ts +25 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/uriTemplate.js +296 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpAccessService.d.ts +27 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpAccessService.js +73 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.d.ts +51 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +391 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpUsageService.d.ts +27 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpUsageService.js +105 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/modelContextProtocol.d.ts +0 -395
- package/vscode/src/vs/workbench/contrib/mcp/common/modelContextProtocol.js +0 -14
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { mapFindFirst } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arraysFind';
|
|
4
|
+
import { decodeBase64 } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
5
|
+
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
6
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
7
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
8
|
+
import { isDefined } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
9
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
10
|
+
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
11
|
+
import { ConfigurationTarget, getConfigValueInTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
|
|
12
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
13
|
+
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
14
|
+
import { ExtensionIdentifier } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
|
|
15
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
16
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
|
|
17
|
+
import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
|
|
18
|
+
import { ChatMessageRole } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
|
|
19
|
+
import { ILanguageModelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service';
|
|
20
|
+
import { McpCommandIds } from '@codingame/monaco-vscode-aa9ead53-dfd3-59da-b9e7-f163d201de8d-common/vscode/vs/workbench/contrib/mcp/common/mcpCommandIds';
|
|
21
|
+
import { mcpServerSamplingSection } from '@codingame/monaco-vscode-aa9ead53-dfd3-59da-b9e7-f163d201de8d-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
22
|
+
import { McpSamplingLog } from './mcpSamplingLog.js';
|
|
23
|
+
import { McpError } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
24
|
+
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
25
|
+
|
|
26
|
+
var ModelMatch;
|
|
27
|
+
(function (ModelMatch) {
|
|
28
|
+
ModelMatch[ModelMatch["UnsureAllowedDuringChat"] = 0] = "UnsureAllowedDuringChat";
|
|
29
|
+
ModelMatch[ModelMatch["UnsureAllowedOutsideChat"] = 1] = "UnsureAllowedOutsideChat";
|
|
30
|
+
ModelMatch[ModelMatch["NotAllowed"] = 2] = "NotAllowed";
|
|
31
|
+
ModelMatch[ModelMatch["NoMatchingModel"] = 3] = "NoMatchingModel";
|
|
32
|
+
})(ModelMatch || (ModelMatch = {}));
|
|
33
|
+
let McpSamplingService = class McpSamplingService extends Disposable {
|
|
34
|
+
constructor(_languageModelsService, _configurationService, _dialogService, _notificationService, _commandService, instaService) {
|
|
35
|
+
super();
|
|
36
|
+
this._languageModelsService = _languageModelsService;
|
|
37
|
+
this._configurationService = _configurationService;
|
|
38
|
+
this._dialogService = _dialogService;
|
|
39
|
+
this._notificationService = _notificationService;
|
|
40
|
+
this._commandService = _commandService;
|
|
41
|
+
this._sessionSets = {
|
|
42
|
+
allowedDuringChat: ( new Map()),
|
|
43
|
+
allowedOutsideChat: ( new Map()),
|
|
44
|
+
};
|
|
45
|
+
this._logs = this._register(instaService.createInstance(McpSamplingLog));
|
|
46
|
+
}
|
|
47
|
+
async sample(opts, token = CancellationToken.None) {
|
|
48
|
+
const messages = ( opts.params.messages.map((message) => {
|
|
49
|
+
const content = message.content.type === 'text'
|
|
50
|
+
? { type: 'text', value: message.content.text }
|
|
51
|
+
: message.content.type === 'image' || message.content.type === 'audio'
|
|
52
|
+
? { type: 'image_url', value: { mimeType: message.content.mimeType, data: decodeBase64(message.content.data) } }
|
|
53
|
+
: undefined;
|
|
54
|
+
if (!content) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
role: message.role === 'assistant' ? ChatMessageRole.Assistant : ChatMessageRole.User,
|
|
59
|
+
content: [content]
|
|
60
|
+
};
|
|
61
|
+
})).filter(isDefined);
|
|
62
|
+
const model = await this._getMatchingModel(opts);
|
|
63
|
+
const response = await this._languageModelsService.sendChatRequest(model, ( new ExtensionIdentifier('Github.copilot-chat')), messages, {}, token);
|
|
64
|
+
let responseText = '';
|
|
65
|
+
const streaming = (async () => {
|
|
66
|
+
for await (const part of response.stream) {
|
|
67
|
+
if (Array.isArray(part)) {
|
|
68
|
+
for (const p of part) {
|
|
69
|
+
if (p.part.type === 'text') {
|
|
70
|
+
responseText += p.part.value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (part.part.type === 'text') {
|
|
75
|
+
responseText += part.part.value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
})();
|
|
79
|
+
try {
|
|
80
|
+
await Promise.all([response.result, streaming]);
|
|
81
|
+
this._logs.add(opts.server, opts.params.messages, responseText, model);
|
|
82
|
+
return {
|
|
83
|
+
sample: {
|
|
84
|
+
model,
|
|
85
|
+
content: { type: 'text', text: responseText },
|
|
86
|
+
role: 'assistant',
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
throw McpError.unknown(err);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
hasLogs(server) {
|
|
95
|
+
return ( this._logs.has(server));
|
|
96
|
+
}
|
|
97
|
+
getLogText(server) {
|
|
98
|
+
return this._logs.getAsText(server);
|
|
99
|
+
}
|
|
100
|
+
async _getMatchingModel(opts) {
|
|
101
|
+
const model = await this._getMatchingModelInner(opts.server, opts.isDuringToolCall, opts.params.modelPreferences);
|
|
102
|
+
if (model === ModelMatch.UnsureAllowedDuringChat) {
|
|
103
|
+
const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
|
|
104
|
+
7957,
|
|
105
|
+
'Allow MCP tools from "{0}" to make LLM requests?',
|
|
106
|
+
opts.server.definition.label
|
|
107
|
+
)), ( localize(
|
|
108
|
+
7958,
|
|
109
|
+
'The MCP server "{0}" has issued a request to make an language model call. Do you want to allow it to make requests during chat?',
|
|
110
|
+
opts.server.definition.label
|
|
111
|
+
)), this.allowButtons(opts.server, 'allowedDuringChat'));
|
|
112
|
+
if (retry) {
|
|
113
|
+
return this._getMatchingModel(opts);
|
|
114
|
+
}
|
|
115
|
+
throw McpError.notAllowed();
|
|
116
|
+
}
|
|
117
|
+
else if (model === ModelMatch.UnsureAllowedOutsideChat) {
|
|
118
|
+
const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
|
|
119
|
+
7959,
|
|
120
|
+
'Allow MCP server "{0}" to make LLM requests?',
|
|
121
|
+
opts.server.definition.label
|
|
122
|
+
)), ( localize(
|
|
123
|
+
7960,
|
|
124
|
+
'The MCP server "{0}" has issued a request to make an language model call. Do you want to allow it to make requests, outside of tool calls during chat?',
|
|
125
|
+
opts.server.definition.label
|
|
126
|
+
)), this.allowButtons(opts.server, 'allowedOutsideChat'));
|
|
127
|
+
if (retry) {
|
|
128
|
+
return this._getMatchingModel(opts);
|
|
129
|
+
}
|
|
130
|
+
throw McpError.notAllowed();
|
|
131
|
+
}
|
|
132
|
+
else if (model === ModelMatch.NotAllowed) {
|
|
133
|
+
throw McpError.notAllowed();
|
|
134
|
+
}
|
|
135
|
+
else if (model === ModelMatch.NoMatchingModel) {
|
|
136
|
+
const newlyPickedModels = opts.isDuringToolCall
|
|
137
|
+
? await this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server)
|
|
138
|
+
: await this._notify(( localize(
|
|
139
|
+
7961,
|
|
140
|
+
'MCP server "{0}" triggered a language model request, but it has no allowlisted models.',
|
|
141
|
+
opts.server.definition.label
|
|
142
|
+
)), {
|
|
143
|
+
[( localize(7962, 'Configure'))]: () => this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server),
|
|
144
|
+
[( localize(7963, 'Cancel'))]: () => Promise.resolve(undefined),
|
|
145
|
+
});
|
|
146
|
+
if (newlyPickedModels) {
|
|
147
|
+
return this._getMatchingModel(opts);
|
|
148
|
+
}
|
|
149
|
+
throw McpError.notAllowed();
|
|
150
|
+
}
|
|
151
|
+
return model;
|
|
152
|
+
}
|
|
153
|
+
allowButtons(server, key) {
|
|
154
|
+
return {
|
|
155
|
+
[( localize(7964, 'Allow in this Session'))]: async () => {
|
|
156
|
+
this._sessionSets[key].set(server.definition.id, true);
|
|
157
|
+
return true;
|
|
158
|
+
},
|
|
159
|
+
[( localize(7965, 'Always'))]: async () => {
|
|
160
|
+
await this.updateConfig(server, c => c[key] = true);
|
|
161
|
+
return true;
|
|
162
|
+
},
|
|
163
|
+
[( localize(7966, 'Not Now'))]: async () => {
|
|
164
|
+
this._sessionSets[key].set(server.definition.id, false);
|
|
165
|
+
return false;
|
|
166
|
+
},
|
|
167
|
+
[( localize(7967, 'Never'))]: async () => {
|
|
168
|
+
await this.updateConfig(server, c => c[key] = false);
|
|
169
|
+
return false;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
async _showContextual(isDuringToolCall, title, message, buttons) {
|
|
174
|
+
if (isDuringToolCall) {
|
|
175
|
+
const result = await this._dialogService.prompt({
|
|
176
|
+
type: 'question',
|
|
177
|
+
title: title,
|
|
178
|
+
message,
|
|
179
|
+
buttons: ( Object.entries(buttons).map(([label, run]) => ({ label, run }))),
|
|
180
|
+
});
|
|
181
|
+
return await result.result;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return await this._notify(message, buttons);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async _notify(message, buttons) {
|
|
188
|
+
return await ( new Promise(resolve => {
|
|
189
|
+
const handle = this._notificationService.prompt(Severity.Info, message, ( Object.entries(buttons).map(([label, action]) => ({
|
|
190
|
+
label,
|
|
191
|
+
run: () => resolve(action()),
|
|
192
|
+
}))));
|
|
193
|
+
Event.once(handle.onDidClose)(() => resolve(undefined));
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
async _getMatchingModelInner(server, isDuringToolCall, preferences) {
|
|
197
|
+
const config = this.getConfig(server);
|
|
198
|
+
if (isDuringToolCall && !config.allowedDuringChat && !( this._sessionSets.allowedDuringChat.has(server.definition.id))) {
|
|
199
|
+
return config.allowedDuringChat === undefined ? ModelMatch.UnsureAllowedDuringChat : ModelMatch.NotAllowed;
|
|
200
|
+
}
|
|
201
|
+
else if (!isDuringToolCall && !config.allowedOutsideChat && !( this._sessionSets.allowedOutsideChat.has(server.definition.id))) {
|
|
202
|
+
return config.allowedOutsideChat === undefined ? ModelMatch.UnsureAllowedOutsideChat : ModelMatch.NotAllowed;
|
|
203
|
+
}
|
|
204
|
+
const foundModelIdsDeep = config.allowedModels?.filter(m => !!this._languageModelsService.lookupLanguageModel(m)) || this._languageModelsService.getLanguageModelIds().filter(m => this._languageModelsService.lookupLanguageModel(m)?.isDefault);
|
|
205
|
+
const foundModelIds = foundModelIdsDeep.flat().sort((a, b) => b.length - a.length);
|
|
206
|
+
if (!foundModelIds.length) {
|
|
207
|
+
return ModelMatch.NoMatchingModel;
|
|
208
|
+
}
|
|
209
|
+
if (preferences?.hints) {
|
|
210
|
+
const found = mapFindFirst(preferences.hints, hint => foundModelIds.find(model => model.toLowerCase().includes(hint.name.toLowerCase())));
|
|
211
|
+
if (found) {
|
|
212
|
+
return found;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return foundModelIds[0];
|
|
216
|
+
}
|
|
217
|
+
_configKey(server) {
|
|
218
|
+
return `${server.collection.label}: ${server.definition.label}`;
|
|
219
|
+
}
|
|
220
|
+
getConfig(server) {
|
|
221
|
+
return this._getConfig(server).value || {};
|
|
222
|
+
}
|
|
223
|
+
_getConfig(server) {
|
|
224
|
+
const def = server.readDefinitions().get();
|
|
225
|
+
const mostSpecificConfig = ConfigurationTarget.MEMORY;
|
|
226
|
+
const leastSpecificConfig = def.collection?.configTarget || ConfigurationTarget.USER;
|
|
227
|
+
const key = this._configKey(server);
|
|
228
|
+
const resource = def.collection?.presentation?.origin;
|
|
229
|
+
const configValue = this._configurationService.inspect(mcpServerSamplingSection, { resource });
|
|
230
|
+
for (let target = mostSpecificConfig; target >= leastSpecificConfig; target--) {
|
|
231
|
+
const mapping = getConfigValueInTarget(configValue, target);
|
|
232
|
+
const config = mapping?.[key];
|
|
233
|
+
if (config) {
|
|
234
|
+
return { value: config, key, mapping, target, resource };
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return { value: undefined, mapping: undefined, key, target: leastSpecificConfig, resource };
|
|
238
|
+
}
|
|
239
|
+
async updateConfig(server, mutate) {
|
|
240
|
+
const { value, mapping, key, target, resource } = this._getConfig(server);
|
|
241
|
+
const newConfig = { ...value };
|
|
242
|
+
mutate(newConfig);
|
|
243
|
+
await this._configurationService.updateValue(mcpServerSamplingSection, { ...mapping, [key]: newConfig }, { resource }, target);
|
|
244
|
+
return newConfig;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
McpSamplingService = ( __decorate([
|
|
248
|
+
( __param(0, ILanguageModelsService)),
|
|
249
|
+
( __param(1, IConfigurationService)),
|
|
250
|
+
( __param(2, IDialogService)),
|
|
251
|
+
( __param(3, INotificationService)),
|
|
252
|
+
( __param(4, ICommandService)),
|
|
253
|
+
( __param(5, IInstantiationService))
|
|
254
|
+
], McpSamplingService));
|
|
255
|
+
|
|
256
|
+
export { McpSamplingService };
|
|
@@ -16,11 +16,14 @@ import { IOutputService } from "@codingame/monaco-vscode-api/vscode/vs/workbench
|
|
|
16
16
|
import { ToolProgress } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService";
|
|
17
17
|
import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
|
|
18
18
|
import { McpServerRequestHandler } from "./mcpServerRequestHandler.js";
|
|
19
|
-
import { IMcpServer, IMcpServerConnection, IMcpTool, McpCollectionReference, McpConnectionState, McpDefinitionReference,
|
|
20
|
-
import {
|
|
19
|
+
import { IMcpPrompt, IMcpResource, IMcpResourceTemplate, IMcpServer, IMcpServerConnection, IMcpServerStartOpts, IMcpTool, McpCapability, McpCollectionDefinition, McpCollectionReference, McpConnectionState, McpDefinitionReference, McpServerCacheState, McpServerDefinition } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
|
|
20
|
+
import { IMcpSamplingService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service";
|
|
21
|
+
import { MCP } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/modelContextProtocol";
|
|
21
22
|
interface IToolCacheEntry {
|
|
22
23
|
readonly nonce: string | undefined;
|
|
23
24
|
readonly tools: readonly IValidatedMcpTool[];
|
|
25
|
+
readonly prompts: readonly MCP.Prompt[] | undefined;
|
|
26
|
+
readonly capabilities: McpCapability | undefined;
|
|
24
27
|
}
|
|
25
28
|
interface IServerCacheEntry {
|
|
26
29
|
readonly servers: readonly McpServerDefinition.Serialized[];
|
|
@@ -31,8 +34,8 @@ export declare class McpServerMetadataCache extends Disposable {
|
|
|
31
34
|
private readonly extensionServers;
|
|
32
35
|
constructor(scope: StorageScope, storageService: IStorageService);
|
|
33
36
|
reset(): void;
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
get(definitionId: string): IToolCacheEntry | undefined;
|
|
38
|
+
store(definitionId: string, entry: IToolCacheEntry): void;
|
|
36
39
|
getServers(collectionId: string): IServerCacheEntry | undefined;
|
|
37
40
|
storeServers(collectionId: string, entry: IServerCacheEntry | undefined): void;
|
|
38
41
|
}
|
|
@@ -43,7 +46,7 @@ export declare class McpServer extends Disposable implements IMcpServer {
|
|
|
43
46
|
readonly collection: McpCollectionReference;
|
|
44
47
|
readonly definition: McpDefinitionReference;
|
|
45
48
|
private readonly _requiresExtensionActivation;
|
|
46
|
-
private readonly
|
|
49
|
+
private readonly _primitiveCache;
|
|
47
50
|
private readonly _mcpRegistry;
|
|
48
51
|
private readonly _extensionService;
|
|
49
52
|
private readonly _loggerService;
|
|
@@ -53,33 +56,46 @@ export declare class McpServer extends Disposable implements IMcpServer {
|
|
|
53
56
|
private readonly _instantiationService;
|
|
54
57
|
private readonly _notificationService;
|
|
55
58
|
private readonly _openerService;
|
|
59
|
+
private readonly _samplingService;
|
|
60
|
+
static callOn<R>(server: IMcpServer, fn: (handler: McpServerRequestHandler) => Promise<R>, token?: CancellationToken): Promise<R>;
|
|
56
61
|
private readonly _connectionSequencer;
|
|
57
62
|
private readonly _connection;
|
|
58
63
|
readonly connection: import("@codingame/monaco-vscode-api/vscode/vs/base/common/observable").ISettableObservable<IMcpServerConnection | undefined, void> & IDisposable;
|
|
59
64
|
readonly connectionState: IObservable<McpConnectionState>;
|
|
60
|
-
private
|
|
61
|
-
|
|
62
|
-
private readonly
|
|
63
|
-
|
|
64
|
-
readonly
|
|
65
|
+
private readonly _capabilities;
|
|
66
|
+
get capabilities(): import("@codingame/monaco-vscode-api/vscode/vs/base/common/observable").ISettableObservable<number | undefined, void>;
|
|
67
|
+
private readonly _tools;
|
|
68
|
+
get tools(): IObservable<readonly IMcpTool[]>;
|
|
69
|
+
private readonly _prompts;
|
|
70
|
+
get prompts(): IObservable<readonly IMcpPrompt[]>;
|
|
71
|
+
private readonly _fullDefinitions;
|
|
72
|
+
readonly cacheState: import("@codingame/monaco-vscode-api/vscode/vs/base/common/observable").IObservableWithChange<McpServerCacheState, void>;
|
|
65
73
|
private readonly _loggerId;
|
|
66
74
|
private readonly _logger;
|
|
75
|
+
private _lastModeDebugged;
|
|
76
|
+
runningToolCalls: number;
|
|
67
77
|
get trusted(): IObservable<boolean | undefined>;
|
|
68
|
-
constructor(collection: McpCollectionReference, definition: McpDefinitionReference, explicitRoots: URI[] | undefined, _requiresExtensionActivation: boolean | undefined,
|
|
78
|
+
constructor(collection: McpCollectionReference, definition: McpDefinitionReference, explicitRoots: URI[] | undefined, _requiresExtensionActivation: boolean | undefined, _primitiveCache: McpServerMetadataCache, toolPrefix: string, _mcpRegistry: IMcpRegistry, workspacesService: IWorkspaceContextService, _extensionService: IExtensionService, _loggerService: ILoggerService, _outputService: IOutputService, _telemetryService: ITelemetryService, _commandService: ICommandService, _instantiationService: IInstantiationService, _notificationService: INotificationService, _openerService: IOpenerService, _samplingService: IMcpSamplingService);
|
|
79
|
+
readDefinitions(): IObservable<{
|
|
80
|
+
server: McpServerDefinition | undefined;
|
|
81
|
+
collection: McpCollectionDefinition | undefined;
|
|
82
|
+
}>;
|
|
69
83
|
showOutput(): void;
|
|
70
|
-
|
|
84
|
+
resources(token?: CancellationToken): AsyncIterable<IMcpResource[]>;
|
|
85
|
+
resourceTemplates(token?: CancellationToken): Promise<IMcpResourceTemplate[]>;
|
|
86
|
+
start({ isFromInteraction, debug }?: IMcpServerStartOpts): Promise<McpConnectionState>;
|
|
71
87
|
private showInteractiveError;
|
|
72
88
|
stop(): Promise<void>;
|
|
73
89
|
private resetLiveData;
|
|
74
90
|
private _normalizeTool;
|
|
75
91
|
private _getValidatedTools;
|
|
76
92
|
private populateLiveData;
|
|
77
|
-
callOn<R>(fn: (handler: McpServerRequestHandler) => Promise<R>, token?: CancellationToken): Promise<R>;
|
|
78
93
|
}
|
|
79
94
|
export declare class McpTool implements IMcpTool {
|
|
80
95
|
private readonly _server;
|
|
81
96
|
private readonly _definition;
|
|
82
97
|
readonly id: string;
|
|
98
|
+
readonly referenceName: string;
|
|
83
99
|
get definition(): MCP.Tool;
|
|
84
100
|
constructor(_server: McpServer, idPrefix: string, _definition: IValidatedMcpTool);
|
|
85
101
|
call(params: Record<string, unknown>, token?: CancellationToken): Promise<MCP.CallToolResult>;
|