@codingame/monaco-vscode-mcp-service-override 36.2.7 → 37.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/package.json +2 -2
- package/vscode/src/vs/base/common/jsonRpcProtocol.d.ts +2 -2
- package/vscode/src/vs/platform/mcp/common/allowedMcpServers.d.ts +52 -0
- package/vscode/src/vs/platform/mcp/common/allowedMcpServers.js +180 -0
- package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.d.ts +4 -0
- package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +68 -12
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.d.ts +5 -1
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +200 -92
- package/vscode/src/vs/platform/mcp/common/mcpResourceScannerService.js +3 -2
- package/vscode/src/vs/platform/mcp/common/nativeMcpDiscoveryHelper.d.ts +1 -0
- 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.d.ts +10 -3
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +357 -121
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +25 -25
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.d.ts +11 -1
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +409 -145
- 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/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.js +5 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +18 -18
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +279 -72
- package/vscode/src/vs/workbench/contrib/mcp/browser/media/mcpServersView.css +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +6 -5
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/installedMcpServersDiscovery.js +9 -16
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.d.ts +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +7 -3
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.d.ts +14 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.js +32 -9
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceDotMcpDiscovery.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceDotMcpDiscovery.js +20 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.js +9 -5
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpEditorAffordanceState.d.ts +13 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpEditorAffordanceState.js +36 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +6 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +51 -19
- 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 +4 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.js +42 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +3 -3
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +6 -3
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +9 -9
package/vscode/src/vs/workbench/contrib/mcp/common/discovery/installedMcpServersDiscovery.js
CHANGED
|
@@ -5,7 +5,6 @@ import { Throttler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/as
|
|
|
5
5
|
import { Disposable, DisposableMap, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
6
|
import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
7
7
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
8
|
-
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
9
8
|
import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
|
|
10
9
|
import { ConfigurationTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
|
|
11
10
|
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
@@ -13,7 +12,7 @@ import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/st
|
|
|
13
12
|
import { getMcpServerMapping } from '../mcpConfigFileUtils.js';
|
|
14
13
|
import { mcpConfigurationSection } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
15
14
|
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
16
|
-
import { MCP_CONFIGURATION_COLLECTION_ID_PREFIX,
|
|
15
|
+
import { MCP_CONFIGURATION_COLLECTION_ID_PREFIX, McpServerLaunch, McpServerTrust, McpCollectionSortOrder, getMcpCollectionProvenance, McpCollectionDefinition, McpServerDefinition } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
17
16
|
import { IMcpWorkbenchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
|
|
18
17
|
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
19
18
|
|
|
@@ -78,25 +77,18 @@ let InstalledMcpServersDiscovery = class InstalledMcpServersDiscovery extends Di
|
|
|
78
77
|
definitions = [mcpConfigPath, []];
|
|
79
78
|
collections.set(collectionId, definitions);
|
|
80
79
|
}
|
|
81
|
-
const launch = config.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
type: McpServerTransportType.Stdio,
|
|
88
|
-
command: config.command,
|
|
89
|
-
args: config.args || [],
|
|
90
|
-
env: config.env || {},
|
|
91
|
-
envFile: config.envFile,
|
|
92
|
-
cwd: config.cwd,
|
|
93
|
-
sandbox: server.rootSandbox
|
|
94
|
-
};
|
|
80
|
+
const launch = McpServerLaunch.fromServerConfiguration(config, server.rootSandbox);
|
|
81
|
+
if (!launch) {
|
|
82
|
+
this.logService.warn(`Skipping invalid MCP server configuration: ${server.name}`);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const defaultCwd = config.type === "http" ? undefined : mcpConfigPath?.workspaceFolder?.uri;
|
|
95
86
|
definitions[1].push({
|
|
96
87
|
id: `${collectionId}.${server.name}`,
|
|
97
88
|
label: server.name,
|
|
98
89
|
launch,
|
|
99
90
|
sandboxEnabled: config.type === "http" ? undefined : config.sandboxEnabled,
|
|
91
|
+
defaultCwd,
|
|
100
92
|
cacheNonce: await McpServerLaunch.hash(launch),
|
|
101
93
|
roots: mcpConfigPath?.workspaceFolder ? [mcpConfigPath.workspaceFolder.uri] : undefined,
|
|
102
94
|
variableReplacement: {
|
|
@@ -120,6 +112,7 @@ let InstalledMcpServersDiscovery = class InstalledMcpServersDiscovery extends Di
|
|
|
120
112
|
const newServerDefinitions = observableValue(this, serverDefinitions);
|
|
121
113
|
const newCollection = {
|
|
122
114
|
id,
|
|
115
|
+
provenance: getMcpCollectionProvenance(mcpConfigPath?.target),
|
|
123
116
|
label: mcpConfigPath?.label ?? "",
|
|
124
117
|
order: mcpConfigPath?.order ?? McpCollectionSortOrder.User,
|
|
125
118
|
presentation: {
|
package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/pl
|
|
|
8
8
|
import { ILabelService } from "@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service";
|
|
9
9
|
import { INativeMcpDiscoveryData } from "../../../../../platform/mcp/common/nativeMcpDiscoveryHelper.js";
|
|
10
10
|
import { Dto } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/proxyIdentifier";
|
|
11
|
-
import {
|
|
11
|
+
import { ExternalDiscoverySource } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration";
|
|
12
12
|
import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
|
|
13
13
|
import { McpCollectionDefinition, McpServerDefinition } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
|
|
14
14
|
import { IMcpDiscovery } from "./mcpDiscovery.js";
|
|
@@ -20,11 +20,11 @@ export declare abstract class FilesystemMcpDiscovery extends Disposable implemen
|
|
|
20
20
|
private readonly _mcpRegistry;
|
|
21
21
|
readonly fromGallery: boolean;
|
|
22
22
|
protected readonly _fsDiscoveryEnabled: IObservable<{
|
|
23
|
-
[K in
|
|
23
|
+
[K in ExternalDiscoverySource]: boolean;
|
|
24
24
|
} | undefined>;
|
|
25
25
|
constructor(configurationService: IConfigurationService, _fileService: IFileService, _mcpRegistry: IMcpRegistry);
|
|
26
|
-
protected _isDiscoveryEnabled(reader: IReader, discoverySource:
|
|
27
|
-
protected watchFile(file: URI, collection: WritableMcpCollectionDefinition, discoverySource:
|
|
26
|
+
protected _isDiscoveryEnabled(reader: IReader, discoverySource: ExternalDiscoverySource): boolean;
|
|
27
|
+
protected watchFile(file: URI, collection: WritableMcpCollectionDefinition, discoverySource: ExternalDiscoverySource, adaptFile: (contents: VSBuffer) => Promise<McpServerDefinition[] | undefined>): IDisposable;
|
|
28
28
|
abstract start(): void;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -15,8 +15,8 @@ import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/pl
|
|
|
15
15
|
import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
16
16
|
import { mcpDiscoverySection, discoverySourceLabel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
17
17
|
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
18
|
-
import { McpCollectionSortOrder, McpServerTrust } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
19
|
-
import { ClaudeDesktopMpcDiscoveryAdapter, CursorDesktopMpcDiscoveryAdapter, WindsurfDesktopMpcDiscoveryAdapter } from './nativeMcpDiscoveryAdapters.js';
|
|
18
|
+
import { McpCollectionSortOrder, McpServerTrust, McpCollectionProvenance } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
19
|
+
import { ClaudeDesktopMpcDiscoveryAdapter, CopilotMpcDiscoveryAdapter, CursorDesktopMpcDiscoveryAdapter, WindsurfDesktopMpcDiscoveryAdapter } from './nativeMcpDiscoveryAdapters.js';
|
|
20
20
|
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
21
21
|
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
22
22
|
|
|
@@ -86,13 +86,14 @@ let NativeFilesystemMcpDiscovery = class NativeFilesystemMcpDiscovery extends Fi
|
|
|
86
86
|
this.suffix = "";
|
|
87
87
|
if (remoteAuthority) {
|
|
88
88
|
this.suffix = " " + ( localize(
|
|
89
|
-
|
|
89
|
+
14064,
|
|
90
90
|
" on {0}",
|
|
91
91
|
labelService.getHostLabel(Schemas.vscodeRemote, remoteAuthority)
|
|
92
92
|
));
|
|
93
93
|
}
|
|
94
94
|
this.adapters = [
|
|
95
95
|
instantiationService.createInstance(ClaudeDesktopMpcDiscoveryAdapter, remoteAuthority),
|
|
96
|
+
instantiationService.createInstance(CopilotMpcDiscoveryAdapter, remoteAuthority),
|
|
96
97
|
instantiationService.createInstance(CursorDesktopMpcDiscoveryAdapter, remoteAuthority),
|
|
97
98
|
instantiationService.createInstance(WindsurfDesktopMpcDiscoveryAdapter, remoteAuthority)
|
|
98
99
|
];
|
|
@@ -104,6 +105,7 @@ let NativeFilesystemMcpDiscovery = class NativeFilesystemMcpDiscovery extends Fi
|
|
|
104
105
|
const details = {
|
|
105
106
|
...detailsDto,
|
|
106
107
|
homedir: URI.revive(detailsDto.homedir),
|
|
108
|
+
copilotHome: detailsDto.copilotHome ? URI.revive(detailsDto.copilotHome) : undefined,
|
|
107
109
|
xdgHome: detailsDto.xdgHome ? URI.revive(detailsDto.xdgHome) : undefined,
|
|
108
110
|
winAppData: detailsDto.winAppData ? URI.revive(detailsDto.winAppData) : undefined
|
|
109
111
|
};
|
|
@@ -114,6 +116,8 @@ let NativeFilesystemMcpDiscovery = class NativeFilesystemMcpDiscovery extends Fi
|
|
|
114
116
|
}
|
|
115
117
|
const collection = {
|
|
116
118
|
id: adapter.id,
|
|
119
|
+
provenance: McpCollectionProvenance.ExternalConfiguration,
|
|
120
|
+
discoverySource: adapter.discoverySource,
|
|
117
121
|
label: discoverySourceLabel[adapter.discoverySource] + this.suffix,
|
|
118
122
|
remoteAuthority: adapter.remoteAuthority,
|
|
119
123
|
configTarget: ConfigurationTarget.USER,
|
package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.d.ts
CHANGED
|
@@ -2,33 +2,41 @@ import { VSBuffer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buf
|
|
|
2
2
|
import { Mutable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/types";
|
|
3
3
|
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
4
4
|
import { INativeMcpDiscoveryData } from "../../../../../platform/mcp/common/nativeMcpDiscoveryHelper.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ExternalDiscoverySource } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration";
|
|
6
6
|
import { McpCollectionSortOrder, McpServerDefinition } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
|
|
7
7
|
export interface NativeMpcDiscoveryAdapter {
|
|
8
8
|
readonly remoteAuthority: string | null;
|
|
9
9
|
readonly id: string;
|
|
10
10
|
readonly order: number;
|
|
11
|
-
readonly discoverySource:
|
|
11
|
+
readonly discoverySource: ExternalDiscoverySource;
|
|
12
12
|
getFilePath(details: INativeMcpDiscoveryData): URI | undefined;
|
|
13
13
|
adaptFile(contents: VSBuffer, details: INativeMcpDiscoveryData): Promise<McpServerDefinition[] | undefined>;
|
|
14
14
|
}
|
|
15
|
-
export declare function claudeConfigToServerDefinition(idPrefix: string, contents: VSBuffer,
|
|
15
|
+
export declare function claudeConfigToServerDefinition(idPrefix: string, contents: VSBuffer, options?: {
|
|
16
|
+
cwd?: URI;
|
|
17
|
+
defaultCwd?: URI;
|
|
18
|
+
}): Promise<Mutable<McpServerDefinition>[] | undefined>;
|
|
16
19
|
export declare class ClaudeDesktopMpcDiscoveryAdapter implements NativeMpcDiscoveryAdapter {
|
|
17
20
|
readonly remoteAuthority: string | null;
|
|
18
21
|
id: string;
|
|
19
22
|
readonly order = McpCollectionSortOrder.Filesystem;
|
|
20
|
-
readonly discoverySource:
|
|
23
|
+
readonly discoverySource: ExternalDiscoverySource;
|
|
21
24
|
constructor(remoteAuthority: string | null);
|
|
22
25
|
getFilePath({ platform, winAppData, xdgHome, homedir }: INativeMcpDiscoveryData): URI | undefined;
|
|
23
26
|
adaptFile(contents: VSBuffer, { homedir }: INativeMcpDiscoveryData): Promise<McpServerDefinition[] | undefined>;
|
|
24
27
|
}
|
|
28
|
+
export declare class CopilotMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
|
|
29
|
+
readonly discoverySource: ExternalDiscoverySource;
|
|
30
|
+
constructor(remoteAuthority: string | null);
|
|
31
|
+
getFilePath({ copilotHome, homedir }: INativeMcpDiscoveryData): URI | undefined;
|
|
32
|
+
}
|
|
25
33
|
export declare class WindsurfDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
|
|
26
|
-
readonly discoverySource:
|
|
34
|
+
readonly discoverySource: ExternalDiscoverySource;
|
|
27
35
|
constructor(remoteAuthority: string | null);
|
|
28
36
|
getFilePath({ homedir }: INativeMcpDiscoveryData): URI | undefined;
|
|
29
37
|
}
|
|
30
38
|
export declare class CursorDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
|
|
31
|
-
readonly discoverySource:
|
|
39
|
+
readonly discoverySource: ExternalDiscoverySource;
|
|
32
40
|
constructor(remoteAuthority: string | null);
|
|
33
41
|
getFilePath({ homedir }: INativeMcpDiscoveryData): URI | undefined;
|
|
34
42
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { Platform } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
3
3
|
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
4
|
-
import {
|
|
4
|
+
import { ExternalDiscoverySource } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
5
5
|
import { McpServerTransportType, McpServerLaunch, McpCollectionSortOrder } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
6
6
|
|
|
7
|
-
async function claudeConfigToServerDefinition(idPrefix, contents,
|
|
7
|
+
async function claudeConfigToServerDefinition(idPrefix, contents, options) {
|
|
8
8
|
let parsed;
|
|
9
9
|
try {
|
|
10
10
|
parsed = JSON.parse(( contents.toString()));
|
|
@@ -22,14 +22,20 @@ async function claudeConfigToServerDefinition(idPrefix, contents, cwd) {
|
|
|
22
22
|
command: server.command,
|
|
23
23
|
env: server.env || {},
|
|
24
24
|
envFile: undefined,
|
|
25
|
-
cwd: cwd?.fsPath,
|
|
25
|
+
cwd: options?.cwd?.fsPath,
|
|
26
26
|
sandbox: undefined
|
|
27
27
|
};
|
|
28
|
+
const defaultCwd = launch.type === McpServerTransportType.Stdio ? options?.defaultCwd : undefined;
|
|
29
|
+
const nonceLaunch = defaultCwd && launch.type === McpServerTransportType.Stdio ? {
|
|
30
|
+
...launch,
|
|
31
|
+
cwd: defaultCwd.fsPath
|
|
32
|
+
} : launch;
|
|
28
33
|
return {
|
|
29
34
|
id: `${idPrefix}.${name}`,
|
|
30
35
|
label: name,
|
|
31
36
|
launch,
|
|
32
|
-
|
|
37
|
+
defaultCwd,
|
|
38
|
+
cacheNonce: await McpServerLaunch.hash(nonceLaunch)
|
|
33
39
|
};
|
|
34
40
|
})));
|
|
35
41
|
}
|
|
@@ -37,7 +43,7 @@ class ClaudeDesktopMpcDiscoveryAdapter {
|
|
|
37
43
|
constructor(remoteAuthority) {
|
|
38
44
|
this.remoteAuthority = remoteAuthority;
|
|
39
45
|
this.order = McpCollectionSortOrder.Filesystem;
|
|
40
|
-
this.discoverySource =
|
|
46
|
+
this.discoverySource = ExternalDiscoverySource.ClaudeDesktop;
|
|
41
47
|
this.id = `claude-desktop.${this.remoteAuthority}`;
|
|
42
48
|
}
|
|
43
49
|
getFilePath(
|
|
@@ -70,13 +76,30 @@ class ClaudeDesktopMpcDiscoveryAdapter {
|
|
|
70
76
|
homedir
|
|
71
77
|
}
|
|
72
78
|
) {
|
|
73
|
-
return claudeConfigToServerDefinition(this.id, contents,
|
|
79
|
+
return claudeConfigToServerDefinition(this.id, contents, {
|
|
80
|
+
cwd: homedir
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
class CopilotMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
|
|
85
|
+
constructor(remoteAuthority) {
|
|
86
|
+
super(remoteAuthority);
|
|
87
|
+
this.discoverySource = ExternalDiscoverySource.Copilot;
|
|
88
|
+
this.id = `copilot.${this.remoteAuthority}`;
|
|
89
|
+
}
|
|
90
|
+
getFilePath(
|
|
91
|
+
{
|
|
92
|
+
copilotHome,
|
|
93
|
+
homedir
|
|
94
|
+
}
|
|
95
|
+
) {
|
|
96
|
+
return URI.joinPath(copilotHome ?? URI.joinPath(homedir, ".copilot"), "mcp-config.json");
|
|
74
97
|
}
|
|
75
98
|
}
|
|
76
99
|
class WindsurfDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
|
|
77
100
|
constructor(remoteAuthority) {
|
|
78
101
|
super(remoteAuthority);
|
|
79
|
-
this.discoverySource =
|
|
102
|
+
this.discoverySource = ExternalDiscoverySource.Windsurf;
|
|
80
103
|
this.id = `windsurf.${this.remoteAuthority}`;
|
|
81
104
|
}
|
|
82
105
|
getFilePath(
|
|
@@ -90,7 +113,7 @@ class WindsurfDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapte
|
|
|
90
113
|
class CursorDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
|
|
91
114
|
constructor(remoteAuthority) {
|
|
92
115
|
super(remoteAuthority);
|
|
93
|
-
this.discoverySource =
|
|
116
|
+
this.discoverySource = ExternalDiscoverySource.CursorGlobal;
|
|
94
117
|
this.id = `cursor.${this.remoteAuthority}`;
|
|
95
118
|
}
|
|
96
119
|
getFilePath(
|
|
@@ -102,4 +125,4 @@ class CursorDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter
|
|
|
102
125
|
}
|
|
103
126
|
}
|
|
104
127
|
|
|
105
|
-
export { ClaudeDesktopMpcDiscoveryAdapter, CursorDesktopMpcDiscoveryAdapter, WindsurfDesktopMpcDiscoveryAdapter, claudeConfigToServerDefinition };
|
|
128
|
+
export { ClaudeDesktopMpcDiscoveryAdapter, CopilotMpcDiscoveryAdapter, CursorDesktopMpcDiscoveryAdapter, WindsurfDesktopMpcDiscoveryAdapter, claudeConfigToServerDefinition };
|
|
@@ -5,8 +5,8 @@ import { IRemoteAgentService } from "@codingame/monaco-vscode-api/vscode/vs/work
|
|
|
5
5
|
import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
|
|
6
6
|
import { IMcpDiscovery } from "./mcpDiscovery.js";
|
|
7
7
|
/**
|
|
8
|
-
* Discovers
|
|
9
|
-
*
|
|
8
|
+
* Discovers workspace-root `.mcp.json` files using the Claude-style `{ "mcpServers": { ... } }` format.
|
|
9
|
+
* Servers inherit workspace trust, matching `.vscode/mcp.json`.
|
|
10
10
|
*/
|
|
11
11
|
export declare class WorkspaceDotMcpDiscovery extends Disposable implements IMcpDiscovery {
|
|
12
12
|
private readonly _fileService;
|
|
@@ -10,7 +10,7 @@ import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/st
|
|
|
10
10
|
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
11
11
|
import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
12
12
|
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
13
|
-
import { McpCollectionSortOrder, McpServerTrust } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
13
|
+
import { WORKSPACE_DOT_MCP_COLLECTION_ID_PREFIX, McpCollectionSortOrder, McpServerTrust, McpCollectionProvenance } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
14
14
|
import { claudeConfigToServerDefinition } from './nativeMcpDiscoveryAdapters.js';
|
|
15
15
|
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
16
16
|
|
|
@@ -39,14 +39,15 @@ let WorkspaceDotMcpDiscovery = class WorkspaceDotMcpDiscovery extends Disposable
|
|
|
39
39
|
}
|
|
40
40
|
_watchFolder(folder) {
|
|
41
41
|
const configFile = joinPath(folder.uri, ".mcp.json");
|
|
42
|
-
const collectionId =
|
|
42
|
+
const collectionId = `${WORKSPACE_DOT_MCP_COLLECTION_ID_PREFIX}${folder.index}`;
|
|
43
43
|
const serverDefinitions = observableValue(this, []);
|
|
44
44
|
const collection = {
|
|
45
45
|
id: collectionId,
|
|
46
|
+
provenance: McpCollectionProvenance.WorkspaceDotMcp,
|
|
46
47
|
label: `${folder.name}/.mcp.json`,
|
|
47
48
|
remoteAuthority: this._remoteAgentService.getConnection()?.remoteAuthority || null,
|
|
48
49
|
scope: StorageScope.WORKSPACE,
|
|
49
|
-
trustBehavior: McpServerTrust.Kind.
|
|
50
|
+
trustBehavior: McpServerTrust.Kind.Trusted,
|
|
50
51
|
serverDefinitions,
|
|
51
52
|
configTarget: ConfigurationTarget.WORKSPACE_FOLDER,
|
|
52
53
|
order: McpCollectionSortOrder.WorkspaceFolder + 1,
|
|
@@ -56,11 +57,14 @@ let WorkspaceDotMcpDiscovery = class WorkspaceDotMcpDiscovery extends Disposable
|
|
|
56
57
|
};
|
|
57
58
|
const store = ( new DisposableStore());
|
|
58
59
|
const collectionRegistration = store.add(( new MutableDisposable()));
|
|
60
|
+
let isLazyCollection = true;
|
|
59
61
|
const updateFile = async () => {
|
|
60
62
|
let definitions = [];
|
|
61
63
|
try {
|
|
62
64
|
const contents = await this._fileService.readFile(configFile);
|
|
63
|
-
const defs = await claudeConfigToServerDefinition(collectionId, contents.value,
|
|
65
|
+
const defs = await claudeConfigToServerDefinition(collectionId, contents.value, {
|
|
66
|
+
defaultCwd: folder.uri
|
|
67
|
+
});
|
|
64
68
|
if (defs) {
|
|
65
69
|
for (const d of defs) {
|
|
66
70
|
d.roots = [folder.uri];
|
|
@@ -72,7 +76,8 @@ let WorkspaceDotMcpDiscovery = class WorkspaceDotMcpDiscovery extends Disposable
|
|
|
72
76
|
collectionRegistration.clear();
|
|
73
77
|
} else {
|
|
74
78
|
serverDefinitions.set(definitions, undefined);
|
|
75
|
-
if (!collectionRegistration.value) {
|
|
79
|
+
if (isLazyCollection || !collectionRegistration.value) {
|
|
80
|
+
isLazyCollection = false;
|
|
76
81
|
collectionRegistration.value = this._mcpRegistry.registerCollection(collection);
|
|
77
82
|
}
|
|
78
83
|
}
|
|
@@ -83,7 +88,16 @@ let WorkspaceDotMcpDiscovery = class WorkspaceDotMcpDiscovery extends Disposable
|
|
|
83
88
|
excludes: []
|
|
84
89
|
}));
|
|
85
90
|
store.add(watcher.onDidChange(() => throttler.schedule()));
|
|
86
|
-
|
|
91
|
+
let initialUpdate;
|
|
92
|
+
const loadInitial = () => initialUpdate ??= updateFile();
|
|
93
|
+
collectionRegistration.value = this._mcpRegistry.registerCollection({
|
|
94
|
+
...collection,
|
|
95
|
+
lazy: {
|
|
96
|
+
isCached: false,
|
|
97
|
+
load: loadInitial
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
void loadInitial();
|
|
87
101
|
this._collections.set(( folder.uri.toString()), store);
|
|
88
102
|
}
|
|
89
103
|
};
|
package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.js
CHANGED
|
@@ -10,9 +10,9 @@ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/fi
|
|
|
10
10
|
import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
11
11
|
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
12
12
|
import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
13
|
-
import {
|
|
13
|
+
import { ExternalDiscoverySource } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
14
14
|
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
15
|
-
import { McpCollectionSortOrder, McpServerTrust } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
15
|
+
import { McpCollectionSortOrder, McpServerTrust, McpCollectionProvenance, CURSOR_WORKSPACE_MCP_COLLECTION_ID_PREFIX } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
16
16
|
import { FilesystemMcpDiscovery } from './nativeMcpDiscoveryAbstract.js';
|
|
17
17
|
import { claudeConfigToServerDefinition } from './nativeMcpDiscoveryAdapters.js';
|
|
18
18
|
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
@@ -46,7 +46,9 @@ let CursorWorkspaceMcpDiscoveryAdapter = class CursorWorkspaceMcpDiscoveryAdapte
|
|
|
46
46
|
watchFolder(folder) {
|
|
47
47
|
const configFile = joinPath(folder.uri, ".cursor", "mcp.json");
|
|
48
48
|
const collection = {
|
|
49
|
-
id:
|
|
49
|
+
id: `${CURSOR_WORKSPACE_MCP_COLLECTION_ID_PREFIX}${folder.index}`,
|
|
50
|
+
provenance: McpCollectionProvenance.ExternalConfiguration,
|
|
51
|
+
discoverySource: ExternalDiscoverySource.CursorWorkspace,
|
|
50
52
|
label: `${folder.name}/.cursor/mcp.json`,
|
|
51
53
|
remoteAuthority: this._remoteAgentService.getConnection()?.remoteAuthority || null,
|
|
52
54
|
scope: StorageScope.WORKSPACE,
|
|
@@ -61,9 +63,11 @@ let CursorWorkspaceMcpDiscoveryAdapter = class CursorWorkspaceMcpDiscoveryAdapte
|
|
|
61
63
|
this._collections.set(( folder.uri.toString()), this.watchFile(
|
|
62
64
|
URI.joinPath(folder.uri, ".cursor", "mcp.json"),
|
|
63
65
|
collection,
|
|
64
|
-
|
|
66
|
+
ExternalDiscoverySource.CursorWorkspace,
|
|
65
67
|
async contents => {
|
|
66
|
-
const defs = await claudeConfigToServerDefinition(collection.id, contents,
|
|
68
|
+
const defs = await claudeConfigToServerDefinition(collection.id, contents, {
|
|
69
|
+
defaultCwd: folder.uri
|
|
70
|
+
});
|
|
67
71
|
defs?.forEach(d => d.roots = [folder.uri]);
|
|
68
72
|
return defs;
|
|
69
73
|
}
|
|
@@ -14,19 +14,19 @@ var McpContextKeys;
|
|
|
14
14
|
(function(McpContextKeys) {
|
|
15
15
|
McpContextKeys.serverCount = ( new RawContextKey("mcp.serverCount", undefined, {
|
|
16
16
|
type: "number",
|
|
17
|
-
description: ( localize(
|
|
17
|
+
description: ( localize(14110, "Context key that has the number of registered MCP servers"))
|
|
18
18
|
}));
|
|
19
19
|
McpContextKeys.hasUnknownTools = ( new RawContextKey("mcp.hasUnknownTools", undefined, {
|
|
20
20
|
type: "boolean",
|
|
21
|
-
description: ( localize(
|
|
21
|
+
description: ( localize(14111, "Indicates whether there are MCP servers with unknown tools."))
|
|
22
22
|
}));
|
|
23
23
|
McpContextKeys.hasServersWithErrors = ( new RawContextKey("mcp.hasServersWithErrors", undefined, {
|
|
24
24
|
type: "boolean",
|
|
25
|
-
description: ( localize(
|
|
25
|
+
description: ( localize(14112, "Indicates whether there are any MCP servers with errors."))
|
|
26
26
|
}));
|
|
27
27
|
McpContextKeys.toolsCount = ( new RawContextKey("mcp.toolsCount", undefined, {
|
|
28
28
|
type: "number",
|
|
29
|
-
description: ( localize(
|
|
29
|
+
description: ( localize(14113, "Context key that has the number of registered MCP tools"))
|
|
30
30
|
}));
|
|
31
31
|
})(McpContextKeys || (McpContextKeys = {}));
|
|
32
32
|
let McpContextKeysController = class McpContextKeysController extends Disposable {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
2
|
+
import { McpServerStatus } from "@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/state";
|
|
3
|
+
export interface IMcpEditorAgentHostServer {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly enabled: boolean;
|
|
6
|
+
readonly status: McpServerStatus;
|
|
7
|
+
}
|
|
8
|
+
export interface IMcpEditorAgentHostSessionServers {
|
|
9
|
+
readonly resource: URI;
|
|
10
|
+
readonly servers: readonly IMcpEditorAgentHostServer[];
|
|
11
|
+
}
|
|
12
|
+
export declare function getActiveAgentHostMcpSessionResource(sessionResource: URI | undefined): URI | undefined;
|
|
13
|
+
export declare function countRunningMcpServersInOtherSessions(currentSession: URI, sessions: readonly IMcpEditorAgentHostSessionServers[]): Map<string, number>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
3
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-root/state';
|
|
4
|
+
import { McpServerStatus } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-session/state';
|
|
5
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-chat/state';
|
|
6
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-terminal/state';
|
|
7
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-changeset/state';
|
|
8
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-resource-watch/state';
|
|
9
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-automation/state';
|
|
10
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-automation-run/state';
|
|
11
|
+
import { isAgentHostTarget } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService';
|
|
12
|
+
import { getChatSessionType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/model/chatUri';
|
|
13
|
+
|
|
14
|
+
function getActiveAgentHostMcpSessionResource(sessionResource) {
|
|
15
|
+
return sessionResource && isAgentHostTarget(getChatSessionType(sessionResource)) ? sessionResource : undefined;
|
|
16
|
+
}
|
|
17
|
+
function countRunningMcpServersInOtherSessions(currentSession, sessions) {
|
|
18
|
+
const counts = ( new Map());
|
|
19
|
+
for (const session of sessions) {
|
|
20
|
+
if (isEqual(session.resource, currentSession)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const running = ( new Set());
|
|
24
|
+
for (const server of session.servers) {
|
|
25
|
+
if (server.enabled && server.status === McpServerStatus.Ready) {
|
|
26
|
+
running.add(server.name);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const name of running) {
|
|
30
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return counts;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { countRunningMcpServersInOtherSessions, getActiveAgentHostMcpSessionResource };
|
|
@@ -71,7 +71,7 @@ let McpLanguageModelToolContribution = class McpLanguageModelToolContribution ex
|
|
|
71
71
|
const toolSet = store.add(
|
|
72
72
|
this._toolsService.createToolSet(source, server.definition.id, referenceName, {
|
|
73
73
|
icon: Codicon.mcp,
|
|
74
|
-
description: ( localize(
|
|
74
|
+
description: ( localize(14114, "{0}: All Tools", server.definition.label)),
|
|
75
75
|
deprecated: true
|
|
76
76
|
})
|
|
77
77
|
);
|
|
@@ -192,7 +192,7 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
192
192
|
});
|
|
193
193
|
const isSandboxedServer = sandboxEnabled === true;
|
|
194
194
|
const mcpToolWarning = ( localize(
|
|
195
|
-
|
|
195
|
+
14115,
|
|
196
196
|
"Note that MCP servers or malicious conversation content may attempt to misuse '{0}' through tools.",
|
|
197
197
|
this._productService.nameShort
|
|
198
198
|
));
|
|
@@ -201,7 +201,7 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
201
201
|
if (!isSandboxedServer) {
|
|
202
202
|
confirm = {};
|
|
203
203
|
if (!tool.definition.annotations?.readOnlyHint) {
|
|
204
|
-
confirm.title = ( new MarkdownString(( localize(
|
|
204
|
+
confirm.title = ( new MarkdownString(( localize(14116, "Run {0}", title))));
|
|
205
205
|
confirm.message = ( new MarkdownString(tool.definition.description, {
|
|
206
206
|
supportThemeIcons: true
|
|
207
207
|
}));
|
|
@@ -215,9 +215,9 @@ let McpToolImplementation = class McpToolImplementation {
|
|
|
215
215
|
const mcpUiEnabled = this._configurationService.getValue(mcpAppsEnabledConfig);
|
|
216
216
|
return {
|
|
217
217
|
confirmationMessages: confirm,
|
|
218
|
-
invocationMessage: ( new MarkdownString(( localize(
|
|
219
|
-
pastTenseMessage: ( new MarkdownString(( localize(
|
|
220
|
-
originMessage: ( localize(
|
|
218
|
+
invocationMessage: ( new MarkdownString(( localize(14117, "Running {0}", title)))),
|
|
219
|
+
pastTenseMessage: ( new MarkdownString(( localize(14118, "Ran {0} ", title)))),
|
|
220
|
+
originMessage: ( localize(14119, "{0} (MCP Server)", server.definition.label)),
|
|
221
221
|
toolSpecificData: {
|
|
222
222
|
kind: "input",
|
|
223
223
|
rawInput: context.parameters,
|
|
@@ -35,6 +35,7 @@ export declare class McpRegistry extends Disposable implements IMcpRegistry {
|
|
|
35
35
|
private readonly _collections;
|
|
36
36
|
private readonly _delegates;
|
|
37
37
|
private readonly _mcpAccessValue;
|
|
38
|
+
private readonly _strictPluginOnlyCustomization;
|
|
38
39
|
readonly collections: IObservable<readonly McpCollectionDefinition[]>;
|
|
39
40
|
private readonly _workspaceStorage;
|
|
40
41
|
private readonly _profileStorage;
|
|
@@ -75,5 +76,6 @@ export declare class McpRegistry extends Disposable implements IMcpRegistry {
|
|
|
75
76
|
}[]): Promise<string[] | undefined>;
|
|
76
77
|
private _updateStorageWithExpressionInputs;
|
|
77
78
|
private _replaceVariablesInLaunch;
|
|
79
|
+
private isCollectionAllowed;
|
|
78
80
|
resolveConnection(opts: IMcpResolveConnectionOptions): Promise<IMcpServerConnection | undefined>;
|
|
79
81
|
}
|