Path: blob/main/src/vs/platform/mcp/node/nativeMcpDiscoveryHelperChannel.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 { IURITransformer, transformOutgoingURIs } from '../../../base/common/uriIpc.js';7import { IServerChannel } from '../../../base/parts/ipc/common/ipc.js';8import { INativeMcpDiscoveryHelperService } from '../common/nativeMcpDiscoveryHelper.js';910export class NativeMcpDiscoveryHelperChannel implements IServerChannel {1112constructor(13private getUriTransformer: undefined | ((requestContext: any) => IURITransformer),14@INativeMcpDiscoveryHelperService private nativeMcpDiscoveryHelperService: INativeMcpDiscoveryHelperService15) { }1617listen(context: any, event: string): Event<any> {18throw new Error('Invalid listen');19}2021async call(context: any, command: string, args?: any): Promise<any> {22const uriTransformer = this.getUriTransformer?.(context);23switch (command) {24case 'load': {25const result = await this.nativeMcpDiscoveryHelperService.load();26return uriTransformer ? transformOutgoingURIs(result, uriTransformer) : result;27}28}29throw new Error('Invalid call');30}31}32333435