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

Function stabilizeStructuredContent

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

Source from the content-addressed store, hash-verified

404}
405
406export function stabilizeStructuredContent(content: unknown): string {
407 if (typeof content === 'string') {
408 return stabilizeResponseOutput(content);
409 }
410 const stabilize = (c: unknown): unknown => {
411 if (typeof c === 'string') {
412 return stabilizeResponseOutput(c);
413 }
414 if (Array.isArray(c)) {
415 return c.map(item => stabilize(item));
416 }
417 if (typeof c === 'object' && c !== null) {
418 const result: Record<string, unknown> = {};
419 for (const [key, value] of Object.entries(c)) {
420 if (key === 'snapshotFilePath' && typeof value === 'string') {
421 result[key] = '<file>';
422 } else {
423 result[key] = stabilize(value);
424 }
425 }
426 return result;
427 }
428 return c;
429 };
430
431 return JSON.stringify(stabilize(content), null, 2);
432}
433
434export function stabilizeResponseOutput(text: unknown): string {
435 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