Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpRemoteDiscovery.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { ProxyChannel } from '../../../../../base/parts/ipc/common/ipc.js';
7
import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';
8
import { IFileService } from '../../../../../platform/files/common/files.js';
9
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
10
import { ILabelService } from '../../../../../platform/label/common/label.js';
11
import { ILogService } from '../../../../../platform/log/common/log.js';
12
import { INativeMcpDiscoveryHelperService, NativeMcpDiscoveryHelperChannelName } from '../../../../../platform/mcp/common/nativeMcpDiscoveryHelper.js';
13
import { IRemoteAgentService } from '../../../../services/remote/common/remoteAgentService.js';
14
import { IMcpRegistry } from '../mcpRegistryTypes.js';
15
import { NativeFilesystemMcpDiscovery } from './nativeMcpDiscoveryAbstract.js';
16
17
/**
18
* Discovers MCP servers on the remote filesystem, if any.
19
*/
20
export class RemoteNativeMpcDiscovery extends NativeFilesystemMcpDiscovery {
21
constructor(
22
@IRemoteAgentService private readonly remoteAgent: IRemoteAgentService,
23
@ILogService private readonly logService: ILogService,
24
@ILabelService labelService: ILabelService,
25
@IFileService fileService: IFileService,
26
@IInstantiationService instantiationService: IInstantiationService,
27
@IMcpRegistry mcpRegistry: IMcpRegistry,
28
@IConfigurationService configurationService: IConfigurationService,
29
) {
30
super(remoteAgent.getConnection()?.remoteAuthority || null, labelService, fileService, instantiationService, mcpRegistry, configurationService);
31
}
32
33
public override async start() {
34
const connection = this.remoteAgent.getConnection();
35
if (!connection) {
36
return this.setDetails(undefined);
37
}
38
39
await connection.withChannel(NativeMcpDiscoveryHelperChannelName, async channel => {
40
const service = ProxyChannel.toService<INativeMcpDiscoveryHelperService>(channel);
41
42
service.load().then(
43
data => this.setDetails(data),
44
err => {
45
this.logService.warn('Error getting remote process MCP environment', err);
46
this.setDetails(undefined);
47
}
48
);
49
});
50
}
51
}
52
53