@codingame/monaco-vscode-mcp-service-override 36.2.6 → 37.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.
Files changed (49) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/base/common/jsonRpcProtocol.d.ts +2 -2
  3. package/vscode/src/vs/platform/mcp/common/allowedMcpServers.d.ts +52 -0
  4. package/vscode/src/vs/platform/mcp/common/allowedMcpServers.js +180 -0
  5. package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.d.ts +4 -0
  6. package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +68 -12
  7. package/vscode/src/vs/platform/mcp/common/mcpGalleryService.d.ts +5 -1
  8. package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +200 -92
  9. package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.js +3 -2
  10. package/vscode/src/vs/platform/mcp/common/nativeMcpDiscoveryHelper.d.ts +1 -0
  11. package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +3 -3
  12. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +2 -2
  13. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.d.ts +10 -3
  14. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +357 -121
  15. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +25 -25
  16. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.d.ts +11 -1
  17. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +409 -145
  18. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpMigration.js +4 -4
  19. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.js +8 -8
  20. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditor.js +37 -37
  21. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.js +2 -2
  22. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerIcons.js +5 -5
  23. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerWidgets.js +5 -5
  24. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +18 -18
  25. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.d.ts +12 -0
  26. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +279 -72
  27. package/vscode/src/vs/workbench/contrib/mcp/browser/media/mcpServersView.css +1 -1
  28. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +6 -5
  29. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/installedMcpServersDiscovery.js +9 -16
  30. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.d.ts +4 -4
  31. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +7 -3
  32. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.d.ts +14 -6
  33. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.js +32 -9
  34. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceDotMcpDiscovery.d.ts +2 -2
  35. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceDotMcpDiscovery.js +20 -6
  36. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.js +9 -5
  37. package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +4 -4
  38. package/vscode/src/vs/workbench/contrib/mcp/common/mcpEditorAffordanceState.d.ts +13 -0
  39. package/vscode/src/vs/workbench/contrib/mcp/common/mcpEditorAffordanceState.js +36 -0
  40. package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +6 -6
  41. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.d.ts +2 -0
  42. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +51 -19
  43. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +1 -1
  44. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +11 -11
  45. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.d.ts +4 -0
  46. package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.js +42 -6
  47. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +3 -3
  48. package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +6 -3
  49. package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +9 -9
@@ -4,12 +4,27 @@ import { computeLevenshteinDistance } from '@codingame/monaco-vscode-api/vscode/
4
4
  import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
5
5
  import { MarkdownString, createMarkdownCommandLink } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
6
6
  import { parseTree, findNodeAtLocation } from '@codingame/monaco-vscode-api/vscode/vs/base/common/json';
