@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.
- package/index.d.ts +2 -0
- package/index.js +20 -0
- package/package.json +50 -0
- package/vscode/src/vs/platform/mcp/common/nativeMcpDiscoveryHelper.d.ts +9 -0
- package/vscode/src/vs/platform/mcp/common/nativeMcpDiscoveryHelper.js +5 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +47 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpDiscovery.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpDiscovery.js +36 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.d.ts +21 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +340 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/configMcpDiscovery.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/configMcpDiscovery.js +146 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +108 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/mcpDiscovery.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/mcpDiscovery.js +16 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.d.ts +34 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +134 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.d.ts +34 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.js +79 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpRemoteDiscovery.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpRemoteDiscovery.js +44 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/workspaceMcpDiscoveryAdapter.js +68 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigFileUtils.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigFileUtils.js +30 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigPathsService.d.ts +33 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfigPathsService.js +112 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.d.ts +59 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +322 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistryInputStorage.d.ts +27 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistryInputStorage.js +134 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.d.ts +77 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.js +383 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +114 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.d.ts +63 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerRequestHandler.js +318 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.d.ts +27 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +220 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/modelContextProtocol.d.ts +374 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/modelContextProtocol.js +14 -0
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import '@codingame/monaco-vscode-api/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
3
|
+
import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
|
+
import { IMcpConfigPathsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfigPathsService.service';
|
|
5
|
+
import { IMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
|
|
6
|
+
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
7
|
+
import { McpConfigPathsService } from './vscode/src/vs/workbench/contrib/mcp/common/mcpConfigPathsService.js';
|
|
8
|
+
import { McpService } from './vscode/src/vs/workbench/contrib/mcp/common/mcpService.js';
|
|
9
|
+
import { McpRegistry } from './vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js';
|
|
10
|
+
import './vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js';
|
|
11
|
+
|
|
12
|
+
function getServiceOverride() {
|
|
13
|
+
return {
|
|
14
|
+
[IMcpConfigPathsService.toString()]: new SyncDescriptor(McpConfigPathsService, [], true),
|
|
15
|
+
[IMcpService.toString()]: new SyncDescriptor(McpService, [], true),
|
|
16
|
+
[IMcpRegistry.toString()]: new SyncDescriptor(McpRegistry, [], true)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { getServiceOverride as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codingame/monaco-vscode-mcp-service-override",
|
|
3
|
+
"version": "16.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "VSCode public API plugged on the monaco editor - mcp service-override",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "CodinGame",
|
|
9
|
+
"url": "http://www.codingame.com"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@codingame/monaco-vscode-2b1a9082-790f-527f-b013-d1b29d6265a3-common": "16.0.0",
|
|
19
|
+
"@codingame/monaco-vscode-4a3ac544-9a61-534c-88df-756262793ef7-common": "16.0.0",
|
|
20
|
+
"@codingame/monaco-vscode-ae8a8ca1-f243-508b-9c37-c88ebbd295fa-common": "16.0.0",
|
|
21
|
+
"@codingame/monaco-vscode-api": "16.0.0",
|
|
22
|
+
"@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common": "16.0.0"
|
|
23
|
+
},
|
|
24
|
+
"main": "index.js",
|
|
25
|
+
"module": "index.js",
|
|
26
|
+
"types": "index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"default": "./index.js"
|
|
30
|
+
},
|
|
31
|
+
"./vscode/*.css": {
|
|
32
|
+
"default": "./vscode/src/*.css"
|
|
33
|
+
},
|
|
34
|
+
"./vscode/*": {
|
|
35
|
+
"types": "./vscode/src/*.d.ts",
|
|
36
|
+
"default": "./vscode/src/*.js"
|
|
37
|
+
},
|
|
38
|
+
"./*": {
|
|
39
|
+
"types": "./*.d.ts",
|
|
40
|
+
"default": "./*.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"typesVersions": {
|
|
44
|
+
"*": {
|
|
45
|
+
"vscode/*": [
|
|
46
|
+
"./vscode/src/*.d.ts"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Platform } from "@codingame/monaco-vscode-api/vscode/vs/base/common/platform";
|
|
2
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
3
|
+
export declare const NativeMcpDiscoveryHelperChannelName = "NativeMcpDiscoveryHelper";
|
|
4
|
+
export interface INativeMcpDiscoveryData {
|
|
5
|
+
platform: Platform;
|
|
6
|
+
homedir: URI;
|
|
7
|
+
winAppData?: URI;
|
|
8
|
+
xdgHome?: URI;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
import { registerAction2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
3
|
+
import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
|
|
5
|
+
import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/platform/jsonschemas/common/jsonContributionRegistry';
|
|
6
|
+
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
7
|
+
import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
8
|
+
import { mcpSchemaId } from '@codingame/monaco-vscode-2b1a9082-790f-527f-b013-d1b29d6265a3-common/vscode/vs/workbench/services/configuration/common/configuration';
|
|
9
|
+
import { ConfigMcpDiscovery } from '../common/discovery/configMcpDiscovery.js';
|
|
10
|
+
import { ExtensionMcpDiscovery } from '../common/discovery/extensionMcpDiscovery.js';
|
|
11
|
+
import { mcpDiscoveryRegistry } from '../common/discovery/mcpDiscovery.js';
|
|
12
|
+
import { RemoteNativeMpcDiscovery } from '../common/discovery/nativeMcpRemoteDiscovery.js';
|
|
13
|
+
import { CursorWorkspaceMcpDiscoveryAdapter } from '../common/discovery/workspaceMcpDiscoveryAdapter.js';
|
|
14
|
+
import '../common/mcpConfigPathsService.js';
|
|
15
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
16
|
+
import { mcpServerSchema } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
17
|
+
import { McpContextKeysController } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpContextKeys';
|
|
18
|
+
import '../common/mcpRegistry.js';
|
|
19
|
+
import '../common/mcpService.js';
|
|
20
|
+
import { ListMcpServerCommand, McpServerOptionsCommand, ResetMcpTrustCommand, ResetMcpCachedTools, AddConfigurationAction, RemoveStoredInput, EditStoredInput, StartServer, StopServer, ShowOutput, InstallFromActivation, RestartServer, MCPServerActionRendering } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/browser/mcpCommands';
|
|
21
|
+
import { McpDiscovery } from './mcpDiscovery.js';
|
|
22
|
+
import { McpLanguageFeatures } from './mcpLanguageFeatures.js';
|
|
23
|
+
import { McpUrlHandler } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/browser/mcpUrlHandler';
|
|
24
|
+
|
|
25
|
+
mcpDiscoveryRegistry.register(( new SyncDescriptor(RemoteNativeMpcDiscovery)));
|
|
26
|
+
mcpDiscoveryRegistry.register(( new SyncDescriptor(ConfigMcpDiscovery)));
|
|
27
|
+
mcpDiscoveryRegistry.register(( new SyncDescriptor(ExtensionMcpDiscovery)));
|
|
28
|
+
mcpDiscoveryRegistry.register(( new SyncDescriptor(CursorWorkspaceMcpDiscoveryAdapter)));
|
|
29
|
+
registerWorkbenchContribution2('mcpDiscovery', McpDiscovery, WorkbenchPhase.AfterRestored);
|
|
30
|
+
registerWorkbenchContribution2('mcpContextKeys', McpContextKeysController, WorkbenchPhase.BlockRestore);
|
|
31
|
+
registerWorkbenchContribution2('mcpLanguageFeatures', McpLanguageFeatures, WorkbenchPhase.Eventually);
|
|
32
|
+
registerWorkbenchContribution2('mcpUrlHandler', McpUrlHandler, WorkbenchPhase.BlockRestore);
|
|
33
|
+
registerAction2(ListMcpServerCommand);
|
|
34
|
+
registerAction2(McpServerOptionsCommand);
|
|
35
|
+
registerAction2(ResetMcpTrustCommand);
|
|
36
|
+
registerAction2(ResetMcpCachedTools);
|
|
37
|
+
registerAction2(AddConfigurationAction);
|
|
38
|
+
registerAction2(RemoveStoredInput);
|
|
39
|
+
registerAction2(EditStoredInput);
|
|
40
|
+
registerAction2(StartServer);
|
|
41
|
+
registerAction2(StopServer);
|
|
42
|
+
registerAction2(ShowOutput);
|
|
43
|
+
registerAction2(InstallFromActivation);
|
|
44
|
+
registerAction2(RestartServer);
|
|
45
|
+
registerWorkbenchContribution2('mcpActionRendering', MCPServerActionRendering, WorkbenchPhase.BlockRestore);
|
|
46
|
+
const jsonRegistry = ( Registry.as(Extensions.JSONContribution));
|
|
47
|
+
jsonRegistry.registerSchema(mcpSchemaId, mcpServerSchema);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
3
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
4
|
+
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
5
|
+
export declare class McpDiscovery extends Disposable implements IWorkbenchContribution {
|
|
6
|
+
static readonly ID = "workbench.contrib.mcp.discovery";
|
|
7
|
+
constructor(instantiationService: IInstantiationService, configurationService: IConfigurationService);
|
|
8
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
5
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
6
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
|
+
import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
|
|
8
|
+
import { mcpDiscoveryRegistry } from '../common/discovery/mcpDiscovery.js';
|
|
9
|
+
import { mcpEnabledSection } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
10
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
|
11
|
+
|
|
12
|
+
let McpDiscovery = class McpDiscovery extends Disposable {
|
|
13
|
+
static { this.ID = 'workbench.contrib.mcp.discovery'; }
|
|
14
|
+
constructor(instantiationService, configurationService) {
|
|
15
|
+
super();
|
|
16
|
+
const enabled = observableConfigValue(mcpEnabledSection, true, configurationService);
|
|
17
|
+
const store = this._register(( new DisposableStore()));
|
|
18
|
+
this._register(autorun(reader => {
|
|
19
|
+
if (enabled.read(reader)) {
|
|
20
|
+
for (const discovery of mcpDiscoveryRegistry.getAll()) {
|
|
21
|
+
const inst = store.add(instantiationService.createInstance(discovery));
|
|
22
|
+
inst.start();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
store.clear();
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
McpDiscovery = ( __decorate([
|
|
32
|
+
( __param(0, IInstantiationService)),
|
|
33
|
+
( __param(1, IConfigurationService))
|
|
34
|
+
], McpDiscovery));
|
|
35
|
+
|
|
36
|
+
export { McpDiscovery };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { ILanguageFeaturesService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service";
|
|
3
|
+
import { IMarkerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers.service";
|
|
4
|
+
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
5
|
+
import { IConfigurationResolverService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolver.service";
|
|
6
|
+
import { IMcpConfigPathsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfigPathsService.service";
|
|
7
|
+
import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
|
|
8
|
+
import { IMcpService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service";
|
|
9
|
+
export declare class McpLanguageFeatures extends Disposable implements IWorkbenchContribution {
|
|
10
|
+
private readonly _mcpRegistry;
|
|
11
|
+
private readonly _mcpConfigPathsService;
|
|
12
|
+
private readonly _mcpService;
|
|
13
|
+
private readonly _markerService;
|
|
14
|
+
private readonly _configurationResolverService;
|
|
15
|
+
private readonly _cachedMcpSection;
|
|
16
|
+
constructor(languageFeaturesService: ILanguageFeaturesService, _mcpRegistry: IMcpRegistry, _mcpConfigPathsService: IMcpConfigPathsService, _mcpService: IMcpService, _markerService: IMarkerService, _configurationResolverService: IConfigurationResolverService);
|
|
17
|
+
private _parseModel;
|
|
18
|
+
private _addDiagnostics;
|
|
19
|
+
private _provideCodeLenses;
|
|
20
|
+
private _provideInlayHints;
|
|
21
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { computeLevenshteinDistance } from '@codingame/monaco-vscode-api/vscode/vs/base/common/diff/diff';
|
|
4
|
+
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
5
|
+
import { MarkdownString, markdownCommandLink } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
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';
|
|
8
|
+
import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
9
|
+
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
10
|
+
import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
|
|
11
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
12
|
+
import { MarkerSeverity } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers';
|
|
13
|
+
import { IMarkerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers.service';
|
|
14
|
+
import { IConfigurationResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolver.service';
|
|
15
|
+
import { ConfigurationResolverExpression } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolverExpression';
|
|
16
|
+
import { IMcpConfigPathsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfigPathsService.service';
|
|
17
|
+
import { mcpConfigurationSection } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/common/mcpConfiguration';
|
|
18
|
+
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
19
|
+
import { McpConnectionState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
20
|
+
import { IMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
|
|
21
|
+
import { StartServer, ShowOutput, StopServer, RestartServer, EditStoredInput, RemoveStoredInput } from '@codingame/monaco-vscode-ec21d4de-4d65-574c-8715-bb1a6bbad376-common/vscode/vs/workbench/contrib/mcp/browser/mcpCommands';
|
|
22
|
+
|
|
23
|
+
const diagnosticOwner = 'vscode.mcp';
|
|
24
|
+
let McpLanguageFeatures = class McpLanguageFeatures extends Disposable {
|
|
25
|
+
constructor(languageFeaturesService, _mcpRegistry, _mcpConfigPathsService, _mcpService, _markerService, _configurationResolverService) {
|
|
26
|
+
super();
|
|
27
|
+
this._mcpRegistry = _mcpRegistry;
|
|
28
|
+
this._mcpConfigPathsService = _mcpConfigPathsService;
|
|
29
|
+
this._mcpService = _mcpService;
|
|
30
|
+
this._markerService = _markerService;
|
|
31
|
+
this._configurationResolverService = _configurationResolverService;
|
|
32
|
+
this._cachedMcpSection = this._register(( new MutableDisposable()));
|
|
33
|
+
const patterns = [
|
|
34
|
+
{ pattern: '**/.vscode/mcp.json' },
|
|
35
|
+
{ pattern: '**/settings.json' },
|
|
36
|
+
{ pattern: '**/workspace.json' },
|
|
37
|
+
];
|
|
38
|
+
const onDidChangeCodeLens = this._register(( new Emitter()));
|
|
39
|
+
const codeLensProvider = {
|
|
40
|
+
onDidChange: onDidChangeCodeLens.event,
|
|
41
|
+
provideCodeLenses: (model, range) => this._provideCodeLenses(model, () => onDidChangeCodeLens.fire(codeLensProvider)),
|
|
42
|
+
};
|
|
43
|
+
this._register(languageFeaturesService.codeLensProvider.register(patterns, codeLensProvider));
|
|
44
|
+
this._register(languageFeaturesService.inlayHintsProvider.register(patterns, {
|
|
45
|
+
onDidChangeInlayHints: _mcpRegistry.onDidChangeInputs,
|
|
46
|
+
provideInlayHints: (model, range) => this._provideInlayHints(model, range),
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
_parseModel(model) {
|
|
50
|
+
if (this._cachedMcpSection.value?.model === model) {
|
|
51
|
+
return this._cachedMcpSection.value;
|
|
52
|
+
}
|
|
53
|
+
const uri = model.uri;
|
|
54
|
+
const inConfig = this._mcpConfigPathsService.paths.get().find(u => isEqual(u.uri, uri));
|
|
55
|
+
if (!inConfig) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const value = model.getValue();
|
|
59
|
+
const tree = parseTree(value);
|
|
60
|
+
const listeners = [
|
|
61
|
+
model.onDidChangeContent(() => this._cachedMcpSection.clear()),
|
|
62
|
+
model.onWillDispose(() => this._cachedMcpSection.clear()),
|
|
63
|
+
];
|
|
64
|
+
this._addDiagnostics(model, value, tree, inConfig);
|
|
65
|
+
return this._cachedMcpSection.value = {
|
|
66
|
+
model,
|
|
67
|
+
tree,
|
|
68
|
+
inConfig,
|
|
69
|
+
dispose: () => {
|
|
70
|
+
this._markerService.remove(diagnosticOwner, [uri]);
|
|
71
|
+
dispose(listeners);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
_addDiagnostics(tm, value, tree, inConfig) {
|
|
76
|
+
const serversNode = findNodeAtLocation(tree, inConfig.section ? [...inConfig.section, 'servers'] : ['servers']);
|
|
77
|
+
if (!serversNode) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const getClosestMatchingVariable = (name) => {
|
|
81
|
+
let bestValue = '';
|
|
82
|
+
let bestDistance = Infinity;
|
|
83
|
+
for (const variable of this._configurationResolverService.resolvableVariables) {
|
|
84
|
+
const distance = computeLevenshteinDistance(name, variable);
|
|
85
|
+
if (distance < bestDistance) {
|
|
86
|
+
bestDistance = distance;
|
|
87
|
+
bestValue = variable;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return bestValue;
|
|
91
|
+
};
|
|
92
|
+
const diagnostics = [];
|
|
93
|
+
forEachPropertyWithReplacement(serversNode, node => {
|
|
94
|
+
const expr = ConfigurationResolverExpression.parse(node.value);
|
|
95
|
+
for (const { id, name, arg } of expr.unresolved()) {
|
|
96
|
+
if (!( this._configurationResolverService.resolvableVariables.has(name))) {
|
|
97
|
+
const position = value.indexOf(id, node.offset);
|
|
98
|
+
if (position === -1) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const start = tm.getPositionAt(position);
|
|
102
|
+
const end = tm.getPositionAt(position + id.length);
|
|
103
|
+
diagnostics.push({
|
|
104
|
+
severity: MarkerSeverity.Warning,
|
|
105
|
+
message: ( localize(
|
|
106
|
+
7618,
|
|
107
|
+
'Variable `{0}` not found, did you mean ${{1}}?',
|
|
108
|
+
name,
|
|
109
|
+
getClosestMatchingVariable(name) + (arg ? `:${arg}` : '')
|
|
110
|
+
)),
|
|
111
|
+
startLineNumber: start.lineNumber,
|
|
112
|
+
startColumn: start.column,
|
|
113
|
+
endLineNumber: end.lineNumber,
|
|
114
|
+
endColumn: end.column,
|
|
115
|
+
modelVersionId: tm.getVersionId(),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (diagnostics.length) {
|
|
121
|
+
this._markerService.changeOne(diagnosticOwner, tm.uri, diagnostics);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this._markerService.remove(diagnosticOwner, [tm.uri]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
_provideCodeLenses(model, onDidChangeCodeLens) {
|
|
128
|
+
const parsed = this._parseModel(model);
|
|
129
|
+
if (!parsed) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
const { tree, inConfig } = parsed;
|
|
133
|
+
const serversNode = findNodeAtLocation(tree, inConfig.section ? [...inConfig.section, 'servers'] : ['servers']);
|
|
134
|
+
if (!serversNode) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
const store = ( new DisposableStore());
|
|
138
|
+
const lenses = { lenses: [], dispose: () => store.dispose() };
|
|
139
|
+
const read = (observable) => {
|
|
140
|
+
store.add(Event.fromObservableLight(observable)(onDidChangeCodeLens));
|
|
141
|
+
return observable.get();
|
|
142
|
+
};
|
|
143
|
+
const collection = read(this._mcpRegistry.collections).find(c => isEqual(c.presentation?.origin, model.uri));
|
|
144
|
+
if (!collection) {
|
|
145
|
+
return lenses;
|
|
146
|
+
}
|
|
147
|
+
const mcpServers = read(this._mcpService.servers).filter(s => s.collection.id === collection.id);
|
|
148
|
+
for (const node of serversNode.children || []) {
|
|
149
|
+
if (node.type !== 'property' || node.children?.[0]?.type !== 'string') {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const name = node.children[0].value;
|
|
153
|
+
const server = mcpServers.find(s => s.definition.label === name);
|
|
154
|
+
if (!server) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const range = Range.fromPositions(model.getPositionAt(node.children[0].offset));
|
|
158
|
+
switch (read(server.connectionState).state) {
|
|
159
|
+
case McpConnectionState.Kind.Error:
|
|
160
|
+
lenses.lenses.push({
|
|
161
|
+
range,
|
|
162
|
+
command: {
|
|
163
|
+
id: ShowOutput.ID,
|
|
164
|
+
title: '$(error) ' + ( localize(7619, 'Error')),
|
|
165
|
+
arguments: [server.definition.id],
|
|
166
|
+
},
|
|
167
|
+
}, {
|
|
168
|
+
range,
|
|
169
|
+
command: {
|
|
170
|
+
id: RestartServer.ID,
|
|
171
|
+
title: ( localize(7620, "Restart")),
|
|
172
|
+
arguments: [server.definition.id],
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
break;
|
|
176
|
+
case McpConnectionState.Kind.Starting:
|
|
177
|
+
lenses.lenses.push({
|
|
178
|
+
range,
|
|
179
|
+
command: {
|
|
180
|
+
id: ShowOutput.ID,
|
|
181
|
+
title: '$(loading~spin) ' + ( localize(7621, 'Starting')),
|
|
182
|
+
arguments: [server.definition.id],
|
|
183
|
+
},
|
|
184
|
+
}, {
|
|
185
|
+
range,
|
|
186
|
+
command: {
|
|
187
|
+
id: StopServer.ID,
|
|
188
|
+
title: ( localize(7622, "Cancel")),
|
|
189
|
+
arguments: [server.definition.id],
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
break;
|
|
193
|
+
case McpConnectionState.Kind.Running:
|
|
194
|
+
lenses.lenses.push({
|
|
195
|
+
range,
|
|
196
|
+
command: {
|
|
197
|
+
id: ShowOutput.ID,
|
|
198
|
+
title: '$(check) ' + ( localize(7623, 'Running')),
|
|
199
|
+
arguments: [server.definition.id],
|
|
200
|
+
},
|
|
201
|
+
}, {
|
|
202
|
+
range,
|
|
203
|
+
command: {
|
|
204
|
+
id: StopServer.ID,
|
|
205
|
+
title: ( localize(7624, "Stop")),
|
|
206
|
+
arguments: [server.definition.id],
|
|
207
|
+
},
|
|
208
|
+
}, {
|
|
209
|
+
range,
|
|
210
|
+
command: {
|
|
211
|
+
id: RestartServer.ID,
|
|
212
|
+
title: ( localize(7620, "Restart")),
|
|
213
|
+
arguments: [server.definition.id],
|
|
214
|
+
},
|
|
215
|
+
}, {
|
|
216
|
+
range,
|
|
217
|
+
command: {
|
|
218
|
+
id: '',
|
|
219
|
+
title: ( localize(7625, '{0} tools', read(server.tools).length)),
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
break;
|
|
223
|
+
case McpConnectionState.Kind.Stopped: {
|
|
224
|
+
lenses.lenses.push({
|
|
225
|
+
range,
|
|
226
|
+
command: {
|
|
227
|
+
id: StartServer.ID,
|
|
228
|
+
title: '$(debug-start) ' + ( localize(7626, "Start")),
|
|
229
|
+
arguments: [server.definition.id],
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
const toolCount = read(server.tools).length;
|
|
233
|
+
if (toolCount) {
|
|
234
|
+
lenses.lenses.push({
|
|
235
|
+
range,
|
|
236
|
+
command: {
|
|
237
|
+
id: '',
|
|
238
|
+
title: ( localize(7627, '{0} cached tools', toolCount)),
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return lenses;
|
|
246
|
+
}
|
|
247
|
+
async _provideInlayHints(model, range) {
|
|
248
|
+
const parsed = this._parseModel(model);
|
|
249
|
+
if (!parsed) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
const { tree, inConfig } = parsed;
|
|
253
|
+
const mcpSection = inConfig.section ? findNodeAtLocation(tree, [...inConfig.section]) : tree;
|
|
254
|
+
if (!mcpSection) {
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
const inputsNode = findNodeAtLocation(mcpSection, ['inputs']);
|
|
258
|
+
if (!inputsNode) {
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
const inputs = await this._mcpRegistry.getSavedInputs(inConfig.scope);
|
|
262
|
+
const hints = [];
|
|
263
|
+
const serversNode = findNodeAtLocation(mcpSection, ['servers']);
|
|
264
|
+
if (serversNode) {
|
|
265
|
+
annotateServers(serversNode);
|
|
266
|
+
}
|
|
267
|
+
annotateInputs(inputsNode);
|
|
268
|
+
return { hints, dispose: () => { } };
|
|
269
|
+
function annotateServers(servers) {
|
|
270
|
+
forEachPropertyWithReplacement(servers, node => {
|
|
271
|
+
const expr = ConfigurationResolverExpression.parse(node.value);
|
|
272
|
+
for (const { id } of expr.unresolved()) {
|
|
273
|
+
const saved = inputs[id];
|
|
274
|
+
if (saved) {
|
|
275
|
+
pushAnnotation(id, node.offset + node.value.indexOf(id) + id.length, saved);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function annotateInputs(node) {
|
|
281
|
+
if (node.type !== 'array' || !node.children) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
for (const input of node.children) {
|
|
285
|
+
if (input.type !== 'object' || !input.children) {
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const idProp = input.children.find(c => c.type === 'property' && c.children?.[0].value === 'id');
|
|
289
|
+
if (!idProp) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const id = idProp.children[1];
|
|
293
|
+
if (!id || id.type !== 'string' || !id.value) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const savedId = '${input:' + id.value + '}';
|
|
297
|
+
const saved = inputs[savedId];
|
|
298
|
+
if (saved) {
|
|
299
|
+
pushAnnotation(savedId, id.offset + 1 + id.length, saved);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function pushAnnotation(savedId, offset, saved) {
|
|
304
|
+
const tooltip = ( new MarkdownString([
|
|
305
|
+
markdownCommandLink({ id: EditStoredInput.ID, title: ( localize(7628, 'Edit')), arguments: [savedId, model.uri, mcpConfigurationSection, inConfig.target] }),
|
|
306
|
+
markdownCommandLink({ id: RemoveStoredInput.ID, title: ( localize(7629, 'Clear')), arguments: [inConfig.scope, savedId] }),
|
|
307
|
+
markdownCommandLink({ id: RemoveStoredInput.ID, title: ( localize(7630, 'Clear All')), arguments: [inConfig.scope] }),
|
|
308
|
+
].join(' | '), { isTrusted: true }));
|
|
309
|
+
const hint = {
|
|
310
|
+
label: '= ' + (saved.input?.type === 'promptString' && saved.input.password ? '*'.repeat(10) : (saved.value || '')),
|
|
311
|
+
position: model.getPositionAt(offset),
|
|
312
|
+
tooltip,
|
|
313
|
+
paddingLeft: true,
|
|
314
|
+
};
|
|
315
|
+
hints.push(hint);
|
|
316
|
+
return hint;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
McpLanguageFeatures = ( __decorate([
|
|
321
|
+
( __param(0, ILanguageFeaturesService)),
|
|
322
|
+
( __param(1, IMcpRegistry)),
|
|
323
|
+
( __param(2, IMcpConfigPathsService)),
|
|
324
|
+
( __param(3, IMcpService)),
|
|
325
|
+
( __param(4, IMarkerService)),
|
|
326
|
+
( __param(5, IConfigurationResolverService))
|
|
327
|
+
], McpLanguageFeatures));
|
|
328
|
+
function forEachPropertyWithReplacement(node, callback) {
|
|
329
|
+
if (node.type === 'string' && typeof node.value === 'string' && node.value.includes(ConfigurationResolverExpression.VARIABLE_LHS)) {
|
|
330
|
+
callback(node);
|
|
331
|
+
}
|
|
332
|
+
else if (node.type === 'property') {
|
|
333
|
+
node.children?.slice(1).forEach(n => forEachPropertyWithReplacement(n, callback));
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
node.children?.forEach(n => forEachPropertyWithReplacement(n, callback));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { McpLanguageFeatures };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { ITextModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service";
|
|
3
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
4
|
+
import { IMcpConfigPathsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpConfigPathsService.service";
|
|
5
|
+
import { IMcpRegistry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service";
|
|
6
|
+
import { IMcpDiscovery } from "./mcpDiscovery.js";
|
|
7
|
+
export declare class ConfigMcpDiscovery extends Disposable implements IMcpDiscovery {
|
|
8
|
+
private readonly _configurationService;
|
|
9
|
+
private readonly _mcpRegistry;
|
|
10
|
+
private readonly _textModelService;
|
|
11
|
+
private readonly _mcpConfigPathsService;
|
|
12
|
+
private configSources;
|
|
13
|
+
constructor(_configurationService: IConfigurationService, _mcpRegistry: IMcpRegistry, _textModelService: ITextModelService, _mcpConfigPathsService: IMcpConfigPathsService);
|
|
14
|
+
start(): void;
|
|
15
|
+
private _getServerIdMapping;
|
|
16
|
+
private sync;
|
|
17
|
+
}
|