MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / stabilizeStructuredContent

Function stabilizeStructuredContent

tests/utils.ts:307–333  ·  view source on GitHub ↗
(content: unknown)

Source from the content-addressed store, hash-verified

305}
306
307export function stabilizeStructuredContent(content: unknown): string {
308 if (typeof content === 'string') {
309 return stabilizeResponseOutput(content);
310 }
311 const stabilize = (c: unknown): unknown => {
312 if (typeof c === 'string') {
313 return stabilizeResponseOutput(c);
314 }
315 if (Array.isArray(c)) {
316 return c.map(item => stabilize(item));
317 }
318 if (typeof c === 'object' && c !== null) {
319 const result: Record<string, unknown> = {};
320 for (const [key, value] of Object.entries(c)) {
321 if (key === 'snapshotFilePath' && typeof value === 'string') {
322 result[key] = '<file>';
323 } else {
324 result[key] = stabilize(value);
325 }
326 }
327 return result;
328 }
329 return c;
330 };
331
332 return JSON.stringify(stabilize(content), null, 2);
333}
334
335export function stabilizeResponseOutput(text: unknown) {
336 if (typeof text !== 'string') {

Callers 4

testIncludesWebmcpToolsFunction · 0.85
McpContext.test.tsFile · 0.85
console.test.tsFile · 0.85

Calls 2

stabilizeResponseOutputFunction · 0.85
stabilizeFunction · 0.85

Tested by 1

testIncludesWebmcpToolsFunction · 0.68