@codingame/monaco-vscode-mcp-service-override 28.4.0 → 29.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/package.json +2 -2
- package/vscode/src/vs/base/common/jsonRpcProtocol.d.ts +13 -1
- package/vscode/src/vs/base/common/jsonRpcProtocol.js +26 -13
- package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +1 -1
- package/vscode/src/vs/platform/mcp/common/mcpGalleryManifestService.js +2 -1
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +8 -5
- package/vscode/src/vs/platform/mcp/common/mcpGateway.d.ts +49 -18
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +3 -3
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +81 -67
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +267 -50
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayService.js +17 -3
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +24 -21
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpMigration.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.js +8 -8
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +18 -18
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +37 -9
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/pluginMcpDiscovery.js +11 -3
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.d.ts +8 -9
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.js +147 -132
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +10 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +14 -14
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +11 -11
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.js +15 -8
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +7 -22
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.d.ts +4 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +16 -4
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +9 -9
- package/vscode/src/vs/workbench/services/mcp/browser/mcpGalleryManifestService.js +2 -2
|
@@ -16,8 +16,7 @@ class McpGatewayToolBrokerChannel extends Disposable {
|
|
|
16
16
|
this._startupGracePeriodMs = _startupGracePeriodMs;
|
|
17
17
|
this._onDidChangeTools = this._register(( new Emitter()));
|
|
18
18
|
this._onDidChangeResources = this._register(( new Emitter()));
|
|
19
|
-
this.
|
|
20
|
-
this._nextServerIndex = 0;
|
|
19
|
+
this._onDidChangeServers = this._register(( new Emitter()));
|
|
21
20
|
this._startupGrace = ( new Map());
|
|
22
21
|
this._logService.debug("[McpGateway][ToolBroker] Initialized");
|
|
23
22
|
let toolsInitialized = false;
|
|
@@ -44,19 +43,23 @@ class McpGatewayToolBrokerChannel extends Disposable {
|
|
|
44
43
|
resourcesInitialized = true;
|
|
45
44
|
}
|
|
46
45
|
}));
|
|
46
|
+
let serversInitialized = false;
|
|
47
|
+
this._register(autorun(reader => {
|
|
48
|
+
const servers = this._mcpService.servers.read(reader);
|
|
49
|
+
if (serversInitialized) {
|
|
50
|
+
this._logService.debug("[McpGateway][ToolBroker] Servers changed, firing onDidChangeServers");
|
|
51
|
+
this._onDidChangeServers.fire(( servers.map(s => ({
|
|
52
|
+
id: s.definition.id,
|
|
53
|
+
label: s.definition.label
|
|
54
|
+
}))));
|
|
55
|
+
} else {
|
|
56
|
+
serversInitialized = true;
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
47
59
|
}
|
|
48
|
-
|
|
49
|
-
const defId = server.definition.id;
|
|
50
|
-
let index = this._serverIdMap.get(defId);
|
|
51
|
-
if (index === undefined) {
|
|
52
|
-
index = this._nextServerIndex++;
|
|
53
|
-
this._serverIdMap.set(defId, index);
|
|
54
|
-
}
|
|
55
|
-
return index;
|
|
56
|
-
}
|
|
57
|
-
_getServerByIndex(serverIndex) {
|
|
60
|
+
_getServerById(serverId) {
|
|
58
61
|
for (const server of this._mcpService.servers.get()) {
|
|
59
|
-
if (
|
|
62
|
+
if (server.definition.id === serverId) {
|
|
60
63
|
return server;
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -98,181 +101,193 @@ class McpGatewayToolBrokerChannel extends Disposable {
|
|
|
98
101
|
return this._onDidChangeTools.event;
|
|
99
102
|
case "onDidChangeResources":
|
|
100
103
|
return this._onDidChangeResources.event;
|
|
104
|
+
case "onDidChangeServers":
|
|
105
|
+
return this._onDidChangeServers.event;
|
|
101
106
|
}
|
|
102
107
|
throw ( new Error(`Invalid listen: ${event}`));
|
|
103
108
|
}
|
|
104
109
|
async call(_ctx, command, arg, cancellationToken) {
|
|
105
110
|
this._logService.debug(`[McpGateway][ToolBroker] IPC call: ${command}`);
|
|
106
111
|
switch (command) {
|
|
107
|
-
case "
|
|
112
|
+
case "listServers":
|
|
113
|
+
{
|
|
114
|
+
const servers = this._listServers();
|
|
115
|
+
return servers;
|
|
116
|
+
}
|
|
117
|
+
case "listToolsForServer":
|
|
108
118
|
{
|
|
109
|
-
const
|
|
119
|
+
const {
|
|
120
|
+
serverId
|
|
121
|
+
} = arg;
|
|
122
|
+
const tools = await this._listToolsForServer(serverId);
|
|
110
123
|
return tools;
|
|
111
124
|
}
|
|
112
|
-
case "
|
|
125
|
+
case "callToolForServer":
|
|
113
126
|
{
|
|
114
127
|
const {
|
|
128
|
+
serverId,
|
|
115
129
|
name,
|
|
116
130
|
args
|
|
117
131
|
} = arg;
|
|
118
|
-
const result = await this.
|
|
132
|
+
const result = await this._callToolForServer(serverId, name, args || {}, cancellationToken);
|
|
119
133
|
return result;
|
|
120
134
|
}
|
|
121
|
-
case "
|
|
135
|
+
case "listResourcesForServer":
|
|
122
136
|
{
|
|
123
|
-
const
|
|
137
|
+
const {
|
|
138
|
+
serverId
|
|
139
|
+
} = arg;
|
|
140
|
+
const resources = await this._listResourcesForServer(serverId);
|
|
124
141
|
return resources;
|
|
125
142
|
}
|
|
126
|
-
case "
|
|
143
|
+
case "readResourceForServer":
|
|
127
144
|
{
|
|
128
145
|
const {
|
|
129
|
-
|
|
146
|
+
serverId,
|
|
130
147
|
uri
|
|
131
148
|
} = arg;
|
|
132
|
-
const result = await this.
|
|
149
|
+
const result = await this._readResourceForServer(serverId, uri, cancellationToken);
|
|
133
150
|
return result;
|
|
134
151
|
}
|
|
135
|
-
case "
|
|
152
|
+
case "listResourceTemplatesForServer":
|
|
136
153
|
{
|
|
137
|
-
const
|
|
154
|
+
const {
|
|
155
|
+
serverId
|
|
156
|
+
} = arg;
|
|
157
|
+
const templates = await this._listResourceTemplatesForServer(serverId);
|
|
138
158
|
return templates;
|
|
139
159
|
}
|
|
140
160
|
}
|
|
141
161
|
throw ( new Error(`Invalid call: ${command}`));
|
|
142
162
|
}
|
|
143
|
-
|
|
163
|
+
_listServers() {
|
|
144
164
|
const servers = this._mcpService.servers.get();
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return ( server.tools.get().filter(t => t.visibility & McpToolVisibility.Model).map(t => t.definition));
|
|
153
|
-
})));
|
|
154
|
-
const mcpTools = perServer.flat();
|
|
165
|
+
const result = [];
|
|
166
|
+
for (const server of servers) {
|
|
167
|
+
result.push({
|
|
168
|
+
id: server.definition.id,
|
|
169
|
+
label: server.definition.label
|
|
170
|
+
});
|
|
171
|
+
}
|
|
155
172
|
this._logService.debug(
|
|
156
|
-
`[McpGateway][ToolBroker]
|
|
173
|
+
`[McpGateway][ToolBroker] listServers result: ${result.length} server(s): [${( result.map(s => s.label)).join(", ")}]`
|
|
157
174
|
);
|
|
158
|
-
return
|
|
175
|
+
return result;
|
|
159
176
|
}
|
|
160
|
-
async
|
|
161
|
-
this.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const tool = server.tools.get().find(
|
|
166
|
-
t => t.definition.name === name && (t.visibility & McpToolVisibility.Model)
|
|
177
|
+
async _listToolsForServer(serverId) {
|
|
178
|
+
const server = this._getServerById(serverId);
|
|
179
|
+
if (!server) {
|
|
180
|
+
this._logService.warn(
|
|
181
|
+
`[McpGateway][ToolBroker] listToolsForServer: unknown server '${serverId}'`
|
|
167
182
|
);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
);
|
|
176
|
-
return {
|
|
177
|
-
result,
|
|
178
|
-
serverIndex: this._getServerIndex(server)
|
|
179
|
-
};
|
|
180
|
-
}
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
if (!(await this._shouldUseCachedData(server))) {
|
|
186
|
+
this._logService.debug(
|
|
187
|
+
`[McpGateway][ToolBroker] Server '${serverId}' not ready, skipping tool listing`
|
|
188
|
+
);
|
|
189
|
+
return [];
|
|
181
190
|
}
|
|
182
|
-
|
|
183
|
-
|
|
191
|
+
const tools = ( server.tools.get().filter(t => t.visibility & McpToolVisibility.Model).map(t => t.definition));
|
|
192
|
+
this._logService.debug(
|
|
193
|
+
`[McpGateway][ToolBroker] listToolsForServer '${serverId}': ${tools.length} tool(s)`
|
|
194
|
+
);
|
|
195
|
+
return tools;
|
|
184
196
|
}
|
|
185
|
-
async
|
|
186
|
-
const results = [];
|
|
187
|
-
const servers = this._mcpService.servers.get();
|
|
197
|
+
async _callToolForServer(serverId, name, args, token = CancellationToken.None) {
|
|
188
198
|
this._logService.debug(
|
|
189
|
-
`[McpGateway][ToolBroker]
|
|
199
|
+
`[McpGateway][ToolBroker] callToolForServer '${serverId}' tool '${name}' with args: ${JSON.stringify(args)}`
|
|
190
200
|
);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
const resources = await McpServer.callOn(server, h => h.listResources());
|
|
204
|
-
this._logService.debug(
|
|
205
|
-
`[McpGateway][ToolBroker] Server '${server.definition.id}' (index=${this._getServerIndex(server)}) listed ${resources.length} resource(s)`
|
|
206
|
-
);
|
|
207
|
-
results.push({
|
|
208
|
-
serverIndex: this._getServerIndex(server),
|
|
209
|
-
resources
|
|
210
|
-
});
|
|
211
|
-
} catch (error) {
|
|
212
|
-
this._logService.warn(
|
|
213
|
-
`[McpGateway][ToolBroker] Server '${server.definition.id}' failed to list resources`,
|
|
214
|
-
error
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
})));
|
|
201
|
+
const server = this._getServerById(serverId);
|
|
202
|
+
if (!server) {
|
|
203
|
+
throw ( new Error(`Unknown server: ${serverId}`));
|
|
204
|
+
}
|
|
205
|
+
const tool = server.tools.get().find(
|
|
206
|
+
t => t.definition.name === name && (t.visibility & McpToolVisibility.Model)
|
|
207
|
+
);
|
|
208
|
+
if (!tool) {
|
|
209
|
+
throw ( new Error(`Unknown tool '${name}' on server '${serverId}'`));
|
|
210
|
+
}
|
|
211
|
+
const result = await tool.call(args, undefined, token);
|
|
218
212
|
this._logService.debug(
|
|
219
|
-
`[McpGateway][ToolBroker]
|
|
213
|
+
`[McpGateway][ToolBroker] Tool '${name}' on '${serverId}' completed (isError=${result.isError ?? false}, content blocks=${result.content.length})`
|
|
220
214
|
);
|
|
221
|
-
return
|
|
215
|
+
return result;
|
|
222
216
|
}
|
|
223
|
-
async
|
|
224
|
-
const server = this.
|
|
217
|
+
async _listResourcesForServer(serverId) {
|
|
218
|
+
const server = this._getServerById(serverId);
|
|
225
219
|
if (!server) {
|
|
226
220
|
this._logService.warn(
|
|
227
|
-
`[McpGateway][ToolBroker]
|
|
221
|
+
`[McpGateway][ToolBroker] listResourcesForServer: unknown server '${serverId}'`
|
|
222
|
+
);
|
|
223
|
+
return [];
|
|
224
|
+
}
|
|
225
|
+
if (!(await this._shouldUseCachedData(server))) {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
const capabilities = server.capabilities.get();
|
|
229
|
+
if (!capabilities || !(capabilities & McpCapability.Resources)) {
|
|
230
|
+
this._logService.debug(`[McpGateway][ToolBroker] Server '${serverId}' has no resource capability`);
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
const resources = await McpServer.callOn(server, h => h.listResources());
|
|
235
|
+
this._logService.debug(
|
|
236
|
+
`[McpGateway][ToolBroker] Server '${serverId}' listed ${resources.length} resource(s)`
|
|
237
|
+
);
|
|
238
|
+
return resources;
|
|
239
|
+
} catch (error) {
|
|
240
|
+
this._logService.warn(
|
|
241
|
+
`[McpGateway][ToolBroker] Server '${serverId}' failed to list resources`,
|
|
242
|
+
error
|
|
228
243
|
);
|
|
229
|
-
|
|
244
|
+
return [];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async _readResourceForServer(serverId, uri, token = CancellationToken.None) {
|
|
248
|
+
const server = this._getServerById(serverId);
|
|
249
|
+
if (!server) {
|
|
250
|
+
throw ( new Error(`Unknown server: ${serverId}`));
|
|
230
251
|
}
|
|
231
252
|
this._logService.debug(
|
|
232
|
-
`[McpGateway][ToolBroker]
|
|
253
|
+
`[McpGateway][ToolBroker] readResourceForServer '${uri}' from server '${serverId}'`
|
|
233
254
|
);
|
|
234
255
|
const result = await McpServer.callOn(server, h => h.readResource({
|
|
235
256
|
uri
|
|
236
257
|
}, token), token);
|
|
237
258
|
this._logService.debug(
|
|
238
|
-
`[McpGateway][ToolBroker]
|
|
259
|
+
`[McpGateway][ToolBroker] readResourceForServer returned ${result.contents.length} content(s)`
|
|
239
260
|
);
|
|
240
261
|
return result;
|
|
241
262
|
}
|
|
242
|
-
async
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
})));
|
|
272
|
-
this._logService.debug(
|
|
273
|
-
`[McpGateway][ToolBroker] listResourceTemplates result: ${results.length} server(s) with templates`
|
|
274
|
-
);
|
|
275
|
-
return results;
|
|
263
|
+
async _listResourceTemplatesForServer(serverId) {
|
|
264
|
+
const server = this._getServerById(serverId);
|
|
265
|
+
if (!server) {
|
|
266
|
+
this._logService.warn(
|
|
267
|
+
`[McpGateway][ToolBroker] listResourceTemplatesForServer: unknown server '${serverId}'`
|
|
268
|
+
);
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
if (!(await this._shouldUseCachedData(server))) {
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
const capabilities = server.capabilities.get();
|
|
275
|
+
if (!capabilities || !(capabilities & McpCapability.Resources)) {
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
const resourceTemplates = await McpServer.callOn(server, h => h.listResourceTemplates());
|
|
280
|
+
this._logService.debug(
|
|
281
|
+
`[McpGateway][ToolBroker] Server '${serverId}' listed ${resourceTemplates.length} resource template(s)`
|
|
282
|
+
);
|
|
283
|
+
return resourceTemplates;
|
|
284
|
+
} catch (error) {
|
|
285
|
+
this._logService.warn(
|
|
286
|
+
`[McpGateway][ToolBroker] Server '${serverId}' failed to list resource templates`,
|
|
287
|
+
error
|
|
288
|
+
);
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
276
291
|
}
|
|
277
292
|
async _ensureServerReady(server) {
|
|
278
293
|
const cacheState = server.cacheState.get();
|
|
@@ -17,6 +17,7 @@ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/pl
|
|
|
17
17
|
import { mcpAppsEnabledConfig } from '@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/mcpManagement';
|
|
18
18
|
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
19
19
|
import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
20
|
+
import { isContributionEnabled } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/enablement';
|
|
20
21
|
import { getAttachableImageExtension, ChatResponseResource } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/model/chatModel';
|
|
21
22
|
import { LanguageModelPartAudience } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
|
|
22
23
|
import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/languageModelToolsService.service';
|
|
@@ -49,6 +50,9 @@ let McpLanguageModelToolContribution = class McpLanguageModelToolContribution ex
|
|
|
49
50
|
const servers = mcpService.servers.read(reader);
|
|
50
51
|
const toDelete = ( new Set(( previous.keys())));
|
|
51
52
|
for (const server of servers) {
|
|
53
|
+
if (!isContributionEnabled(server.enablement.read(reader))) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
52
56
|
const previousRec = previous.get(server);
|
|
53
57
|
if (previousRec) {
|
|
54
58
|
toDelete.delete(server);
|
|
@@ -67,7 +71,7 @@ let McpLanguageModelToolContribution = class McpLanguageModelToolContribution ex
|
|
|
67
71
|
const toolSet = store.add(
|
|
68
72
|
this._toolsService.createToolSet(source, server.definition.id, referenceName, {
|
|
69
73
|
icon: Codicon.mcp,
|
|
70
|
-
description: ( localize(
|
|
74
|
+
description: ( localize(10673, "{0}: All Tools", server.definition.label))
|
|
71
75
|
})
|
|
72
76
|
);
|
|
73
77
|
return {
|
|
@@ -187,7 +191,7 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
187
191
|
});
|
|
188
192
|
const isSandboxedServer = sandboxEnabled === true;
|
|
189
193
|
const mcpToolWarning = ( localize(
|
|
190
|
-
|
|
194
|
+
10674,
|
|
191
195
|
"Note that MCP servers or malicious conversation content may attempt to misuse '{0}' through tools.",
|
|
192
196
|
this._productService.nameShort
|
|
193
197
|
));
|
|
@@ -196,7 +200,7 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
196
200
|
if (!isSandboxedServer) {
|
|
197
201
|
confirm = {};
|
|
198
202
|
if (!tool.definition.annotations?.readOnlyHint) {
|
|
199
|
-
confirm.title = ( new MarkdownString(( localize(
|
|
203
|
+
confirm.title = ( new MarkdownString(( localize(10675, "Run {0}", title))));
|
|
200
204
|
confirm.message = ( new MarkdownString(tool.definition.description, {
|
|
201
205
|
supportThemeIcons: true
|
|
202
206
|
}));
|
|
@@ -210,9 +214,9 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
210
214
|
const mcpUiEnabled = this._configurationService.getValue(mcpAppsEnabledConfig);
|
|
211
215
|
return {
|
|
212
216
|
confirmationMessages: confirm,
|
|
213
|
-
invocationMessage: ( new MarkdownString(( localize(
|
|
214
|
-
pastTenseMessage: ( new MarkdownString(( localize(
|
|
215
|
-
originMessage: ( localize(
|
|
217
|
+
invocationMessage: ( new MarkdownString(( localize(10676, "Running {0}", title)))),
|
|
218
|
+
pastTenseMessage: ( new MarkdownString(( localize(10677, "Ran {0} ", title)))),
|
|
219
|
+
originMessage: ( localize(10678, "{0} (MCP Server)", server.definition.label)),
|
|
216
220
|
toolSpecificData: {
|
|
217
221
|
kind: "input",
|
|
218
222
|
rawInput: context.parameters,
|
|
@@ -34,10 +34,10 @@ import { McpRegistryInputStorage } from './mcpRegistryInputStorage.js';
|
|
|
34
34
|
import { IMcpSandboxService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpSandboxService.service';
|
|
35
35
|
import { McpServerConnection } from './mcpServerConnection.js';
|
|
36
36
|
import { LazyCollectionState, UserInteractionRequiredError, McpServerTrust, McpStartServerInteraction } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
37
|
-
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
38
37
|
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
39
38
|
import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/derived';
|
|
40
39
|
import { autorunSelfDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
40
|
+
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
41
41
|
|
|
42
42
|
const notTrustedNonce = "__vscode_not_trusted";
|
|
43
43
|
let McpRegistry = class McpRegistry extends Disposable {
|
|
@@ -227,7 +227,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
227
227
|
if (errorOnUserInteraction) {
|
|
228
228
|
throw ( new UserInteractionRequiredError("workspaceTrust"));
|
|
229
229
|
} else if (!(await this._workspaceTrustRequestService.requestWorkspaceTrust({
|
|
230
|
-
message: ( localize(
|
|
230
|
+
message: ( localize(10679, "This MCP server definition is defined in your workspace files."))
|
|
231
231
|
}))) {
|
|
232
232
|
return false;
|
|
233
233
|
}
|
|
@@ -305,7 +305,7 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
305
305
|
const originURI = r.definition.presentation?.origin?.uri || r.collection.presentation?.origin;
|
|
306
306
|
let labelWithOrigin = originURI ? `[\`${r.definition.label}\`](${originURI})` : "`" + r.definition.label + "`";
|
|
307
307
|
if (r.collection.source instanceof ExtensionIdentifier) {
|
|
308
|
-
labelWithOrigin += ` (${( localize(
|
|
308
|
+
labelWithOrigin += ` (${( localize(10680, "from {0}", r.collection.source.value))})`;
|
|
309
309
|
}
|
|
310
310
|
return labelWithOrigin;
|
|
311
311
|
}
|
|
@@ -315,12 +315,12 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
315
315
|
const {
|
|
316
316
|
result
|
|
317
317
|
} = await this._dialogService.prompt({
|
|
318
|
-
message: ( localize(
|
|
318
|
+
message: ( localize(10681, "Trust and run MCP server {0}?", def.definition.label)),
|
|
319
319
|
custom: {
|
|
320
320
|
icon: Codicon.shield,
|
|
321
321
|
markdownDetails: [{
|
|
322
322
|
markdown: ( new MarkdownString(( localize(
|
|
323
|
-
|
|
323
|
+
10682,
|
|
324
324
|
"The MCP server {0} was updated. MCP servers may add context to your chat session and lead to unexpected behavior. Do you want to trust and run this server?",
|
|
325
325
|
labelFor(def)
|
|
326
326
|
)))),
|
|
@@ -333,10 +333,10 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
333
333
|
}]
|
|
334
334
|
},
|
|
335
335
|
buttons: [{
|
|
336
|
-
label: ( localize(
|
|
336
|
+
label: ( localize(10683, "Trust")),
|
|
337
337
|
run: () => true
|
|
338
338
|
}, {
|
|
339
|
-
label: ( localize(
|
|
339
|
+
label: ( localize(10684, "Do not trust")),
|
|
340
340
|
run: () => false
|
|
341
341
|
}]
|
|
342
342
|
});
|
|
@@ -346,12 +346,12 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
346
346
|
const {
|
|
347
347
|
result
|
|
348
348
|
} = await this._dialogService.prompt({
|
|
349
|
-
message: ( localize(
|
|
349
|
+
message: ( localize(10685, "Trust and run {0} MCP servers?", definitions.length)),
|
|
350
350
|
custom: {
|
|
351
351
|
icon: Codicon.shield,
|
|
352
352
|
markdownDetails: [{
|
|
353
353
|
markdown: ( new MarkdownString(( localize(
|
|
354
|
-
|
|
354
|
+
10686,
|
|
355
355
|
"Several updated MCP servers were discovered:\n\n{0}\n\n MCP servers may add context to your chat session and lead to unexpected behavior. Do you want to trust and run these server?",
|
|
356
356
|
list
|
|
357
357
|
)))),
|
|
@@ -364,13 +364,13 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
364
364
|
}]
|
|
365
365
|
},
|
|
366
366
|
buttons: [{
|
|
367
|
-
label: ( localize(
|
|
367
|
+
label: ( localize(10683, "Trust")),
|
|
368
368
|
run: () => "all"
|
|
369
369
|
}, {
|
|
370
|
-
label: ( localize(
|
|
370
|
+
label: ( localize(10687, "Pick Trusted")),
|
|
371
371
|
run: () => "pick"
|
|
372
372
|
}, {
|
|
373
|
-
label: ( localize(
|
|
373
|
+
label: ( localize(10684, "Do not trust")),
|
|
374
374
|
run: () => "none"
|
|
375
375
|
}]
|
|
376
376
|
});
|
|
@@ -533,14 +533,14 @@ let McpRegistry = class McpRegistry extends Disposable {
|
|
|
533
533
|
}
|
|
534
534
|
this._notificationService.notify({
|
|
535
535
|
severity: Severity.Error,
|
|
536
|
-
message: ( localize(
|
|
536
|
+
message: ( localize(10688, "Error starting {0}: {1}", definition.label, String(e))),
|
|
537
537
|
actions: {
|
|
538
538
|
primary: collection.presentation?.origin && [{
|
|
539
539
|
id: "mcp.launchError.openConfig",
|
|
540
540
|
class: undefined,
|
|
541
541
|
enabled: true,
|
|
542
542
|
tooltip: "",
|
|
543
|
-
label: ( localize(
|
|
543
|
+
label: ( localize(10689, "Open Configuration")),
|
|
544
544
|
run: () => this._editorService.openEditor({
|
|
545
545
|
resource: collection.presentation.origin,
|
|
546
546
|
options: {
|
|
@@ -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(10690, "{0} total requests in the last 7 days.", total)));
|
|
45
45
|
parts.push(this._formatRecentRequests(record));
|
|
46
46
|
return parts.join("\n");
|
|
47
47
|
}
|
|
@@ -131,11 +131,11 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
131
131
|
return this._getMatchingModel(opts);
|
|
132
132
|
}
|
|
133
133
|
const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
|
|
134
|
-
|
|
134
|
+
10691,
|
|
135
135
|
"Allow MCP tools from \"{0}\" to make LLM requests?",
|
|
136
136
|
opts.server.definition.label
|
|
137
137
|
)), ( localize(
|
|
138
|
-
|
|
138
|
+
10692,
|
|
139
139
|
"The MCP server \"{0}\" has issued a request to make a language model call. Do you want to allow it to make requests during chat?",
|
|
140
140
|
opts.server.definition.label
|
|
141
141
|
)), this.allowButtons(opts.server, "allowedDuringChat"));
|
|
@@ -149,11 +149,11 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
149
149
|
return this._getMatchingModel(opts);
|
|
150
150
|
}
|
|
151
151
|
const retry = await this._showContextual(opts.isDuringToolCall, ( localize(
|
|
152
|
-
|
|
152
|
+
10693,
|
|
153
153
|
"Allow MCP server \"{0}\" to make LLM requests?",
|
|
154
154
|
opts.server.definition.label
|
|
155
155
|
)), ( localize(
|
|
156
|
-
|
|
156
|
+
10694,
|
|
157
157
|
"The MCP server \"{0}\" has issued a request to make a language model call. Do you want to allow it to make requests, outside of tool calls during chat?",
|
|
158
158
|
opts.server.definition.label
|
|
159
159
|
)), this.allowButtons(opts.server, "allowedOutsideChat"));
|
|
@@ -165,12 +165,12 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
165
165
|
throw McpError.notAllowed();
|
|
166
166
|
} else if (model === ModelMatch.NoMatchingModel) {
|
|
167
167
|
const newlyPickedModels = opts.isDuringToolCall ? await this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server) : await this._notify(( localize(
|
|
168
|
-
|
|
168
|
+
10695,
|
|
169
169
|
"MCP server \"{0}\" triggered a language model request, but it has no allowlisted models.",
|
|
170
170
|
opts.server.definition.label
|
|
171
171
|
)), {
|
|
172
|
-
[( localize(
|
|
173
|
-
[( localize(
|
|
172
|
+
[( localize(10696, "Configure"))]: () => this._commandService.executeCommand(McpCommandIds.ConfigureSamplingModels, opts.server),
|
|
173
|
+
[( localize(10697, "Cancel"))]: () => Promise.resolve(undefined)
|
|
174
174
|
});
|
|
175
175
|
if (newlyPickedModels) {
|
|
176
176
|
return this._getMatchingModel(opts);
|
|
@@ -181,19 +181,19 @@ let McpSamplingService = class McpSamplingService extends Disposable {
|
|
|
181
181
|
}
|
|
182
182
|
allowButtons(server, key) {
|
|
183
183
|
return {
|
|
184
|
-
[( localize(
|
|
184
|
+
[( localize(10698, "Allow in this Session"))]: async () => {
|
|
185
185
|
this._sessionSets[key].set(server.definition.id, true);
|
|
186
186
|
return true;
|
|
187
187
|
},
|
|
188
|
-
[( localize(
|
|
188
|
+
[( localize(10699, "Always"))]: async () => {
|
|
189
189
|
await this.updateConfig(server, c => c[key] = true);
|
|
190
190
|
return true;
|
|
191
191
|
},
|
|
192
|
-
[( localize(
|
|
192
|
+
[( localize(10700, "Not Now"))]: async () => {
|
|
193
193
|
this._sessionSets[key].set(server.definition.id, false);
|
|
194
194
|
return false;
|
|
195
195
|
},
|
|
196
|
-
[( localize(
|
|
196
|
+
[( localize(10701, "Never"))]: async () => {
|
|
197
197
|
await this.updateConfig(server, c => c[key] = false);
|
|
198
198
|
return false;
|
|
199
199
|
}
|
|
@@ -23,6 +23,7 @@ export declare class McpSandboxService extends Disposable implements IMcpSandbox
|
|
|
23
23
|
private _sandboxSettingsId;
|
|
24
24
|
private _remoteEnvDetailsPromise;
|
|
25
25
|
private readonly _defaultAllowedDomains;
|
|
26
|
+
private _defaultAllowWritePaths;
|
|
26
27
|
private _sandboxConfigPerConfigurationTarget;
|
|
27
28
|
constructor(_fileService: IFileService, _environmentService: IEnvironmentService, _logService: ILogService, _mcpResourceScannerService: IMcpResourceScannerService, _remoteAgentService: IRemoteAgentService);
|
|
28
29
|
isEnabled(serverDef: McpServerDefinition, remoteAuthority?: string): Promise<boolean>;
|
|
@@ -44,4 +45,5 @@ export declare class McpSandboxService extends Disposable implements IMcpSandbox
|
|
|
44
45
|
private _getDefaultAllowWrite;
|
|
45
46
|
private _pathJoin;
|
|
46
47
|
private _getPathDelimiter;
|
|
48
|
+
private _quoteShellArgument;
|
|
47
49
|
}
|