7
- import { Disposable, MutableDisposable, dispose, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
7
+ import { Disposable, MutableDisposable, DisposableStore, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
8
8
  import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
9
9
  import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
10
10
  import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
11
11
  import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
12
12
  import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
13
+ import { LOCAL_AGENT_HOST_SCHEME_PREFIX } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostConnectionsService';
14
+ import { IAgentHostConnectionsService } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostConnectionsService.service';
15
+ import { remoteAgentHostSessionTypeId } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostSessionType';
16
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentService';
17
+ import { isCustomizationEnabled } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/customizationEnablement';
18
+ import { ActionType } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/common/actions';
19
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-root/state';
20
+ import { McpServerStatus, CustomizationType } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-session/state';
21
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-chat/state';
22
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-terminal/state';
23
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-changeset/state';
24
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-resource-watch/state';
25
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-automation/state';
26
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-automation-run/state';
27
+ import { StateComponents } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/sessionState';
13
28
  import { ConfigurationTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
14
29
  import { MarkerSeverity } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers';
15
30
  import { IMarkerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers.service';
@@ -17,12 +32,16 @@ import { ISecretStorageService } from '@codingame/monaco-vscode-api/vscode/vs/pl
17
32
  import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
18
33
  import { IConfigurationResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolver.service';
19
34
  import { ConfigurationResolverExpression } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolverExpression';
35
+ import { IAgentHostCustomizationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCustomizationService.service';
36
+ import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
37
+ import { isContributionDisabled } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/enablement';
20
38
  import { McpCommandIds } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpCommandIds';
21
39
  import { mcpConfigurationSection } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
40
+ import { getActiveAgentHostMcpSessionResource, countRunningMcpServersInOtherSessions } from '../common/mcpEditorAffordanceState.js';
22
41
  import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
23
- import { isContributionDisabled } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/enablement';
24
42
  import { McpConnectionState, mcpOAuthClientSecretStorageKey } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
25
43
  import { IMcpWorkbenchService, IMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
44
+ import { AgentSession } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agent';
26
45
 
27
46
  const diagnosticOwner = "vscode.mcp";
28
47
  let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
@@ -31,6 +50,9 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
31
50
  _mcpRegistry,
32
51
  _mcpWorkbenchService,
33
52
  _mcpService,
53
+ _chatWidgetService,
54
+ _agentHostCustomizationService,
55
+ _agentHostConnectionsService,
34
56
  _markerService,
35
57
  _configurationResolverService,
36
58
  _secretStorageService
@@ -39,6 +61,9 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
39
61
  this._mcpRegistry = _mcpRegistry;
40
62
  this._mcpWorkbenchService = _mcpWorkbenchService;
41
63
  this._mcpService = _mcpService;
64
+ this._chatWidgetService = _chatWidgetService;
65
+ this._agentHostCustomizationService = _agentHostCustomizationService;
66
+ this._agentHostConnectionsService = _agentHostConnectionsService;
42
67
  this._markerService = _markerService;
43
68
  this._configurationResolverService = _configurationResolverService;
44
69
  this._secretStorageService = _secretStorageService;
@@ -55,14 +80,57 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
55
80
  onDidChange: onDidChangeCodeLens.event,
56
81
  provideCodeLenses: (model, range) => this._provideCodeLenses(model, () => onDidChangeCodeLens.fire(codeLensProvider))
57
82
  };
83
+ const refreshCodeLens = () => onDidChangeCodeLens.fire(codeLensProvider);
58
84
  this._register(
59
85
  languageFeaturesService.codeLensProvider.register(patterns, codeLensProvider)
60
86
  );
61
87
  this._register(this._secretStorageService.onDidChangeSecret(key => {
62
88
  if (key.startsWith("mcp.oauth.clientSecret:")) {
63
- onDidChangeCodeLens.fire(codeLensProvider);
89
+ refreshCodeLens();
64
90
  }
65
91
  }));
92
+ const focusedWidgetViewModelListener = this._register(( new MutableDisposable()));
93
+ const updateFocusedWidgetViewModelListener = () => {
94
+ focusedWidgetViewModelListener.value = this._chatWidgetService.lastFocusedWidget?.onDidChangeViewModel(refreshCodeLens);
95
+ refreshCodeLens();
96
+ };
97
+ const connectionStateListeners = this._register(( new MutableDisposable()));
98
+ const updateConnectionStateListeners = () => {
99
+ const store = ( new DisposableStore());
100
+ for (const connectionInfo of this._agentHostConnectionsService.connections) {
101
+ const connection = connectionInfo.connection;
102
+ if (connection) {
103
+ store.add(connection.onDidAction((
104
+ {
105
+ action
106
+ }
107
+ ) => {
108
+ switch (action.type) {
109
+ case ActionType.SessionCustomizationsChanged:
110
+ case ActionType.SessionCustomizationUpdated:
111
+ case ActionType.SessionCustomizationRemoved:
112
+ case ActionType.SessionMcpServerStateChanged:
113
+ refreshCodeLens();
114
+ break;
115
+ }
116
+ }));
117
+ }
118
+ }
119
+ connectionStateListeners.value = store;
120
+ refreshCodeLens();
121
+ };
122
+ updateFocusedWidgetViewModelListener();
123
+ updateConnectionStateListeners();
124
+ this._register(
125
+ this._chatWidgetService.onDidChangeFocusedWidget(updateFocusedWidgetViewModelListener)
126
+ );
127
+ this._register(this._chatWidgetService.onDidChangeFocusedSession(refreshCodeLens));
128
+ this._register(
129
+ this._agentHostConnectionsService.onDidChangeConnections(updateConnectionStateListeners)
130
+ );
131
+ this._register(
132
+ this._agentHostCustomizationService.onDidChangeCustomizations(refreshCodeLens)
133
+ );
66
134
  this._register(languageFeaturesService.inlayHintsProvider.register(patterns, {
67
135
  onDidChangeInlayHints: _mcpRegistry.onDidChangeInputs,
68
136
  provideInlayHints: (model, range) => this._provideInlayHints(model, range)
@@ -134,7 +202,7 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
134
202
  diagnostics.push({
135
203
  severity: MarkerSeverity.Warning,
136
204
  message: ( localize(
137
- 11936,
205
+ 13691,
138
206
  "Variable `{0}` not found, did you mean ${{1}}?",
139
207
  name,
140
208
  getClosestMatchingVariable(name) + (arg ? `:${arg}` : "")
@@ -182,174 +250,197 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
182
250
  if (!collection) {
183
251
  return lensList;
184
252
  }
185
- const mcpServers = read(this._mcpService.servers).filter(s => s.collection.id === collection.id);
186
- for (const node of serversNode.children || []) {
187
- if (node.type !== "property" || node.children?.[0]?.type !== "string") {
188
- continue;
189
- }
190
- const name = node.children[0].value;
191
- const server = mcpServers.find(s => s.definition.label === name);
192
- if (!server) {
193
- continue;
194
- }
195
- const range = Range.fromPositions(model.getPositionAt(node.children[0].offset));
196
- if (isContributionDisabled(read(server.enablement))) {
197
- lenses.push({
198
- range,
199
- command: {
200
- id: McpCommandIds.ServerOptions,
201
- title: "$(circle-slash) " + ( localize(11937, "Disabled")),
202
- arguments: [server.definition.id]
203
- }
204
- });
205
- continue;
253
+ const agentHostSession = getActiveAgentHostMcpSessionResource(this._chatWidgetService.lastFocusedWidget?.viewModel?.sessionResource);
254
+ if (agentHostSession) {
255
+ const mcpServers = this._agentHostCustomizationService.getMcpServers(agentHostSession);
256
+ const otherRunningCounts = this._getOtherRunningAgentHostMcpServerCounts(agentHostSession);
257
+ for (const node of serversNode.children || []) {
258
+ if (node.type !== "property" || node.children?.[0]?.type !== "string") {
259
+ continue;
260
+ }
261
+ const name = node.children[0].value;
262
+ const server = mcpServers.find(s => s.name === name);
263
+ if (!server) {
264
+ continue;
265
+ }
266
+ this._addAgentHostServerCodeLenses(
267
+ lenses,
268
+ Range.fromPositions(model.getPositionAt(node.children[0].offset)),
269
+ agentHostSession,
270
+ server,
271
+ otherRunningCounts.get(name) ?? 0
272
+ );
206
273
  }
207
- const canDebug = !!server.readDefinitions().get().server?.devMode?.debug;
208
- const state = read(server.connectionState).state;
209
- switch (state) {
210
- case McpConnectionState.Kind.Error:
211
- lenses.push({
212
- range,
213
- command: {
214
- id: McpCommandIds.ShowOutput,
215
- title: "$(error) " + ( localize(11938, "Error")),
216
- arguments: [server.definition.id]
217
- }
218
- }, {
219
- range,
220
- command: {
221
- id: McpCommandIds.RestartServer,
222
- title: ( localize(11939, "Restart")),
223
- arguments: [server.definition.id, {
224
- autoTrustChanges: true
225
- }]
226
- }
227
- });
228
- if (canDebug) {
274
+ } else {
275
+ const mcpServers = read(this._mcpService.servers).filter(s => s.collection.id === collection.id);
276
+ for (const node of serversNode.children || []) {
277
+ if (node.type !== "property" || node.children?.[0]?.type !== "string") {
278
+ continue;
279
+ }
280
+ const name = node.children[0].value;
281
+ const server = mcpServers.find(s => s.definition.label === name);
282
+ if (!server) {
283
+ continue;
284
+ }
285
+ const range = Range.fromPositions(model.getPositionAt(node.children[0].offset));
286
+ if (isContributionDisabled(read(server.enablement))) {
229
287
  lenses.push({
230
288
  range,
231
289
  command: {
232
- id: McpCommandIds.RestartServer,
233
- title: ( localize(11940, "Debug")),
234
- arguments: [server.definition.id, {
235
- debug: true,
236
- autoTrustChanges: true
237
- }]
290
+ id: McpCommandIds.ServerOptions,
291
+ title: "$(circle-slash) " + ( localize(13692, "Disabled")),
292
+ arguments: [server.definition.id]
238
293
  }
239
294
  });
295
+ continue;
240
296
  }
241
- break;
242
- case McpConnectionState.Kind.Starting:
243
- lenses.push({
244
- range,
245
- command: {
246
- id: McpCommandIds.ShowOutput,
247
- title: "$(loading~spin) " + ( localize(11941, "Starting")),
248
- arguments: [server.definition.id]
249
- }
250
- }, {
251
- range,
252
- command: {
253
- id: McpCommandIds.StopServer,
254
- title: ( localize(11942, "Cancel")),
255
- arguments: [server.definition.id]
256
- }
257
- });
258
- break;
259
- case McpConnectionState.Kind.Running:
260
- lenses.push({
261
- range,
262
- command: {
263
- id: McpCommandIds.ShowOutput,
264
- title: "$(check) " + ( localize(11943, "Running")),
265
- arguments: [server.definition.id]
266
- }
267
- }, {
268
- range,
269
- command: {
270
- id: McpCommandIds.StopServer,
271
- title: ( localize(11944, "Stop")),
272
- arguments: [server.definition.id]
273
- }
274
- }, {
275
- range,
276
- command: {
277
- id: McpCommandIds.RestartServer,
278
- title: ( localize(11939, "Restart")),
279
- arguments: [server.definition.id, {
280
- autoTrustChanges: true
281
- }]
282
- }
283
- });
284
- if (canDebug) {
297
+ const canDebug = !!server.readDefinitions().get().server?.devMode?.debug;
298
+ const state = read(server.connectionState).state;
299
+ switch (state) {
300
+ case McpConnectionState.Kind.Error:
285
301
  lenses.push({
302
+ range,
303
+ command: {
304
+ id: McpCommandIds.ShowOutput,
305
+ title: "$(error) " + ( localize(13693, "Error")),
306
+ arguments: [server.definition.id]
307
+ }
308
+ }, {
286
309
  range,
287
310
  command: {
288
311
  id: McpCommandIds.RestartServer,
289
- title: ( localize(11940, "Debug")),
312
+ title: ( localize(13694, "Restart")),
290
313
  arguments: [server.definition.id, {
291
- autoTrustChanges: true,
292
- debug: true
314
+ autoTrustChanges: true
293
315
  }]
294
316
  }
295
317
  });
296
- }
297
- break;
298
- case McpConnectionState.Kind.Stopped:
299
- lenses.push({
300
- range,
301
- command: {
302
- id: McpCommandIds.StartServer,
303
- title: "$(debug-start) " + ( localize(11945, "Start")),
304
- arguments: [server.definition.id, {
305
- autoTrustChanges: true
306
- }]
318
+ if (canDebug) {
319
+ lenses.push({
320
+ range,
321
+ command: {
322
+ id: McpCommandIds.RestartServer,
323
+ title: ( localize(13695, "Debug")),
324
+ arguments: [server.definition.id, {
325
+ debug: true,
326
+ autoTrustChanges: true
327
+ }]
328
+ }
329
+ });
307
330
  }
308
- });
309
- if (canDebug) {
331
+ break;
332
+ case McpConnectionState.Kind.Starting:
310
333
  lenses.push({
311
334
  range,
312
335
  command: {
313
- id: McpCommandIds.StartServer,
314
- title: ( localize(11940, "Debug")),
336
+ id: McpCommandIds.ShowOutput,
337
+ title: "$(loading~spin) " + ( localize(13696, "Starting")),
338
+ arguments: [server.definition.id]
339
+ }
340
+ }, {
341
+ range,
342
+ command: {
343
+ id: McpCommandIds.StopServer,
344
+ title: ( localize(13697, "Cancel")),
345
+ arguments: [server.definition.id]
346
+ }
347
+ });
348
+ break;
349
+ case McpConnectionState.Kind.Running:
350
+ lenses.push({
351
+ range,
352
+ command: {
353
+ id: McpCommandIds.ShowOutput,
354
+ title: "$(check) " + ( localize(13698, "Running")),
355
+ arguments: [server.definition.id]
356
+ }
357
+ }, {
358
+ range,
359
+ command: {
360
+ id: McpCommandIds.StopServer,
361
+ title: ( localize(13699, "Stop")),
362
+ arguments: [server.definition.id]
363
+ }
364
+ }, {
365
+ range,
366
+ command: {
367
+ id: McpCommandIds.RestartServer,
368
+ title: ( localize(13694, "Restart")),
315
369
  arguments: [server.definition.id, {
316
- autoTrustChanges: true,
317
- debug: true
370
+ autoTrustChanges: true
318
371
  }]
319
372
  }
320
373
  });
321
- }
322
- }
323
- if (state !== McpConnectionState.Kind.Error) {
324
- const toolCount = read(server.tools).length;
325
- if (toolCount) {
374
+ if (canDebug) {
375
+ lenses.push({
376
+ range,
377
+ command: {
378
+ id: McpCommandIds.RestartServer,
379
+ title: ( localize(13695, "Debug")),
380
+ arguments: [server.definition.id, {
381
+ autoTrustChanges: true,
382
+ debug: true
383
+ }]
384
+ }
385
+ });
386
+ }
387
+ break;
388
+ case McpConnectionState.Kind.Stopped:
326
389
  lenses.push({
327
390
  range,
328
391
  command: {
329
- id: "",
330
- title: ( localize(11946, "{0} tools", toolCount))
392
+ id: McpCommandIds.StartServer,
393
+ title: "$(debug-start) " + ( localize(13700, "Start")),
394
+ arguments: [server.definition.id, {
395
+ autoTrustChanges: true
396
+ }]
331
397
  }
332
398
  });
399
+ if (canDebug) {
400
+ lenses.push({
401
+ range,
402
+ command: {
403
+ id: McpCommandIds.StartServer,
404
+ title: ( localize(13695, "Debug")),
405
+ arguments: [server.definition.id, {
406
+ autoTrustChanges: true,
407
+ debug: true
408
+ }]
409
+ }
410
+ });
411
+ }
333
412
  }
334
- const promptCount = read(server.prompts).length;
335
- if (promptCount) {
413
+ if (state !== McpConnectionState.Kind.Error) {
414
+ const toolCount = read(server.tools).length;
415
+ if (toolCount) {
416
+ lenses.push({
417
+ range,
418
+ command: {
419
+ id: "",
420
+ title: ( localize(13701, "{0} tools", toolCount))
421
+ }
422
+ });
423
+ }
424
+ const promptCount = read(server.prompts).length;
425
+ if (promptCount) {
426
+ lenses.push({
427
+ range,
428
+ command: {
429
+ id: McpCommandIds.StartPromptForServer,
430
+ title: ( localize(13702, "{0} prompts", promptCount)),
431
+ arguments: [server]
432
+ }
433
+ });
434
+ }
336
435
  lenses.push({
337
436
  range,
338
437
  command: {
339
- id: McpCommandIds.StartPromptForServer,
340
- title: ( localize(11947, "{0} prompts", promptCount)),
341
- arguments: [server]
438
+ id: McpCommandIds.ServerOptions,
439
+ title: ( localize(13703, "More...")),
440
+ arguments: [server.definition.id]
342
441
  }
343
442
  });
344
443
  }
345
- lenses.push({
346
- range,
347
- command: {
348
- id: McpCommandIds.ServerOptions,
349
- title: ( localize(11948, "More...")),
350
- arguments: [server.definition.id]
351
- }
352
- });
353
444
  }
354
445
  }
355
446
  const candidates = [];
@@ -394,7 +485,7 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
394
485
  clientIdOffset
395
486
  } = candidates[i];
396
487
  const existing = existingSecrets[i];
397
- const title = existing ? ( localize(11949, "Replace Client Secret")) : ( localize(11950, "Set Client Secret"));
488
+ const title = existing ? ( localize(13704, "Replace Client Secret")) : ( localize(13705, "Set Client Secret"));
398
489
  lenses.push({
399
490
  range: Range.fromPositions(model.getPositionAt(clientIdOffset)),
400
491
  command: {
@@ -406,6 +497,179 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
406
497
  }
407
498
  return lensList;
408
499
  }
500
+ _addAgentHostServerCodeLenses(lenses, range, agentHostSession, server, otherRunningSessionCount) {
501
+ const commandArg = {
502
+ agentHostSession,
503
+ serverId: server.id
504
+ };
505
+ if (!server.enabled) {
506
+ lenses.push({
507
+ range,
508
+ command: {
509
+ id: McpCommandIds.AgentHostServerOptions,
510
+ title: "$(circle-slash) " + ( localize(13692, "Disabled")),
511
+ arguments: [agentHostSession, server.id]
512
+ }
513
+ });
514
+ return;
515
+ }
516
+ switch (server.status) {
517
+ case McpServerStatus.Error:
518
+ lenses.push({
519
+ range,
520
+ command: {
521
+ id: McpCommandIds.AgentHostServerOptions,
522
+ title: "$(error) " + ( localize(13693, "Error")),
523
+ arguments: [agentHostSession, server.id]
524
+ }
525
+ });
526
+ lenses.push({
527
+ range,
528
+ command: {
529
+ id: McpCommandIds.StartServer,
530
+ title: ( localize(13700, "Start")),
531
+ arguments: [commandArg]
532
+ }
533
+ });
534
+ break;
535
+ case McpServerStatus.Starting:
536
+ lenses.push({
537
+ range,
538
+ command: {
539
+ id: McpCommandIds.AgentHostServerOptions,
540
+ title: "$(loading~spin) " + ( localize(13696, "Starting")),
541
+ arguments: [agentHostSession, server.id]
542
+ }
543
+ });
544
+ lenses.push({
545
+ range,
546
+ command: {
547
+ id: McpCommandIds.StopServer,
548
+ title: ( localize(13697, "Cancel")),
549
+ arguments: [commandArg]
550
+ }
551
+ });
552
+ break;
553
+ case McpServerStatus.Ready:
554
+ lenses.push({
555
+ range,
556
+ command: {
557
+ id: McpCommandIds.AgentHostServerOptions,
558
+ title: "$(check) " + ( localize(13698, "Running")),
559
+ arguments: [agentHostSession, server.id]
560
+ }
561
+ });
562
+ lenses.push({
563
+ range,
564
+ command: {
565
+ id: McpCommandIds.StopServer,
566
+ title: ( localize(13699, "Stop")),
567
+ arguments: [commandArg]
568
+ }
569
+ });
570
+ break;
571
+ case McpServerStatus.AuthRequired:
572
+ lenses.push({
573
+ range,
574
+ command: {
575
+ id: McpCommandIds.AgentHostServerOptions,
576
+ title: "$(account) " + ( localize(13706, "Authentication Required")),
577
+ arguments: [agentHostSession, server.id]
578
+ }
579
+ });
580
+ lenses.push({
581
+ range,
582
+ command: {
583
+ id: McpCommandIds.StopServer,
584
+ title: ( localize(13699, "Stop")),
585
+ arguments: [commandArg]
586
+ }
587
+ });
588
+ break;
589
+ case McpServerStatus.Stopped:
590
+ lenses.push({
591
+ range,
592
+ command: {
593
+ id: McpCommandIds.StartServer,
594
+ title: "$(debug-start) " + ( localize(13700, "Start")),
595
+ arguments: [commandArg]
596
+ }
597
+ });
598
+ break;
599
+ }
600
+ if (otherRunningSessionCount > 0) {
601
+ lenses.push({
602
+ range,
603
+ command: {
604
+ id: "",
605
+ title: otherRunningSessionCount === 1 ? ( localize(13707, "(Running in 1 session)")) : ( localize(13708, "(Running in {0} sessions)", otherRunningSessionCount))
606
+ }
607
+ });
608
+ }
609
+ if (server.status !== McpServerStatus.Error) {
610
+ lenses.push({
611
+ range,
612
+ command: {
613
+ id: McpCommandIds.AgentHostServerOptions,
614
+ title: ( localize(13703, "More...")),
615
+ arguments: [agentHostSession, server.id]
616
+ }
617
+ });
618
+ }
619
+ }
620
+ _getOtherRunningAgentHostMcpServerCounts(agentHostSession) {
621
+ const sessionServers = [];
622
+ for (const connectionInfo of this._agentHostConnectionsService.connections) {
623
+ const connection = connectionInfo.connection;
624
+ if (!connection) {
625
+ continue;
626
+ }
627
+ for (const subscription of connection.getActiveSubscriptions()) {
628
+ if (subscription.kind !== StateComponents.Session) {
629
+ continue;
630
+ }
631
+ const state = connection.getSubscriptionUnmanaged(StateComponents.Session, subscription.resource)?.value;
632
+ const resource = this._toAgentHostSessionResource(connectionInfo, subscription.resource);
633
+ if (!resource || !state || state instanceof Error) {
634
+ continue;
635
+ }
636
+ sessionServers.push({
637
+ resource,
638
+ servers: this._getMcpServersFromSessionState(state)
639
+ });
640
+ }
641
+ }
642
+ return countRunningMcpServersInOtherSessions(agentHostSession, sessionServers);
643
+ }
644
+ _toAgentHostSessionResource(connectionInfo, backendSession) {
645
+ const provider = AgentSession.provider(backendSession);
646
+ if (!provider) {
647
+ return undefined;
648
+ }
649
+ const scheme = connectionInfo.isAmbient ? `${LOCAL_AGENT_HOST_SCHEME_PREFIX}${provider}` : remoteAgentHostSessionTypeId(connectionInfo.authority, provider);
650
+ return ( URI.from({
651
+ scheme,
652
+ path: backendSession.path
653
+ }));
654
+ }
655
+ _getMcpServersFromSessionState(state) {
656
+ const servers = [];
657
+ const collect = customizations => {
658
+ for (const customization of customizations ?? []) {
659
+ if (customization.type === CustomizationType.McpServer) {
660
+ servers.push({
661
+ name: customization.name,
662
+ enabled: isCustomizationEnabled(customization),
663
+ status: customization.state.kind
664
+ });
665
+ } else if (customization.type === CustomizationType.Directory || customization.type === CustomizationType.Plugin) {
666
+ collect(customization.children);
667
+ }
668
+ }
669
+ };
670
+ collect(state.customizations);
671
+ return servers;
672
+ }
409
673
  async _provideInlayHints(model, range) {
410
674
  const parsed = await this._parseModel(model);
411
675
  if (!parsed) {
@@ -473,19 +737,19 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
473
737
  function pushAnnotation(savedId, offset, saved) {
474
738
  const tooltip = ( new MarkdownString([createMarkdownCommandLink({
475
739
  id: McpCommandIds.EditStoredInput,
476
- text: ( localize(11951, "Edit")),
740
+ text: ( localize(13709, "Edit")),
477
741
  arguments: [savedId, model.uri, mcpConfigurationSection, inConfig.target],
478
- tooltip: ( localize(11952, "Edit saved value"))
742
+ tooltip: ( localize(13710, "Edit saved value"))
479
743
  }), createMarkdownCommandLink({
480
744
  id: McpCommandIds.RemoveStoredInput,
481
- text: ( localize(11953, "Clear")),
745
+ text: ( localize(13711, "Clear")),
482
746
  arguments: [inConfig.scope, savedId],
483
- tooltip: ( localize(11954, "Clear saved value"))
747
+ tooltip: ( localize(13712, "Clear saved value"))
484
748
  }), createMarkdownCommandLink({
485
749
  id: McpCommandIds.RemoveStoredInput,
486
- text: ( localize(11955, "Clear All")),
750
+ text: ( localize(13713, "Clear All")),
487
751
  arguments: [inConfig.scope],
488
- tooltip: ( localize(11956, "Clear all saved values"))
752
+ tooltip: ( localize(13714, "Clear all saved values"))
489
753
  })].join(" | "), {
490
754
  isTrusted: true
491
755
  }));
@@ -500,7 +764,7 @@ let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
500
764
  }
501
765
  }
502
766
  };
503
- McpLanguageFeatures = ( __decorate([( __param(0, ILanguageFeaturesService)), ( __param(1, IMcpRegistry)), ( __param(2, IMcpWorkbenchService)), ( __param(3, IMcpService)), ( __param(4, IMarkerService)), ( __param(5, IConfigurationResolverService)), ( __param(6, ISecretStorageService))], McpLanguageFeatures));
767
+ McpLanguageFeatures = ( __decorate([( __param(0, ILanguageFeaturesService)), ( __param(1, IMcpRegistry)), ( __param(2, IMcpWorkbenchService)), ( __param(3, IMcpService)), ( __param(4, IChatWidgetService)), ( __param(5, IAgentHostCustomizationService)), ( __param(6, IAgentHostConnectionsService)), ( __param(7, IMarkerService)), ( __param(8, IConfigurationResolverService)), ( __param(9, ISecretStorageService))], McpLanguageFeatures));
504
768
  function forEachPropertyWithReplacement(node, callback) {
505
769
  if (node.type === "string" && typeof node.value === "string" && node.value.includes(ConfigurationResolverExpression.VARIABLE_LHS)) {
506
770
  callback(node);