@codingame/monaco-vscode-mcp-service-override 16.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 (43) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +20 -0
  3. package/package.json +50 -0
  4. package/vscode/src/vs/platform/mcp/common/nativeMcpDiscoveryHelper.d.ts +9 -0
  5. package/vscode/src/vs/platform/mcp/common/nativeMcpDiscoveryHelper.js +5 -0
  6. package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.d.ts +1 -0
  7. package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +47 -0
  8. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpDiscovery.d.ts +8 -0
  9. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpDiscovery.js +36 -0
  10. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.d.ts +21 -0
  11. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +340 -0
  12. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/configMcpDiscovery.d.ts +17 -0
  13. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/configMcpDiscovery.js +146 -0
  14. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.d.ts +15 -0
  15. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +108 -0
  16. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/mcpDiscovery.d.ts +12 -0
  17. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/mcpDiscovery.js +16 -0
  18. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.d.ts +34 -0
  19. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +134 -0
  20. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.d.ts +34 -0
  21. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.js +79 -0
  22. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpRemoteDiscovery.d.ts +14 -0
  23. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpRemoteDiscovery.js +44 -0
  24. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.d.ts +15 -0
  25. package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.js +68 -0
  26. package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigFileUtils.d.ts +6 -0
  27. package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigFileUtils.js +30 -0
  28. package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigPathsService.d.ts +33 -0
  29. package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigPathsService.js +112 -0
  30. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.d.ts +59 -0
  31. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +322 -0
  32. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistryInputStorage.d.ts +27 -0
  33. package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistryInputStorage.js +134 -0
  34. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.d.ts +77 -0
  35. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.js +383 -0
  36. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.d.ts +26 -0
  37. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +114 -0
  38. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.d.ts +63 -0
  39. package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.js +318 -0
  40. package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.d.ts +27 -0
  41. package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +220 -0
  42. package/vscode/src/vs/workbench/contrib/mcp/common/modelContextProtocol.d.ts +374 -0
  43. package/vscode/src/vs/workbench/contrib/mcp/common/modelContextProtocol.js +14 -0
