MCPcopy Create free account
hub / github.com/modelcontextprotocol/inspector / initializeInspectorConfig

Function initializeInspectorConfig

client/src/utils/configUtils.ts:121–161  ·  view source on GitHub ↗
(
  localStorageKey: string,
)

Source from the content-addressed store, hash-verified

119};
120
121export const initializeInspectorConfig = (
122 localStorageKey: string,
123): InspectorConfig => {
124 // Read persistent config from localStorage
125 const savedPersistentConfig = localStorage.getItem(localStorageKey);
126 // Read ephemeral config from sessionStorage
127 const savedEphemeralConfig = sessionStorage.getItem(
128 `${localStorageKey}_ephemeral`,
129 );
130
131 // Start with default config
132 let baseConfig = { ...DEFAULT_INSPECTOR_CONFIG };
133
134 // Apply saved persistent config
135 if (savedPersistentConfig) {
136 const parsedPersistentConfig = JSON.parse(savedPersistentConfig);
137 baseConfig = { ...baseConfig, ...parsedPersistentConfig };
138 }
139
140 // Apply saved ephemeral config
141 if (savedEphemeralConfig) {
142 const parsedEphemeralConfig = JSON.parse(savedEphemeralConfig);
143 baseConfig = { ...baseConfig, ...parsedEphemeralConfig };
144 }
145
146 // Ensure all config items have the latest labels/descriptions from defaults
147 for (const [key, value] of Object.entries(baseConfig)) {
148 baseConfig[key as keyof InspectorConfig] = {
149 ...value,
150 label: DEFAULT_INSPECTOR_CONFIG[key as keyof InspectorConfig].label,
151 description:
152 DEFAULT_INSPECTOR_CONFIG[key as keyof InspectorConfig].description,
153 is_session_item:
154 DEFAULT_INSPECTOR_CONFIG[key as keyof InspectorConfig].is_session_item,
155 };
156 }
157
158 // Apply query param overrides
159 const overrides = getConfigOverridesFromQueryParams(DEFAULT_INSPECTOR_CONFIG);
160 return { ...baseConfig, ...overrides };
161};
162
163export const saveInspectorConfig = (
164 localStorageKey: string,

Callers 1

AppFunction · 0.90

Calls 1

Tested by

no test coverage detected