Path: blob/main/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpRemoteDiscovery.ts
3296 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 { ProxyChannel } from '../../../../../base/parts/ipc/common/ipc.js';6import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';7import { IFileService } from '../../../../../platform/files/common/files.js';8import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';9import { ILabelService } from '../../../../../platform/label/common/label.js';10import { ILogService } from '../../../../../platform/log/common/log.js';11import { INativeMcpDiscoveryHelperService, NativeMcpDiscoveryHelperChannelName } from '../../../../../platform/mcp/common/nativeMcpDiscoveryHelper.js';12import { IRemoteAgentService } from '../../../../services/remote/common/remoteAgentService.js';13import { IMcpRegistry } from '../mcpRegistryTypes.js';14import { NativeFilesystemMcpDiscovery } from './nativeMcpDiscoveryAbstract.js';1516/**17* Discovers MCP servers on the remote filesystem, if any.18*/19export class RemoteNativeMpcDiscovery extends NativeFilesystemMcpDiscovery {20constructor(21@IRemoteAgentService private readonly remoteAgent: IRemoteAgentService,22@ILogService private readonly logService: ILogService,23@ILabelService labelService: ILabelService,24@IFileService fileService: IFileService,25@IInstantiationService instantiationService: IInstantiationService,26@IMcpRegistry mcpRegistry: IMcpRegistry,27@IConfigurationService configurationService: IConfigurationService,28) {29super(remoteAgent.getConnection()?.remoteAuthority || null, labelService, fileService, instantiationService, mcpRegistry, configurationService);30}3132public override async start() {33const connection = this.remoteAgent.getConnection();34if (!connection) {35return this.setDetails(undefined);36}3738await connection.withChannel(NativeMcpDiscoveryHelperChannelName, async channel => {39const service = ProxyChannel.toService<INativeMcpDiscoveryHelperService>(channel);4041service.load().then(42data => this.setDetails(data),43err => {44this.logService.warn('Error getting remote process MCP environment', err);45this.setDetails(undefined);46}47);48});49}50}515253