mcpTypesUtils.ts ×7

Frontier kind: Code frontier

unlabeled · c_b241200ff368

90 tests · 28988 LOC · 142 files · introduces 0 tests · 44 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
7 ranges44 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2803 ranges28988 lines · 142 files · Browse complete extent
All tests (intent)
90 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 44 introduced LOC across 7 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/mcp/common/mcpTypesUtils.ts 44 introduced LOC · 7 ranges

Open complete file

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();
44 });
45 }
47 > /**
48 > * Starts a server (if needed) and waits for its tools to be live. Returns
49 > * true/false whether this happened successfully.
50 > */
51 export async function startServerAndWaitForLiveTools(server: IMcpServer, opts?: IMcpServerStartOpts, token?: CancellationToken): Promise<boolean> {
52 const r = await server.start(opts);
84 return ok;
85 }
87 > export function mcpServerToSourceData(server: IMcpServer, reader?: IReader): ToolDataSource {
88 const metadata = server.serverMetadata.read(reader);
89 return {
96 };
97 }
99 >
100 > /**
101 > * Validates whether the given HTTP or HTTPS resource is allowed for the specified MCP server.
102 > *
103 > * @param resource The URI of the resource to validate.
104 > * @param server The MCP server instance to validate against, or undefined.
105 > * @returns True if the resource request is valid for the server, false otherwise.
106 > */
107 > export function canLoadMcpNetworkResourceDirectly(resource: URL, server: IMcpServer | undefined) {
108 let isResourceRequestValid = false;
109 if (resource.protocol === 'http:') {
117 return isResourceRequestValid;
118 }
120 > export function isTaskResult(obj: MCP.Result | MCP.CreateTaskResult): obj is MCP.CreateTaskResult {
121 return (obj as MCP.CreateTaskResult).task !== undefined;
122 }
124 > export function findMcpServer(mcpService: IMcpService, filter: (s: IMcpServer) => boolean, token?: CancellationToken) {
125 return new Promise<IMcpServer | undefined>((resolve) => {
126 autorunSelfDisposable(reader => {
147 });
148 }
150 > export function translateMcpLogMessage(logger: ILogger, params: MCP.LoggingMessageNotificationParams, prefix = '') {
151 let contents = typeof params.data === 'string' ? params.data : JSON.stringify(params.data);
152 if (params.logger) {