mcpManagementService.ts ×8

Frontier kind: Code frontier

unlabeled · c_9c56db439caa

3 tests · 15940 LOC · 69 files · introduces 0 tests · 64 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges64 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2248 ranges15940 lines · 69 files · Browse complete extent
All tests (intent)
3 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: 64 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/mcp/common/mcpManagementService.ts 38 introduced LOC · 8 ranges

Open complete file

327
328 constructor(
329 > protected readonly mcpResource: URI, mcpManagementService.ts
330 > protected readonly target: McpResourceTarget,
331 > @IMcpGalleryService protected readonly mcpGalleryService: IMcpGalleryService,
332 > @IFileService protected readonly fileService: IFileService,
333 > @IUriIdentityService protected readonly uriIdentityService: IUriIdentityService,
334 > @ILogService logService: ILogService,
335 > @IMcpResourceScannerService protected readonly mcpResourceScannerService: IMcpResourceScannerService,
336 > @IAllowedMcpServersService protected readonly allowedMcpServersService: IAllowedMcpServersService,
337 > ) {
338 > super(logService);
339 > this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this.updateLocal(), 50));
340 > }
341
342 /**
355
356 private initialize(): Promise<void> {
357 > if (!this.initializePromise) { mcpManagementService.ts
358 > this.initializePromise = (async () => {
359 > try {
360 > this.local = await this.populateLocalServers();
361 > } finally {
362 > this.startWatching();
363 > }
364 > })();
365 > }
366 > return this.initializePromise;
367 > }
368
369 private async populateLocalServers(): Promise<Map<string, ILocalMcpServer>> {
370 > this.logService.trace('AbstractMcpResourceManagementService#populateLocalServers', this.mcpResource.toString()); mcpManagementService.ts
371 > const local = new Map<string, ILocalMcpServer>();
372 > try {
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]) => {
376 const server = await this.scanLocalServer(name, scannedServer, scannedMcpServers.sandbox);
378 }));
379 }
380 > } catch (error) { mcpManagementService.ts
381 this.logService.debug('Could not read user MCP servers:', error);
382 throw error;
383 }
384 > return local; mcpManagementService.ts
385 > }
386
387 private startWatching(): void {
388 > this._register(this.fileService.watch(this.mcpResource)); mcpManagementService.ts
389 > this._register(this.fileService.onDidFilesChange(e => {
390 if (e.affects(this.mcpResource)) {
391 this.reloadConfigurationScheduler.schedule();
392 }
394 > }
395
396 protected async updateLocal(): Promise<void> {
438
439 async getInstalled(): Promise<ILocalMcpServer[]> {
440 > await this.initialize(); mcpManagementService.ts
441 > return Array.from(this.local.values());
442 > }
443
444 protected async scanLocalServer(name: string, config: IMcpServerConfiguration, rootSandbox?: IMcpSandboxConfiguration): Promise<ILocalMcpServer> {
src/vs/platform/mcp/common/mcpResourceScannerService.ts 26 introduced LOC · 8 ranges

Open complete file

58
59 constructor(
60 > @IFileService private readonly fileService: IFileService, mcpResourceScannerService.ts
61 > @IUriIdentityService protected readonly uriIdentityService: IUriIdentityService,
62 > ) {
63 > super();
64 > }
65
66 async scanMcpServers(mcpResource: URI, target?: McpResourceTarget): Promise<IScannedMcpServers> {
67 > return this.withProfileMcpServers(mcpResource, target); mcpResourceScannerService.ts
68 > }
69
70 async addMcpServers(servers: IInstallableMcpServer[], mcpResource: URI, target?: McpResourceTarget): Promise<void> {
100
101 private async withProfileMcpServers(mcpResource: URI, target?: McpResourceTarget, updateFn?: (data: IScannedMcpServers) => IScannedMcpServers): Promise<IScannedMcpServers> {
102 > return this.getResourceAccessQueue(mcpResource) mcpResourceScannerService.ts
103 > .queue(async (): Promise<IScannedMcpServers> => {
104 > target = target ?? ConfigurationTarget.USER;
105 > let scannedMcpServers: IScannedMcpServers = {};
106 > try {
107 > const content = await this.fileService.readFile(mcpResource);
108 const errors: ParseError[] = [];
109 const result = parse(content.value.toString(), errors, { allowTrailingComma: true, allowEmptyContent: true }) || {};
110 > if (errors.length > 0) { mcpResourceScannerService.ts
111 throw new Error('Failed to parse scanned MCP servers: ' + errors.join(', '));
112 }
122 }
123 }
124 > } catch (error) { mcpResourceScannerService.ts
125 if (toFileOperationResult(error) !== FileOperationResult.FILE_NOT_FOUND) {
126 throw error;
127 }
128 }
129 > if (updateFn) { mcpResourceScannerService.ts
130 scannedMcpServers = updateFn(scannedMcpServers ?? {});
131
140 }
141 }
142 > return scannedMcpServers; mcpResourceScannerService.ts
143 > });
144 > }
145
146 private async writeScannedMcpServers(mcpResource: URI, scannedMcpServers: IScannedMcpServers): Promise<void> {
231
232 private getResourceAccessQueue(file: URI): Queue<IScannedMcpServers> {
233 > let resourceQueue = this.resourcesAccessQueueMap.get(file); mcpResourceScannerService.ts
234 > if (!resourceQueue) {
235 > resourceQueue = new Queue<IScannedMcpServers>();
236 > this.resourcesAccessQueueMap.set(file, resourceQueue);
237 > }
238 > return resourceQueue;
239 > }
240 }
241