mcpRegistryInputStorage.ts ×10

Frontier kind: Code frontier

unlabeled · c_af8b5f2f3a6a

52 tests · 23787 LOC · 126 files · introduces 0 tests · 68 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges68 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2782 ranges23787 lines · 126 files · Browse complete extent
All tests (intent)
52 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: 68 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/mcp/common/mcpRegistryInputStorage.ts 68 introduced LOC · 10 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- mcpRegistryInputStorage.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 { Sequencer } from '../../../../base/common/async.js';
7 > import { decodeBase64, encodeBase64, VSBuffer } from '../../../../base/common/buffer.js';
8 > import { Lazy } from '../../../../base/common/lazy.js';
9 > import { Disposable } from '../../../../base/common/lifecycle.js';
10 > import { isEmptyObject } from '../../../../base/common/types.js';
11 > import { ILogService } from '../../../../platform/log/common/log.js';
12 > import { ISecretStorageService } from '../../../../platform/secrets/common/secrets.js';
13 > import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
14 > import { IResolvedValue } from '../../../services/configurationResolver/common/configurationResolverExpression.js';
15 >
16 > const MCP_ENCRYPTION_KEY_NAME = 'mcpEncryptionKey';
17 > const MCP_ENCRYPTION_KEY_ALGORITHM = 'AES-GCM';
18 > const MCP_ENCRYPTION_KEY_LEN = 256;
19 > const MCP_ENCRYPTION_IV_LENGTH = 12; // 96 bits
20 > const MCP_DATA_STORED_VERSION = 1;
21 > const MCP_DATA_STORED_KEY = 'mcpInputs';
22 >
23 > interface IStoredData {
24 > version: number;
25 > values: Record<string, IResolvedValue>;
26 > secrets?: { value: string; iv: string }; // base64, encrypted
27 > }
28 >
29 > interface IHydratedData extends IStoredData {
30 > unsealedSecrets?: Record<string, IResolvedValue>;
31 > }
32 >
33 > export class McpRegistryInputStorage extends Disposable {
34 > private static secretSequencer = new Sequencer();
35 > private readonly _secretsSealerSequencer = new Sequencer();
36 >
37 > private readonly _getEncryptionKey = new Lazy(() => {
38 return McpRegistryInputStorage.secretSequencer.queue(async () => {
39 const existing = await this._secretStorageService.get(MCP_ENCRYPTION_KEY_NAME);
57 return key;
58 });
60 >
61 > private _didChange = false;
62 >
63 > private _record = new Lazy<IHydratedData>(() => {
64 > const stored = this._storageService.getObject<IStoredData>(MCP_DATA_STORED_KEY, this._scope);
65 > return stored?.version === MCP_DATA_STORED_VERSION ? { ...stored } : { version: MCP_DATA_STORED_VERSION, values: {} };
66 > });
67 >
68 >
69 > constructor(
70 private readonly _scope: StorageScope,
71 _target: StorageTarget,
87 }));
88 }
90 > /** Deletes all collection data from storage. */
91 > public clearAll() {
92 this._record.value.values = {};
93 this._record.value.secrets = undefined;
95 this._didChange = true;
96 }
98 > /** Delete a single collection data from the storage. */
99 > public async clear(inputKey: string) {
100 const secrets = await this._unsealSecrets();
101 delete this._record.value.values[inputKey];
107 }
108 }
110 > /** Gets a mapping of saved input data. */
111 > public async getMap() {
112 const secrets = await this._unsealSecrets();
113 return { ...this._record.value.values, ...secrets };
114 }
116 > /** Updates the input data mapping. */
117 > public async setPlainText(values: Record<string, IResolvedValue>) {
118 Object.assign(this._record.value.values, values);
119 this._didChange = true;
120 }
122 > /** Updates the input secrets mapping. */
123 > public async setSecrets(values: Record<string, IResolvedValue>) {
124 const unsealed = await this._unsealSecrets();
125 Object.assign(unsealed, values);
126 await this._sealSecrets();
127 }
129 > private async _sealSecrets() {
130 const key = await this._getEncryptionKey.value;
131 return this._secretsSealerSequencer.queue(async () => {
148 });
149 }
151 > private async _unsealSecrets(): Promise<Record<string, IResolvedValue>> {
152 if (!this._record.value.secrets) {
153 return this._record.value.unsealedSecrets ??= {};