Path: blob/main/src/vs/platform/mcp/common/mcpGalleryManifest.ts
3294 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 {9McpQueryService = 'McpQueryService',10McpServerManifestUri = 'McpServerManifestUriTemplate',11}1213export type McpGalleryManifestResource = {14readonly id: string;15readonly type: string;16};1718export interface IMcpGalleryManifest {19readonly version?: string;20readonly url: string;21readonly resources: readonly McpGalleryManifestResource[];22}2324export const enum McpGalleryManifestStatus {25Available = 'available',26Unavailable = 'unavailable'27}2829export const IMcpGalleryManifestService = createDecorator<IMcpGalleryManifestService>('IMcpGalleryManifestService');3031export interface IMcpGalleryManifestService {32readonly _serviceBrand: undefined;3334readonly mcpGalleryManifestStatus: McpGalleryManifestStatus;35readonly onDidChangeMcpGalleryManifestStatus: Event<McpGalleryManifestStatus>;36readonly onDidChangeMcpGalleryManifest: Event<IMcpGalleryManifest | null>;37getMcpGalleryManifest(): Promise<IMcpGalleryManifest | null>;38}3940export function getMcpGalleryManifestResourceUri(manifest: IMcpGalleryManifest, type: string): string | undefined {41const [name, version] = type.split('/');42for (const resource of manifest.resources) {43const [r, v] = resource.type.split('/');44if (r !== name) {45continue;46}47if (!version || v === version) {48return resource.id;49}50break;51}52return undefined;53}545556