Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/mcp/electron-browser/mcpDevModeDebuggingNode.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 { timeout } from '../../../../base/common/async.js';
7
import { ICommandService } from '../../../../platform/commands/common/commands.js';
8
import { INativeHostService } from '../../../../platform/native/common/native.js';
9
import { IDebugService } from '../../debug/common/debug.js';
10
import { McpDevModeDebugging } from '../common/mcpDevMode.js';
11
12
export class McpDevModeDebuggingNode extends McpDevModeDebugging {
13
constructor(
14
@IDebugService debugService: IDebugService,
15
@ICommandService commandService: ICommandService,
16
@INativeHostService private readonly _nativeHostService: INativeHostService,
17
) {
18
super(debugService, commandService);
19
}
20
21
protected override async ensureListeningOnPort(port: number): Promise<void> {
22
const deadline = Date.now() + 30_000;
23
while (await this._nativeHostService.isPortFree(port) && Date.now() < deadline) {
24
await timeout(50);
25
}
26
}
27
28
protected override getDebugPort() {
29
return this._nativeHostService.findFreePort(5000, 10 /* try 10 ports */, 5000 /* try up to 5 seconds */, 2048 /* skip 2048 ports between attempts */);
30
}
31
}
32
33