extHostMcpNode.ts ×8

Frontier kind: Joint frontier

unlabeled · c_a69039ec0a16

6 tests · 83997 LOC · 317 files · introduces 6 tests · 45 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges45 lines · 1 files
Tests
6 tests

Contains — complete concept membership

All code (extent)
5928 ranges83997 lines · 317 files · Browse complete extent
All tests (intent)
6 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.

6 tests introduced at this concept.

Introduced code

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

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

src/vs/workbench/api/node/extHostMcpNode.ts 45 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- extHostMcpNode.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 { ChildProcessWithoutNullStreams, spawn } from 'child_process';
7 > import { readFile } from 'fs/promises';
8 > import { homedir } from 'os';
9 > import type { RequestInit as UndiciRequestInit } from 'undici';
10 > import { parseEnvFile } from '../../../base/common/envfile.js';
11 > import { untildify } from '../../../base/common/labels.js';
12 > import { Lazy } from '../../../base/common/lazy.js';
13 > import { DisposableMap } from '../../../base/common/lifecycle.js';
14 > import * as path from '../../../base/common/path.js';
15 > import { URI } from '../../../base/common/uri.js';
16 > import { StreamSplitter } from '../../../base/node/nodeStreams.js';
17 > import { findExecutable } from '../../../base/node/processes.js';
18 > import { LogLevel } from '../../../platform/log/common/log.js';
19 > import { McpConnectionState, McpServerLaunch, McpServerTransportStdio, McpServerTransportType } from '../../contrib/mcp/common/mcpTypes.js';
20 > import { McpStdioStateHandler } from '../../contrib/mcp/node/mcpStdioStateHandler.js';
21 > import { CommonRequestInit, CommonResponse, ExtHostMcpService, McpHTTPHandle } from '../common/extHostMcp.js';
22 >
23 > export class NodeExtHostMpcService extends ExtHostMcpService {
24 private nodeServers = this._register(new DisposableMap<number, McpStdioStateHandler>());
26 > protected override _startMcp(id: number, launch: McpServerLaunch, defaultCwd?: URI, errorOnUserInteraction?: boolean): void {
27 if (launch.type === McpServerTransportType.Stdio) {
28 this.startNodeMpc(id, launch, defaultCwd);
33 }
34 }
36 > override $stopMcp(id: number): void {
37 const nodeServer = this.nodeServers.get(id);
38 if (nodeServer) {
42 }
43 }
45 > override $sendMessage(id: number, message: string): void {
46 const nodeServer = this.nodeServers.get(id);
47 if (nodeServer) {
51 }
52 }
54 > private async startNodeMpc(id: number, launch: McpServerTransportStdio, defaultCwd?: URI): Promise<void> {
55 const onError = (err: Error | string) => this._proxy.$onDidChangeState(id, {
56 state: McpConnectionState.Kind.Error,
143 this.nodeServers.set(id, connectionManager);
144 }
146 >
147 class McpHTTPHandleNode extends McpHTTPHandle {
148 private readonly _undici = new Lazy(() => import('undici'));
150 > protected override async _fetchInternal(url: string, init?: CommonRequestInit): Promise<CommonResponse> {
151 // Note: imported async so that we can ensure we load undici after proxy patches have been applied
152 const { fetch, Agent } = await this._undici.value;
186 };
187 }
189 >
190 > const windowsShellScriptRe = /\.(bat|cmd)$/i;
191 >
192 > export const escapeCmdArg = (s: string): string => `"${s.replace(/"/g, '""')}"`;
193 >
194 > /**
195 > * Formats arguments to avoid issues on Windows for CVE-2024-27980.
196 > */
197 > export const formatSubprocessArguments = async (
198 executable: string,
199 args: ReadonlyArray<string>,