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

Function getContentSizeEstimate

src/utils/mcpValidation.ts:59–75  ·  view source on GitHub ↗
(content: MCPToolResult)

Source from the content-addressed store, hash-verified

57}
58
59export function getContentSizeEstimate(content: MCPToolResult): number {
60 if (!content) return 0
61
62 if (typeof content === 'string') {
63 return roughTokenCountEstimation(content)
64 }
65
66 return content.reduce((total, block) => {
67 if (isTextBlock(block)) {
68 return total + roughTokenCountEstimation(block.text)
69 } else if (isImageBlock(block)) {
70 // Estimate for image tokens
71 return total + IMAGE_TOKEN_ESTIMATE
72 }
73 return total
74 }, 0)
75}
76
77function getMaxMcpOutputChars(): number {
78 return getMaxMcpOutputTokens() * 4

Callers 3

renderToolResultMessageFunction · 0.85
processMCPResultFunction · 0.85

Calls 3

isImageBlockFunction · 0.85
isTextBlockFunction · 0.70

Tested by

no test coverage detected