nativeMcpDiscoveryAdapters.ts ×9

Frontier kind: Joint frontier

unlabeled · c_0814a0907437

1 test · 25113 LOC · 130 files · introduces 1 test · 92 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges92 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
2579 ranges25113 lines · 130 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

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

2 files ranked by introduced lines: 92 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.ts 89 introduced LOC · 9 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- nativeMcpDiscoveryAdapters.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 { VSBuffer } from '../../../../../base/common/buffer.js';
7 > import { Platform } from '../../../../../base/common/platform.js';
8 > import { Mutable } from '../../../../../base/common/types.js';
9 > import { URI } from '../../../../../base/common/uri.js';
10 > import { INativeMcpDiscoveryData } from '../../../../../platform/mcp/common/nativeMcpDiscoveryHelper.js';
11 > import { DiscoverySource } from '../mcpConfiguration.js';
12 > import { McpCollectionSortOrder, McpServerDefinition, McpServerLaunch, McpServerTransportType } from '../mcpTypes.js';
13 >
14 > export interface NativeMpcDiscoveryAdapter {
15 > readonly remoteAuthority: string | null;
16 > readonly id: string;
17 > readonly order: number;
18 > readonly discoverySource: DiscoverySource;
19 >
20 > getFilePath(details: INativeMcpDiscoveryData): URI | undefined;
21 > adaptFile(contents: VSBuffer, details: INativeMcpDiscoveryData): Promise<McpServerDefinition[] | undefined>;
22 > }
23 >
24 > export async function claudeConfigToServerDefinition(idPrefix: string, contents: VSBuffer, cwd?: URI) {
25 > let parsed: {
26 > mcpServers: Record<string, {
27 > command: string;
28 > args?: string[];
29 > env?: Record<string, string>;
30 > url?: string;
31 > headers?: Record<string, string>;
32 > }>;
33 > };
34 >
35 > try {
36 > parsed = JSON.parse(contents.toString());
37 > } catch {
38 return;
39 }
41 > return Promise.all(Object.entries(parsed.mcpServers).map(async ([name, server]): Promise<Mutable<McpServerDefinition>> => {
42 > const launch: McpServerLaunch = server.url ? {
43 > type: McpServerTransportType.HTTP,
44 > uri: URI.parse(server.url),
45 > headers: Object.entries(server.headers ?? {}),
46 > } : {
47 > type: McpServerTransportType.Stdio,
48 > args: server.args || [],
49 > command: server.command,
50 > env: server.env || {},
51 > envFile: undefined,
52 > cwd: cwd?.fsPath,
53 > sandbox: undefined
54 > };
55 >
56 > return {
57 > id: `${idPrefix}.${name}`,
58 > label: name,
59 > launch,
60 > cacheNonce: await McpServerLaunch.hash(launch),
61 > };
62 > }));
63 > }
64 >
65 > export class ClaudeDesktopMpcDiscoveryAdapter implements NativeMpcDiscoveryAdapter {
66 > public id: string;
67 > public readonly order = McpCollectionSortOrder.Filesystem;
68 > public readonly discoverySource: DiscoverySource = DiscoverySource.ClaudeDesktop;
69 >
70 > constructor(public readonly remoteAuthority: string | null) {
71 this.id = `claude-desktop.${this.remoteAuthority}`;
72 }
74 > getFilePath({ platform, winAppData, xdgHome, homedir }: INativeMcpDiscoveryData): URI | undefined {
75 if (platform === Platform.Windows) {
76 const appData = winAppData || URI.joinPath(homedir, 'AppData', 'Roaming');
83 }
84 }
86 > adaptFile(contents: VSBuffer, { homedir }: INativeMcpDiscoveryData): Promise<McpServerDefinition[] | undefined> {
87 return claudeConfigToServerDefinition(this.id, contents, homedir);
88 }
90 >
91 > export class WindsurfDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
92 > public override readonly discoverySource: DiscoverySource = DiscoverySource.Windsurf;
93 >
94 > constructor(remoteAuthority: string | null) {
95 super(remoteAuthority);
96 this.id = `windsurf.${this.remoteAuthority}`;
97 }
99 > override getFilePath({ homedir }: INativeMcpDiscoveryData): URI | undefined {
100 return URI.joinPath(homedir, '.codeium', 'windsurf', 'mcp_config.json');
101 }
103 >
104 > export class CursorDesktopMpcDiscoveryAdapter extends ClaudeDesktopMpcDiscoveryAdapter {
105 > public override readonly discoverySource: DiscoverySource = DiscoverySource.CursorGlobal;
106 >
107 > constructor(remoteAuthority: string | null) {
108 super(remoteAuthority);
109 this.id = `cursor.${this.remoteAuthority}`;
110 }
112 > override getFilePath({ homedir }: INativeMcpDiscoveryData): URI | undefined {
113 return URI.joinPath(homedir, '.cursor', 'mcp.json');
114 }
src/vs/workbench/contrib/mcp/common/mcpTypes.ts 3 introduced LOC · 1 range

Open complete file

666
667 export async function hash(launch: McpServerLaunch): Promise<string> {
668 > const nonce = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(launch))); mcpTypes.ts
669 > return encodeHex(VSBuffer.wrap(new Uint8Array(nonce)));
670 > }
671 }
672