Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/mcp/node/nativeMcpDiscoveryHelperChannel.ts
3294 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 { Event } from '../../../base/common/event.js';
7
import { IURITransformer, transformOutgoingURIs } from '../../../base/common/uriIpc.js';
8
import { IServerChannel } from '../../../base/parts/ipc/common/ipc.js';
9
import { INativeMcpDiscoveryHelperService } from '../common/nativeMcpDiscoveryHelper.js';
10
11
export class NativeMcpDiscoveryHelperChannel implements IServerChannel {
12
13
constructor(
14
private getUriTransformer: undefined | ((requestContext: any) => IURITransformer),
15
@INativeMcpDiscoveryHelperService private nativeMcpDiscoveryHelperService: INativeMcpDiscoveryHelperService
16
) { }
17
18
listen(context: any, event: string): Event<any> {
19
throw new Error('Invalid listen');
20
}
21
22
async call(context: any, command: string, args?: any): Promise<any> {
23
const uriTransformer = this.getUriTransformer?.(context);
24
switch (command) {
25
case 'load': {
26
const result = await this.nativeMcpDiscoveryHelperService.load();
27
return uriTransformer ? transformOutgoingURIs(result, uriTransformer) : result;
28
}
29
}
30
throw new Error('Invalid call');
31
}
32
}
33
34
35