1
>
/*---------------------------------------------------------------------------------------------
mcpTypesUtils.ts
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 { disposableTimeout, timeout } from '../../../../base/common/async.js';
7
>
import { CancellationToken } from '../../../../base/common/cancellation.js';
8
>
import { CancellationError } from '../../../../base/common/errors.js';
9
>
import { DisposableStore } from '../../../../base/common/lifecycle.js';
10
>
import { autorun, autorunSelfDisposable, IReader } from '../../../../base/common/observable.js';
11
>
import { ILogger } from '../../../../platform/log/common/log.js';
12
>
import { ToolDataSource } from '../../chat/common/tools/languageModelToolsService.js';
13
>
import { IMcpServer, IMcpServerStartOpts, IMcpService, McpConnectionState, McpServerCacheState, McpServerTransportType } from './mcpTypes.js';
14
>
import { MCP } from './modelContextProtocol.js';
15
>
16
>
17
>
/**
18
>
* Waits up to `timeout` for a server passing the filter to be discovered,
19
>
* and then starts it.
20
>
*/
21
>
export function startServerByFilter(mcpService: IMcpService, filter: (s: IMcpServer) => boolean, timeout = 5000) {
22
return new Promise<void>((resolve, reject) => {
23
const store = new DisposableStore();