Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/mcp/common/mcpGalleryManifestService.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 { Disposable } from '../../../base/common/lifecycle.js';
8
import { IProductService } from '../../product/common/productService.js';
9
import { McpGalleryResourceType, IMcpGalleryManifest, IMcpGalleryManifestService, McpGalleryManifestStatus } from './mcpGalleryManifest.js';
10
11
export class McpGalleryManifestService extends Disposable implements IMcpGalleryManifestService {
12
13
readonly _serviceBrand: undefined;
14
readonly onDidChangeMcpGalleryManifest = Event.None;
15
readonly onDidChangeMcpGalleryManifestStatus = Event.None;
16
17
get mcpGalleryManifestStatus(): McpGalleryManifestStatus {
18
return !!this.productService.mcpGallery?.serviceUrl ? McpGalleryManifestStatus.Available : McpGalleryManifestStatus.Unavailable;
19
}
20
21
constructor(
22
@IProductService protected readonly productService: IProductService,
23
) {
24
super();
25
}
26
27
async getMcpGalleryManifest(): Promise<IMcpGalleryManifest | null> {
28
if (!this.productService.mcpGallery) {
29
return null;
30
}
31
return this.createMcpGalleryManifest(this.productService.mcpGallery.serviceUrl);
32
}
33
34
protected createMcpGalleryManifest(url: string): IMcpGalleryManifest {
35
url = url.endsWith('/') ? url.slice(0, -1) : url;
36
const isVSCodeGalleryUrl = this.productService.extensionsGallery?.mcpUrl === url;
37
const version = isVSCodeGalleryUrl ? undefined : 'v0';
38
const serversUrl = isVSCodeGalleryUrl ? url : `${url}/${version}/servers`;
39
const resources = [
40
{
41
id: serversUrl,
42
type: McpGalleryResourceType.McpQueryService
43
}
44
];
45
if (!isVSCodeGalleryUrl) {
46
resources.push({
47
id: `${serversUrl}/{id}`,
48
type: McpGalleryResourceType.McpServerManifestUri
49
});
50
}
51
return {
52
version,
53
url,
54
resources
55
};
56
}
57
}
58
59