1
>
/*---------------------------------------------------------------------------------------------
mcpManagementService.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { RunOnceScheduler } from '../../../base/common/async.js';
7
>
import { VSBuffer } from '../../../base/common/buffer.js';
8
>
import { CancellationToken } from '../../../base/common/cancellation.js';
9
>
import { Emitter, Event } from '../../../base/common/event.js';
10
>
import { IMarkdownString, MarkdownString } from '../../../base/common/htmlContent.js';
11
>
import { Disposable, DisposableStore, IDisposable } from '../../../base/common/lifecycle.js';
12
>
import { ResourceMap } from '../../../base/common/map.js';
13
>
import { equals } from '../../../base/common/objects.js';
14
>
import { isString } from '../../../base/common/types.js';
15
>
import { URI } from '../../../base/common/uri.js';
16
>
import { localize } from '../../../nls.js';
17
>
import { ConfigurationTarget } from '../../configuration/common/configuration.js';
18
>
import { IEnvironmentService } from '../../environment/common/environment.js';
19
>
import { IFileService } from '../../files/common/files.js';
20
>
import { IInstantiationService } from '../../instantiation/common/instantiation.js';
21
>
import { ILogService } from '../../log/common/log.js';
22
>
import { IUriIdentityService } from '../../uriIdentity/common/uriIdentity.js';
23
>
import { IUserDataProfilesService } from '../../userDataProfile/common/userDataProfile.js';
24
>
import { DidUninstallMcpServerEvent, IGalleryMcpServer, ILocalMcpServer, IMcpGalleryService, IMcpManagementService, IMcpServerInput, IGalleryMcpServerConfiguration, InstallMcpServerEvent, InstallMcpServerResult, RegistryType, UninstallMcpServerEvent, InstallOptions, UninstallOptions, IInstallableMcpServer, IAllowedMcpServersService, IMcpServerArgument, IMcpServerKeyValueInput, McpServerConfigurationParseResult } from './mcpManagement.js';
25
>
import { IMcpSandboxConfiguration, IMcpServerVariable, McpServerVariableType, IMcpServerConfiguration, McpServerType } from './mcpPlatformTypes.js';
26
>
import { IMcpResourceScannerService, McpResourceTarget } from './mcpResourceScannerService.js';
27
>
28
>
export interface ILocalMcpServerInfo {
29
>
name: string;
30
>
version?: string;
31
>
displayName?: string;
32
>
galleryId?: string;
33
>
galleryUrl?: string;
34
>
description?: string;
35
>
repositoryUrl?: string;
36
>
publisher?: string;
37
>
publisherDisplayName?: string;
38
>
icon?: {
39
>
dark: string;
40
>
light: string;
41
>
};
42
>
codicon?: string;
43
>
manifest?: IGalleryMcpServerConfiguration;
44
>
readmeUrl?: URI;
45
>
location?: URI;
46
>
licenseUrl?: string;
47
>
}
48
>
49
>
export abstract class AbstractCommonMcpManagementService extends Disposable implements IMcpManagementService {
50
>
51
>
_serviceBrand: undefined;
52
>
53
>
abstract onInstallMcpServer: Event<InstallMcpServerEvent>;
54
>
abstract onDidInstallMcpServers: Event<readonly InstallMcpServerResult[]>;
55
>
abstract onDidUpdateMcpServers: Event<readonly InstallMcpServerResult[]>;
56
>
abstract onUninstallMcpServer: Event<UninstallMcpServerEvent>;
57
>
abstract onDidUninstallMcpServer: Event<DidUninstallMcpServerEvent>;
58
>
59
>
abstract getInstalled(mcpResource?: URI): Promise<ILocalMcpServer[]>;
60
>
abstract install(server: IInstallableMcpServer, options?: InstallOptions): Promise<ILocalMcpServer>;
61
>
abstract installFromGallery(server: IGalleryMcpServer, options?: InstallOptions): Promise<ILocalMcpServer>;
62
>
abstract updateMetadata(local: ILocalMcpServer, server: IGalleryMcpServer, profileLocation?: URI): Promise<ILocalMcpServer>;
63
>
abstract uninstall(server: ILocalMcpServer, options?: UninstallOptions): Promise<void>;
64
>
abstract canInstall(server: IGalleryMcpServer | IInstallableMcpServer): true | IMarkdownString;
65
>
66
>
constructor(
67
@ILogService protected readonly logService: ILogService
68
) {
69
super();
70
}
72
>
getMcpServerConfigurationFromManifest(manifest: IGalleryMcpServerConfiguration, packageType: RegistryType): McpServerConfigurationParseResult {
73
74
// remote