Path: blob/main/src/vs/platform/mcp/node/nativeMcpDiscoveryHelperChannel.ts
5241 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 { RemoteAgentConnectionContext } from '../../remote/common/remoteAgentEnvironment.js';9import { INativeMcpDiscoveryHelperService } from '../common/nativeMcpDiscoveryHelper.js';1011export class NativeMcpDiscoveryHelperChannel implements IServerChannel<RemoteAgentConnectionContext> {1213constructor(14private readonly getUriTransformer: undefined | ((requestContext: RemoteAgentConnectionContext) => IURITransformer),15@INativeMcpDiscoveryHelperService private nativeMcpDiscoveryHelperService: INativeMcpDiscoveryHelperService16) { }1718listen<T>(context: RemoteAgentConnectionContext, event: string): Event<T> {19throw new Error('Invalid listen');20}2122async call<T>(context: RemoteAgentConnectionContext, command: string, args?: unknown): Promise<T> {23const uriTransformer = this.getUriTransformer?.(context);24switch (command) {25case 'load': {26const result = await this.nativeMcpDiscoveryHelperService.load();27return (uriTransformer ? transformOutgoingURIs(result, uriTransformer) : result) as T;28}29}30throw new Error('Invalid call');31}32}33343536