@@ -0,0 +1,146 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
4
+ import { Throttler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
5
+ import { Disposable, MutableDisposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
6
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
7
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
8
+ import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
9
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
10
+ import { getMcpServerMapping } from '../mcpConfigFileUtils.js';
11
+ import { IMcpConfigPathsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfigPathsService.service';
12
+ import { mcpConfigurationSection } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
13
+ import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
14
+ import { McpServerTransportType, McpServerDefinition } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
15
+ import { autorunDelta } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
16
+ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
17
+
18
+ let ConfigMcpDiscovery = class ConfigMcpDiscovery extends Disposable {
19
+ constructor(_configurationService, _mcpRegistry, _textModelService, _mcpConfigPathsService) {
20
+ super();
21
+ this._configurationService = _configurationService;
22
+ this._mcpRegistry = _mcpRegistry;
23
+ this._textModelService = _textModelService;
24
+ this._mcpConfigPathsService = _mcpConfigPathsService;
25
+ this.configSources = [];
26
+ }
27
+ start() {
28
+ const throttler = this._register(( new Throttler()));
29
+ const addPath = (path) => {
30
+ this.configSources.push({
31
+ path,
32
+ serverDefinitions: observableValue(this, []),
33
+ disposable: this._register(( new MutableDisposable())),
34
+ getServerToLocationMapping: (uri) => this._getServerIdMapping(uri, path.section ? [...path.section, 'servers'] : ['servers']),
35
+ });
36
+ };
37
+ this._register(this._configurationService.onDidChangeConfiguration(e => {
38
+ if (e.affectsConfiguration(mcpConfigurationSection)) {
39
+ throttler.queue(() => this.sync());
40
+ }
41
+ }));
42
+ this._register(autorunDelta(this._mcpConfigPathsService.paths, ({ lastValue, newValue }) => {
43
+ for (const last of lastValue || []) {
44
+ if (!newValue.includes(last)) {
45
+ const idx = this.configSources.findIndex(src => src.path.id === last.id);
46
+ if (idx !== -1) {
47
+ this.configSources[idx].disposable.dispose();
48
+ this.configSources.splice(idx, 1);
49
+ }
50
+ }
51
+ }
52
+ for (const next of newValue) {
53
+ if (!lastValue || !lastValue.includes(next)) {
54
+ addPath(next);
55
+ }
56
+ }
57
+ this.sync();
58
+ }));
59
+ }
60
+ async _getServerIdMapping(resource, pathToServers) {
61
+ const store = ( new DisposableStore());
62
+ try {
63
+ const ref = await this._textModelService.createModelReference(resource);
64
+ store.add(ref);
65
+ const serverIdMapping = getMcpServerMapping({ model: ref.object.textEditorModel, pathToServers });
66
+ return serverIdMapping;
67
+ }
68
+ catch {
69
+ return ( new Map());
70
+ }
71
+ finally {
72
+ store.dispose();
73
+ }
74
+ }
75
+ async sync() {
76
+ const configurationKey = this._configurationService.inspect(mcpConfigurationSection);
77
+ const configMappings = await Promise.all(( this.configSources.map(src => {
78
+ const uri = src.path.uri;
79
+ return uri && src.getServerToLocationMapping(uri);
80
+ })));
81
+ for (const [index, src] of this.configSources.entries()) {
82
+ const collectionId = `mcp.config.${src.path.id}`;
83
+ let value = src.path.workspaceFolder
84
+ ? this._configurationService.inspect(mcpConfigurationSection, { resource: src.path.workspaceFolder.uri })[src.path.key]
85
+ : configurationKey[src.path.key];
86
+ if (value?.mcpServers) {
87
+ value = { ...value, servers: { ...value.servers, ...value.mcpServers }, mcpServers: undefined };
88
+ this._configurationService.updateValue(mcpConfigurationSection, value, {}, src.path.target, { donotNotifyError: true });
89
+ }
90
+ const configMapping = configMappings[index];
91
+ const nextDefinitions = ( Object.entries(value?.servers || {}).map(([name, value]) => ({
92
+ id: `${collectionId}.${name}`,
93
+ label: name,
94
+ launch: 'type' in value && value.type === 'sse' ? {
95
+ type: McpServerTransportType.SSE,
96
+ uri: ( URI.parse(value.url)),
97
+ headers: Object.entries(value.headers || {}),
98
+ } : {
99
+ type: McpServerTransportType.Stdio,
100
+ args: value.args || [],
101
+ command: value.command,
102
+ env: value.env || {},
103
+ envFile: value.envFile,
104
+ cwd: undefined,
105
+ },
106
+ roots: src.path.workspaceFolder ? [src.path.workspaceFolder.uri] : [],
107
+ variableReplacement: {
108
+ folder: src.path.workspaceFolder,
109
+ section: mcpConfigurationSection,
110
+ target: src.path.target,
111
+ },
112
+ presentation: {
113
+ order: src.path.order,
114
+ origin: configMapping?.get(name),
115
+ }
116
+ })));
117
+ if (equals(nextDefinitions, src.serverDefinitions.get(), McpServerDefinition.equals)) {
118
+ continue;
119
+ }
120
+ if (!nextDefinitions.length) {
121
+ src.disposable.clear();
122
+ src.serverDefinitions.set(nextDefinitions, undefined);
123
+ }
124
+ else {
125
+ src.serverDefinitions.set(nextDefinitions, undefined);
126
+ src.disposable.value ??= this._mcpRegistry.registerCollection({
127
+ id: collectionId,
128
+ label: src.path.label,
129
+ presentation: { order: src.path.order, origin: src.path.uri },
130
+ remoteAuthority: src.path.remoteAuthority || null,
131
+ serverDefinitions: src.serverDefinitions,
132
+ isTrustedByDefault: true,
133
+ scope: src.path.scope,
134
+ });
135
+ }
136
+ }
137
+ }
138
+ };
139
+ ConfigMcpDiscovery = ( __decorate([
140
+ ( __param(0, IConfigurationService)),
141
+ ( __param(1, IMcpRegistry)),
142
+ ( __param(2, ITextModelService)),
143
+ ( __param(3, IMcpConfigPathsService))
144
+ ], ConfigMcpDiscovery));
145
+
146
+ export { ConfigMcpDiscovery };
@@ -0,0 +1,15 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
3
+ import { IExtensionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service";
4
+ import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
5
+ import { IMcpDiscovery } from "./mcpDiscovery.js";
6
+ export declare class ExtensionMcpDiscovery extends Disposable implements IMcpDiscovery {
7
+ private readonly _mcpRegistry;
8
+ private readonly _extensionService;
9
+ private readonly _extensionCollectionIdsToPersist;
10
+ private readonly cachedServers;
11
+ constructor(_mcpRegistry: IMcpRegistry, storageService: IStorageService, _extensionService: IExtensionService);
12
+ start(): void;
13
+ private _activateExtensionServers;
14
+ private static _validate;
15
+ }
@@ -0,0 +1,108 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { Disposable, DisposableMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
4
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
5
+ import { isFalsyOrWhitespace } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
6
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
7
+ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
8
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
9
+ import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
10
+ import { ExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
11
+ import { mcpContributionPoint, mcpActivationEvent } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
12
+ import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
13
+ import { McpServerDefinition, extensionPrefixedIdentifier } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
14
+ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
15
+
16
+ var ExtensionMcpDiscovery_1;
17
+ const cacheKey = 'mcp.extCachedServers';
18
+ const _mcpExtensionPoint = ExtensionsRegistry.registerExtensionPoint(mcpContributionPoint);
19
+ let ExtensionMcpDiscovery = ExtensionMcpDiscovery_1 = class ExtensionMcpDiscovery extends Disposable {
20
+ constructor(_mcpRegistry, storageService, _extensionService) {
21
+ super();
22
+ this._mcpRegistry = _mcpRegistry;
23
+ this._extensionService = _extensionService;
24
+ this._extensionCollectionIdsToPersist = ( new Set());
25
+ this.cachedServers = storageService.getObject(cacheKey, StorageScope.WORKSPACE, {});
26
+ this._register(storageService.onWillSaveState(() => {
27
+ let updated = false;
28
+ for (const collectionId of this._extensionCollectionIdsToPersist) {
29
+ const collection = this._mcpRegistry.collections.get().find(c => c.id === collectionId);
30
+ if (!collection || collection.lazy) {
31
+ continue;
32
+ }
33
+ const defs = collection.serverDefinitions.get();
34
+ if (defs) {
35
+ updated = true;
36
+ this.cachedServers[collectionId] = { servers: ( defs.map(McpServerDefinition.toSerialized)) };
37
+ }
38
+ }
39
+ if (updated) {
40
+ storageService.store(cacheKey, this.cachedServers, StorageScope.WORKSPACE, StorageTarget.MACHINE);
41
+ }
42
+ }));
43
+ }
44
+ start() {
45
+ const extensionCollections = this._register(( new DisposableMap()));
46
+ this._register(_mcpExtensionPoint.setHandler((_extensions, delta) => {
47
+ const { added, removed } = delta;
48
+ for (const collections of removed) {
49
+ for (const coll of collections.value) {
50
+ extensionCollections.deleteAndDispose(extensionPrefixedIdentifier(collections.description.identifier, coll.id));
51
+ }
52
+ }
53
+ for (const collections of added) {
54
+ if (!ExtensionMcpDiscovery_1._validate(collections)) {
55
+ continue;
56
+ }
57
+ for (const coll of collections.value) {
58
+ const id = extensionPrefixedIdentifier(collections.description.identifier, coll.id);
59
+ this._extensionCollectionIdsToPersist.add(id);
60
+ const serverDefs = this.cachedServers.hasOwnProperty(id) ? this.cachedServers[id].servers : undefined;
61
+ const dispo = this._mcpRegistry.registerCollection({
62
+ id,
63
+ label: coll.label,
64
+ remoteAuthority: null,
65
+ isTrustedByDefault: true,
66
+ scope: StorageScope.WORKSPACE,
67
+ serverDefinitions: observableValue(this, serverDefs?.map(McpServerDefinition.fromSerialized) || []),
68
+ lazy: {
69
+ isCached: !!serverDefs,
70
+ load: () => this._activateExtensionServers(coll.id),
71
+ removed: () => extensionCollections.deleteAndDispose(id),
72
+ }
73
+ });
74
+ extensionCollections.set(id, dispo);
75
+ }
76
+ }
77
+ }));
78
+ }
79
+ async _activateExtensionServers(collectionId) {
80
+ await this._extensionService.activateByEvent(mcpActivationEvent(collectionId));
81
+ await Promise.all(( this._mcpRegistry.delegates
82
+ .map(r => r.waitForInitialProviderPromises())));
83
+ }
84
+ static _validate(user) {
85
+ if (!Array.isArray(user.value)) {
86
+ user.collector.error(( localize(7631, "Expected an array of MCP collections")));
87
+ return false;
88
+ }
89
+ for (const contribution of user.value) {
90
+ if (typeof contribution.id !== 'string' || isFalsyOrWhitespace(contribution.id)) {
91
+ user.collector.error(( localize(7632, "Expected 'id' to be a non-empty string.")));
92
+ return false;
93
+ }
94
+ if (typeof contribution.label !== 'string' || isFalsyOrWhitespace(contribution.label)) {
95
+ user.collector.error(( localize(7633, "Expected 'label' to be a non-empty string.")));
96
+ return false;
97
+ }
98
+ }
99
+ return true;
100
+ }
101
+ };
102
+ ExtensionMcpDiscovery = ExtensionMcpDiscovery_1 = ( __decorate([
103
+ ( __param(0, IMcpRegistry)),
104
+ ( __param(1, IStorageService)),
105
+ ( __param(2, IExtensionService))
106
+ ], ExtensionMcpDiscovery));
107
+
108
+ export { ExtensionMcpDiscovery };
@@ -0,0 +1,12 @@
1
+ import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { SyncDescriptor0 } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors";
3
+ export interface IMcpDiscovery extends IDisposable {
4
+ start(): void;
5
+ }
6
+ declare class McpDiscoveryRegistry {
7
+ private readonly _discovery;
8
+ register(discovery: SyncDescriptor0<IMcpDiscovery>): void;
9
+ getAll(): readonly SyncDescriptor0<IMcpDiscovery>[];
10
+ }
11
+ export declare const mcpDiscoveryRegistry: McpDiscoveryRegistry;
12
+ export {};
@@ -0,0 +1,16 @@
1
+
2
+
3
+ class McpDiscoveryRegistry {
4
+ constructor() {
5
+ this._discovery = [];
6
+ }
7
+ register(discovery) {
8
+ this._discovery.push(discovery);
9
+ }
10
+ getAll() {
11
+ return this._discovery;
12
+ }
13
+ }
14
+ const mcpDiscoveryRegistry = ( new McpDiscoveryRegistry());
15
+
16
+ export { mcpDiscoveryRegistry };
@@ -0,0 +1,34 @@
1
+ import { VSBuffer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
2
+ import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
3
+ import { IObservable, IReader, ISettableObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
4
+ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
5
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
6
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
7
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
8
+ import { ILabelService } from "@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service";
9
+ import { INativeMcpDiscoveryData } from "../../../../../platform/mcp/common/nativeMcpDiscoveryHelper.js";
10
+ import { Dto } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/proxyIdentifier";
11
+ import { DiscoverySource } from "@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration";
12
+ import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
13
+ import { McpCollectionDefinition, McpServerDefinition } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
14
+ import { IMcpDiscovery } from "./mcpDiscovery.js";
15
+ export type WritableMcpCollectionDefinition = McpCollectionDefinition & {
16
+ serverDefinitions: ISettableObservable<readonly McpServerDefinition[]>;
17
+ };
18
+ export declare abstract class FilesystemMcpDiscovery extends Disposable {
19
+ private readonly _fileService;
20
+ private readonly _mcpRegistry;
21
+ protected readonly _fsDiscoveryEnabled: IObservable<boolean | {
22
+ [K in DiscoverySource]: boolean;
23
+ }>;
24
+ constructor(configurationService: IConfigurationService, _fileService: IFileService, _mcpRegistry: IMcpRegistry);
25
+ protected _isDiscoveryEnabled(reader: IReader, discoverySource: DiscoverySource | undefined): boolean;
26
+ protected watchFile(file: URI, collection: WritableMcpCollectionDefinition, discoverySource: DiscoverySource | undefined, adaptFile: (contents: VSBuffer) => McpServerDefinition[] | undefined): IDisposable;
27
+ }
28
+ export declare abstract class NativeFilesystemMcpDiscovery extends FilesystemMcpDiscovery implements IMcpDiscovery {
29
+ private readonly adapters;
30
+ private suffix;
31
+ constructor(remoteAuthority: string | null, labelService: ILabelService, fileService: IFileService, instantiationService: IInstantiationService, mcpRegistry: IMcpRegistry, configurationService: IConfigurationService);
32
+ abstract start(): void;
33
+ protected setDetails(detailsDto: Dto<INativeMcpDiscoveryData> | undefined): void;
34
+ }
@@ -0,0 +1,134 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { RunOnceScheduler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
4
+ import { Disposable, DisposableStore, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
5
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
6
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
7
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
8
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
9
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
10
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
11
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
12
+ import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
13
+ import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
14
+ import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
15
+ import { mcpDiscoverySection, discoverySourceLabel } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
16
+ import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
17
+ import { McpCollectionSortOrder } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
18
+ import { ClaudeDesktopMpcDiscoveryAdapter, CursorDesktopMpcDiscoveryAdapter, WindsurfDesktopMpcDiscoveryAdapter } from './nativeMcpDiscoveryAdapters.js';
19
+ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
20
+ import { autorunWithStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
21
+
22
+ let FilesystemMcpDiscovery = class FilesystemMcpDiscovery extends Disposable {
23
+ constructor(configurationService, _fileService, _mcpRegistry) {
24
+ super();
25
+ this._fileService = _fileService;
26
+ this._mcpRegistry = _mcpRegistry;
27
+ this._fsDiscoveryEnabled = observableConfigValue(mcpDiscoverySection, true, configurationService);
28
+ }
29
+ _isDiscoveryEnabled(reader, discoverySource) {
30
+ const fsDiscovery = this._fsDiscoveryEnabled.read(reader);
31
+ if (typeof fsDiscovery === 'boolean') {
32
+ return fsDiscovery;
33
+ }
34
+ if (discoverySource && fsDiscovery[discoverySource] === false) {
35
+ return false;
36
+ }
37
+ return true;
38
+ }
39
+ watchFile(file, collection, discoverySource, adaptFile) {
40
+ const store = ( new DisposableStore());
41
+ const collectionRegistration = store.add(( new MutableDisposable()));
42
+ const updateFile = async () => {
43
+ let definitions = [];
44
+ try {
45
+ const contents = await this._fileService.readFile(file);
46
+ definitions = adaptFile(contents.value) || [];
47
+ }
48
+ catch {
49
+ }
50
+ if (!definitions.length) {
51
+ collectionRegistration.clear();
52
+ }
53
+ else {
54
+ collection.serverDefinitions.set(definitions, undefined);
55
+ if (!collectionRegistration.value) {
56
+ collectionRegistration.value = this._mcpRegistry.registerCollection(collection);
57
+ }
58
+ }
59
+ };
60
+ store.add(autorunWithStore((reader, store) => {
61
+ if (!this._isDiscoveryEnabled(reader, discoverySource)) {
62
+ collectionRegistration.clear();
63
+ return;
64
+ }
65
+ const throttler = store.add(( new RunOnceScheduler(updateFile, 500)));
66
+ const watcher = store.add(this._fileService.createWatcher(file, { recursive: false, excludes: [] }));
67
+ store.add(watcher.onDidChange(() => throttler.schedule()));
68
+ updateFile();
69
+ }));
70
+ return store;
71
+ }
72
+ };
73
+ FilesystemMcpDiscovery = ( __decorate([
74
+ ( __param(0, IConfigurationService)),
75
+ ( __param(1, IFileService)),
76
+ ( __param(2, IMcpRegistry))
77
+ ], FilesystemMcpDiscovery));
78
+ let NativeFilesystemMcpDiscovery = class NativeFilesystemMcpDiscovery extends FilesystemMcpDiscovery {
79
+ constructor(remoteAuthority, labelService, fileService, instantiationService, mcpRegistry, configurationService) {
80
+ super(configurationService, fileService, mcpRegistry);
81
+ this.suffix = '';
82
+ if (remoteAuthority) {
83
+ this.suffix = ' ' + ( localize(
84
+ 7634,
85
+ ' on {0}',
86
+ labelService.getHostLabel(Schemas.vscodeRemote, remoteAuthority)
87
+ ));
88
+ }
89
+ this.adapters = [
90
+ instantiationService.createInstance(ClaudeDesktopMpcDiscoveryAdapter, remoteAuthority),
91
+ instantiationService.createInstance(CursorDesktopMpcDiscoveryAdapter, remoteAuthority),
92
+ instantiationService.createInstance(WindsurfDesktopMpcDiscoveryAdapter, remoteAuthority),
93
+ ];
94
+ }
95
+ setDetails(detailsDto) {
96
+ if (!detailsDto) {
97
+ return;
98
+ }
99
+ const details = {
100
+ ...detailsDto,
101
+ homedir: URI.revive(detailsDto.homedir),
102
+ xdgHome: detailsDto.xdgHome ? URI.revive(detailsDto.xdgHome) : undefined,
103
+ winAppData: detailsDto.winAppData ? URI.revive(detailsDto.winAppData) : undefined,
104
+ };
105
+ for (const adapter of this.adapters) {
106
+ const file = adapter.getFilePath(details);
107
+ if (!file) {
108
+ continue;
109
+ }
110
+ const collection = {
111
+ id: adapter.id,
112
+ label: discoverySourceLabel[adapter.discoverySource] + this.suffix,
113
+ remoteAuthority: adapter.remoteAuthority,
114
+ scope: StorageScope.PROFILE,
115
+ isTrustedByDefault: false,
116
+ serverDefinitions: observableValue(this, []),
117
+ presentation: {
118
+ origin: file,
119
+ order: adapter.order + (adapter.remoteAuthority ? McpCollectionSortOrder.RemoteBoost : 0),
120
+ },
121
+ };
122
+ this._register(this.watchFile(file, collection, adapter.discoverySource, contents => adapter.adaptFile(contents, details)));
123
+ }
124
+ }
125
+ };
126
+ NativeFilesystemMcpDiscovery = ( __decorate([
127
+ ( __param(1, ILabelService)),
128
+ ( __param(2, IFileService)),
129
+ ( __param(3, IInstantiationService)),
130
+ ( __param(4, IMcpRegistry)),
131
+ ( __param(5, IConfigurationService))
132
+ ], NativeFilesystemMcpDiscovery));
133
+
134
+ export { FilesystemMcpDiscovery, NativeFilesystemMcpDiscovery };
@@ -0,0 +1,34 @@
1
+ import { VSBuffer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
2
+ import { Mutable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/types";
3
+ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
4
+ import { INativeMcpDiscoveryData } from "../../../../../platform/mcp/common/nativeMcpDiscoveryHelper.js";
5
+ import { DiscoverySource } from "@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration";
6
+ import { McpCollectionSortOrder, McpServerDefinition } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes";
7
+ export interface NativeMpcDiscoveryAdapter {
8
+ readonly remoteAuthority: string | null;
9
+ readonly id: string;
10
+ readonly order: number;
11
+ readonly discoverySource: DiscoverySource;
12
+ getFilePath(details: INativeMcpDiscoveryData): URI | undefined;
13
+ adaptFile(contents: VSBuffer, details: INativeMcpDiscoveryData): McpServerDefinition[] | undefined;
14
+ }
15
+ export declare function claudeConfigToServerDefinition(idPrefix: string, contents: VSBuffer, cwd?: URI): Mutable<McpServerDefinition>[] | undefined;
16
+ export declare class ClaudeDesktopMpcDiscoveryAdapter implements NativeMpcDiscoveryAdapter {
17
+ readonly remoteAuthority: string | null;
18
+ id: string;
19
+ readonly order = McpCollectionSortOrder.Filesystem;
20
+ readonly discoverySource: DiscoverySource;
21
+ constructor(remoteAuthority: string | null);
22
+ getFilePath({ platform, winAppData, xdgHome, homedir }: INativeMcpDiscoveryData): URI | undefined;
23
+ adaptFile(contents: VSBuffer, { homedir }: INativeMcpDiscoveryData): McpServerDefinition[] | undefined;
24
+ }
25
+ export declare class WindsurfDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
26
+ readonly discoverySource: DiscoverySource;
27
+ constructor(remoteAuthority: string | null);
28
+ getFilePath({ homedir }: INativeMcpDiscoveryData): URI | undefined;
29
+ }
30
+ export declare class CursorDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
31
+ readonly discoverySource: DiscoverySource;
32
+ constructor(remoteAuthority: string | null);
33
+ getFilePath({ homedir }: INativeMcpDiscoveryData): URI | undefined;
34
+ }
@@ -0,0 +1,79 @@
1
+
2
+ import { Platform } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
3
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
4
+ import { DiscoverySource } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
5
+ import { McpServerTransportType, McpCollectionSortOrder } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
6
+
7
+ function claudeConfigToServerDefinition(idPrefix, contents, cwd) {
8
+ let parsed;
9
+ try {
10
+ parsed = JSON.parse(( contents.toString()));
11
+ }
12
+ catch {
13
+ return;
14
+ }
15
+ return ( Object.entries(parsed.mcpServers).map(([name, server]) => {
16
+ return {
17
+ id: `${idPrefix}.${name}`,
18
+ label: name,
19
+ launch: server.url ? {
20
+ type: McpServerTransportType.SSE,
21
+ uri: ( URI.parse(server.url)),
22
+ headers: [],
23
+ } : {
24
+ type: McpServerTransportType.Stdio,
25
+ args: server.args || [],
26
+ command: server.command,
27
+ env: server.env || {},
28
+ envFile: undefined,
29
+ cwd,
30
+ }
31
+ };
32
+ }));
33
+ }
34
+ class ClaudeDesktopMpcDiscoveryAdapter {
35
+ constructor(remoteAuthority) {
36
+ this.remoteAuthority = remoteAuthority;
37
+ this.order = McpCollectionSortOrder.Filesystem;
38
+ this.discoverySource = DiscoverySource.ClaudeDesktop;
39
+ this.id = `claude-desktop.${this.remoteAuthority}`;
40
+ }
41
+ getFilePath({ platform, winAppData, xdgHome, homedir }) {
42
+ if (platform === Platform.Windows) {
43
+ const appData = winAppData || URI.joinPath(homedir, 'AppData', 'Roaming');
44
+ return URI.joinPath(appData, 'Claude', 'claude_desktop_config.json');
45
+ }
46
+ else if (platform === Platform.Mac) {
47
+ return URI.joinPath(homedir, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
48
+ }
49
+ else {
50
+ const configDir = xdgHome || URI.joinPath(homedir, '.config');
51
+ return URI.joinPath(configDir, 'Claude', 'claude_desktop_config.json');
52
+ }
53
+ }
54
+ adaptFile(contents, { homedir }) {
55
+ return claudeConfigToServerDefinition(this.id, contents, homedir);
56
+ }
57
+ }
58
+ class WindsurfDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
59
+ constructor(remoteAuthority) {
60
+ super(remoteAuthority);
61
+ this.discoverySource = DiscoverySource.Windsurf;
62
+ this.id = `windsurf.${this.remoteAuthority}`;
63
+ }
64
+ getFilePath({ homedir }) {
65
+ return URI.joinPath(homedir, '.codeium', 'windsurf', 'mcp_config.json');
66
+ }
67
+ }
68
+ class CursorDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
69
+ constructor(remoteAuthority) {
70
+ super(remoteAuthority);
71
+ this.discoverySource = DiscoverySource.CursorGlobal;
72
+ this.id = `cursor.${this.remoteAuthority}`;
73
+ }
74
+ getFilePath({ homedir }) {
75
+ return URI.joinPath(homedir, '.cursor', 'mcp.json');
76
+ }
77
+ }
78
+
79
+ export { ClaudeDesktopMpcDiscoveryAdapter, CursorDesktopMpcDiscoveryAdapter, WindsurfDesktopMpcDiscoveryAdapter, claudeConfigToServerDefinition };
@@ -0,0 +1,14 @@
1
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
2
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
3
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
4
+ import { ILabelService } from "@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service";
5
+ import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
6
+ import { IRemoteAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service";
7
+ import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
8
+ import { NativeFilesystemMcpDiscovery } from "./nativeMcpDiscoveryAbstract.js";
9
+ export declare class RemoteNativeMpcDiscovery extends NativeFilesystemMcpDiscovery {
10
+ private readonly remoteAgent;
11
+ private readonly logService;
12
+ constructor(remoteAgent: IRemoteAgentService, logService: ILogService, labelService: ILabelService, fileService: IFileService, instantiationService: IInstantiationService, mcpRegistry: IMcpRegistry, configurationService: IConfigurationService);
13
+ start(): Promise<void>;
14
+ }
@@ -0,0 +1,44 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { ProxyChannel } from '@codingame/monaco-vscode-4a3ac544-9a61-534c-88df-756262793ef7-common/vscode/vs/base/parts/ipc/common/ipc';
4
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
5
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
6
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
7
+ import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
8
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
9
+ import { NativeMcpDiscoveryHelperChannelName } from '../../../../../platform/mcp/common/nativeMcpDiscoveryHelper.js';
10
+ import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
11
+ import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
12
+ import { NativeFilesystemMcpDiscovery } from './nativeMcpDiscoveryAbstract.js';
13
+
14
+ let RemoteNativeMpcDiscovery = class RemoteNativeMpcDiscovery extends NativeFilesystemMcpDiscovery {
15
+ constructor(remoteAgent, logService, labelService, fileService, instantiationService, mcpRegistry, configurationService) {
16
+ super(remoteAgent.getConnection()?.remoteAuthority || null, labelService, fileService, instantiationService, mcpRegistry, configurationService);
17
+ this.remoteAgent = remoteAgent;
18
+ this.logService = logService;
19
+ }
20
+ async start() {
21
+ const connection = this.remoteAgent.getConnection();
22
+ if (!connection) {
23
+ return this.setDetails(undefined);
24
+ }
25
+ await connection.withChannel(NativeMcpDiscoveryHelperChannelName, async (channel) => {
26
+ const service = ProxyChannel.toService(channel);
27
+ service.load().then(data => this.setDetails(data), err => {
28
+ this.logService.warn('Error getting remote process MCP environment', err);
29
+ this.setDetails(undefined);
30
+ });
31
+ });
32
+ }
33
+ };
34
+ RemoteNativeMpcDiscovery = ( __decorate([
35
+ ( __param(0, IRemoteAgentService)),
36
+ ( __param(1, ILogService)),
37
+ ( __param(2, ILabelService)),
38
+ ( __param(3, IFileService)),
39
+ ( __param(4, IInstantiationService)),
40
+ ( __param(5, IMcpRegistry)),
41
+ ( __param(6, IConfigurationService))
42
+ ], RemoteNativeMpcDiscovery));
43
+
44
+ export { RemoteNativeMpcDiscovery };