mcpManagementService.ts ×10

Frontier kind: Code frontier

unlabeled · c_7e9cc79f94d9

2 tests · 16813 LOC · 69 files · introduces 0 tests · 82 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges82 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2533 ranges16813 lines · 69 files · Browse complete extent
All tests (intent)
2 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.

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

src/vs/platform/mcp/common/mcpManagementService.ts 54 introduced LOC · 10 ranges

Open complete file

373 const scannedMcpServers = await this.mcpResourceScannerService.scanMcpServers(this.mcpResource, this.target);
374 if (scannedMcpServers.servers) {
375 > await Promise.allSettled(Object.entries(scannedMcpServers.servers).map(async ([name, scannedServer]) => { mcpManagementService.ts
376 > const server = await this.scanLocalServer(name, scannedServer, scannedMcpServers.sandbox);
377 > local.set(name, server);
378 > }));
379 > }
380 } catch (error) {
381 this.logService.debug('Could not read user MCP servers:', error);
395
396 protected async updateLocal(): Promise<void> {
398 > const current = await this.populateLocalServers();
399 >
400 > const added: ILocalMcpServer[] = [];
401 > const updated: ILocalMcpServer[] = [];
402 > const removed = [...this.local.keys()].filter(name => !current.has(name));
403 >
404 > for (const server of removed) {
405 this.local.delete(server);
406 }
408 > for (const [name, server] of current) {
409 > const previous = this.local.get(name);
410 > if (previous) {
411 if (!equals(previous, server)) {
412 updated.push(server);
413 this.local.set(name, server);
414 }
415 > } else { mcpManagementService.ts
416 added.push(server);
417 this.local.set(name, server);
418 }
420 >
421 > for (const server of removed) {
422 this.local.delete(server);
423 this._onDidUninstallMcpServer.fire({ name: server, mcpResource: this.mcpResource });
424 }
426 > if (updated.length) {
427 this._onDidUpdateMcpServers.fire(updated.map(server => ({ name: server.name, local: server, mcpResource: this.mcpResource })));
428 }
430 > if (added.length) {
431 this._onDidInstallMcpServers.fire(added.map(server => ({ name: server.name, local: server, mcpResource: this.mcpResource })));
432 }
434 > } catch (error) {
435 this.logService.error('Failed to load installed MCP servers:', error);
436 }
438
439 async getInstalled(): Promise<ILocalMcpServer[]> {
443
444 protected async scanLocalServer(name: string, config: IMcpServerConfiguration, rootSandbox?: IMcpSandboxConfiguration): Promise<ILocalMcpServer> {
445 > let mcpServerInfo = await this.getLocalServerInfo(name, config); mcpManagementService.ts
446 > if (!mcpServerInfo) {
447 > mcpServerInfo = { name, version: config.version, galleryUrl: isString(config.gallery) ? config.gallery : undefined };
448 > }
449 >
450 > return {
451 > name,
452 > config,
453 > rootSandbox,
454 > mcpResource: this.mcpResource,
455 > version: mcpServerInfo.version,
456 > location: mcpServerInfo.location,
457 > displayName: mcpServerInfo.displayName,
458 > description: mcpServerInfo.description,
459 > publisher: mcpServerInfo.publisher,
460 > publisherDisplayName: mcpServerInfo.publisherDisplayName,
461 > galleryUrl: mcpServerInfo.galleryUrl,
462 > galleryId: mcpServerInfo.galleryId,
463 > repositoryUrl: mcpServerInfo.repositoryUrl,
464 > readmeUrl: mcpServerInfo.readmeUrl,
465 > icon: mcpServerInfo.icon,
466 > codicon: mcpServerInfo.codicon,
467 > manifest: mcpServerInfo.manifest,
468 > source: config.gallery ? 'gallery' : 'local'
469 > };
470 > }
471
472 async install(server: IInstallableMcpServer, options?: Omit<InstallOptions, 'mcpResource'>): Promise<ILocalMcpServer> {
src/vs/platform/mcp/common/mcpResourceScannerService.ts 28 introduced LOC · 6 ranges

Open complete file

106 try {
107 const content = await this.fileService.readFile(mcpResource);
108 > const errors: ParseError[] = []; mcpResourceScannerService.ts
109 > const result = parse(content.value.toString(), errors, { allowTrailingComma: true, allowEmptyContent: true }) || {};
110 if (errors.length > 0) {
111 throw new Error('Failed to parse scanned MCP servers: ' + errors.join(', '));
112 }
114 > if (target === ConfigurationTarget.USER) {
115 > scannedMcpServers = this.fromUserMcpServers(result);
116 > } else if (target === ConfigurationTarget.WORKSPACE_FOLDER) {
117 scannedMcpServers = this.fromWorkspaceFolderMcpServers(result);
118 } else if (target === ConfigurationTarget.WORKSPACE) {
181
182 private fromUserMcpServers(scannedMcpServers: IScannedMcpServers): IScannedMcpServers {
183 > const userMcpServers: IScannedMcpServers = { mcpResourceScannerService.ts
184 > inputs: scannedMcpServers.inputs,
185 > sandbox: scannedMcpServers.sandbox
186 > };
187 > const servers = Object.entries(scannedMcpServers.servers ?? {});
188 > if (servers.length > 0) {
189 > userMcpServers.servers = {};
190 > for (const [serverName, server] of servers) {
191 > userMcpServers.servers[serverName] = this.sanitizeServer(server);
192 > }
193 > }
194 > return userMcpServers;
195 > }
196
197 private fromWorkspaceFolderMcpServers(scannedWorkspaceFolderMcpServers: IScannedMcpServers): IScannedMcpServers {
212
213 private sanitizeServer(serverOrConfig: IOldScannedMcpServer | Mutable<IMcpServerConfiguration>): IMcpServerConfiguration {
214 > let server: IMcpServerConfiguration; mcpResourceScannerService.ts
215 > if ((<IOldScannedMcpServer>serverOrConfig).config) {
216 const oldScannedMcpServer = <IOldScannedMcpServer>serverOrConfig;
217 server = {
220 gallery: oldScannedMcpServer.gallery
221 };
223 > server = serverOrConfig as IMcpServerConfiguration;
224 > }
225 >
226 > if (server.type === undefined || (server.type !== McpServerType.REMOTE && server.type !== McpServerType.LOCAL)) {
227 (<Mutable<ICommonMcpServerConfiguration>>server).type = (<IMcpStdioServerConfiguration>server).command ? McpServerType.LOCAL : McpServerType.REMOTE;
228 }
229 > return server; mcpResourceScannerService.ts
230 > }
231
232 private getResourceAccessQueue(file: URI): Queue<IScannedMcpServers> {