MCPcopy Index your code
hub / github.com/codeaashu/claude-code / inferCompactSchema

Function inferCompactSchema

src/services/mcp/client.ts:2644–2660  ·  view source on GitHub ↗
(value: unknown, depth = 2)

Source from the content-addressed store, hash-verified

2642 * e.g. "{title: string, items: [{id: number, name: string}]}"
2643 */
2644export function inferCompactSchema(value: unknown, depth = 2): string {
2645 if (value === null) return 'null'
2646 if (Array.isArray(value)) {
2647 if (value.length === 0) return '[]'
2648 return `[${inferCompactSchema(value[0], depth - 1)}]`
2649 }
2650 if (typeof value === 'object') {
2651 if (depth <= 0) return '{...}'
2652 const entries = Object.entries(value).slice(0, 10)
2653 const props = entries.map(
2654 ([k, v]) => `${k}: ${inferCompactSchema(v, depth - 1)}`,
2655 )
2656 const suffix = Object.keys(value).length > 10 ? ', ...' : ''
2657 return `{${props.join(', ')}${suffix}}`
2658 }
2659 return typeof value
2660}
2661
2662export async function transformMCPResult(
2663 result: unknown,

Callers 1

transformMCPResultFunction · 0.85

Calls 2

entriesMethod · 0.80
keysMethod · 0.80

Tested by

no test coverage detected