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

Function stabilizeStructuredContent

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

Source from the content-addressed store, hash-verified

374}
375
376export function stabilizeStructuredContent(content: unknown): string {
377 if (typeof content === 'string') {
378 return stabilizeResponseOutput(content);
379 }
380 const stabilize = (c: unknown): unknown => {
381 if (typeof c === 'string') {
382 return stabilizeResponseOutput(c);
383 }
384 if (Array.isArray(c)) {
385 return c.map(item => stabilize(item));
386 }
387 if (typeof c === 'object' && c !== null) {
388 const result: Record<string, unknown> = {};
389 for (const [key, value] of Object.entries(c)) {
390 if (key === 'snapshotFilePath' && typeof value === 'string') {
391 result[key] = '<file>';
392 } else {
393 result[key] = stabilize(value);
394 }
395 }
396 return result;
397 }
398 return c;
399 };
400
401 return JSON.stringify(stabilize(content), null, 2);
402}
403
404export function stabilizeResponseOutput(text: unknown): string {
405 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