Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/mcp/common/mcpGalleryManifest.ts
3294 views
1
/*---------------------------------------------------------------------------------------------
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 { Event } from '../../../base/common/event.js';
7
import { createDecorator } from '../../instantiation/common/instantiation.js';
8
9
export const enum McpGalleryResourceType {
10
McpQueryService = 'McpQueryService',
11
McpServerManifestUri = 'McpServerManifestUriTemplate',
12
}
13
14
export type McpGalleryManifestResource = {
15
readonly id: string;
16
readonly type: string;
17
};
18
19
export interface IMcpGalleryManifest {
20
readonly version?: string;
21
readonly url: string;
22
readonly resources: readonly McpGalleryManifestResource[];
23
}
24
25
export const enum McpGalleryManifestStatus {
26
Available = 'available',
27
Unavailable = 'unavailable'
28
}
29
30
export const IMcpGalleryManifestService = createDecorator<IMcpGalleryManifestService>('IMcpGalleryManifestService');
31
32
export interface IMcpGalleryManifestService {
33
readonly _serviceBrand: undefined;
34
35
readonly mcpGalleryManifestStatus: McpGalleryManifestStatus;
36
readonly onDidChangeMcpGalleryManifestStatus: Event<McpGalleryManifestStatus>;
37
readonly onDidChangeMcpGalleryManifest: Event<IMcpGalleryManifest | null>;
38
getMcpGalleryManifest(): Promise<IMcpGalleryManifest | null>;
39
}
40
41
export function getMcpGalleryManifestResourceUri(manifest: IMcpGalleryManifest, type: string): string | undefined {
42
const [name, version] = type.split('/');
43
for (const resource of manifest.resources) {
44
const [r, v] = resource.type.split('/');
45
if (r !== name) {
46
continue;
47
}
48
if (!version || v === version) {
49
return resource.id;
50
}
51
break;
52
}
53
return undefined;
54
}
55
56