Path: blob/main/src/vs/platform/mcp/common/mcpGalleryManifest.ts
5316 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Event } from '../../../base/common/event.js';6import { createDecorator } from '../../instantiation/common/instantiation.js';78export const enum McpGalleryResourceType {9McpServersQueryService = 'McpServersQueryService',10McpServerWebUri = 'McpServerWebUriTemplate',11McpServerVersionUri = 'McpServerVersionUriTemplate',12McpServerIdUri = 'McpServerIdUriTemplate',13McpServerLatestVersionUri = 'McpServerLatestVersionUriTemplate',14McpServerNamedResourceUri = 'McpServerNamedResourceUriTemplate',15PublisherUriTemplate = 'PublisherUriTemplate',16ContactSupportUri = 'ContactSupportUri',17PrivacyPolicyUri = 'PrivacyPolicyUri',18TermsOfServiceUri = 'TermsOfServiceUri',19ReportUri = 'ReportUri',20}2122export type McpGalleryManifestResource = {23readonly id: string;24readonly type: string;25};2627export interface IMcpGalleryManifest {28readonly version: string;29readonly url: string;30readonly resources: readonly McpGalleryManifestResource[];31}3233export const enum McpGalleryManifestStatus {34Available = 'available',35Unavailable = 'unavailable'36}3738export const IMcpGalleryManifestService = createDecorator<IMcpGalleryManifestService>('IMcpGalleryManifestService');3940export interface IMcpGalleryManifestService {41readonly _serviceBrand: undefined;4243readonly mcpGalleryManifestStatus: McpGalleryManifestStatus;44readonly onDidChangeMcpGalleryManifestStatus: Event<McpGalleryManifestStatus>;45readonly onDidChangeMcpGalleryManifest: Event<IMcpGalleryManifest | null>;46getMcpGalleryManifest(): Promise<IMcpGalleryManifest | null>;47}4849export function getMcpGalleryManifestResourceUri(manifest: IMcpGalleryManifest, type: string): string | undefined {50const [name, version] = type.split('/');51for (const resource of manifest.resources) {52const [r, v] = resource.type.split('/');53if (r !== name) {54continue;55}56if (!version || v === version) {57return resource.id;58}59break;60}61return undefined;62}636465