Code Block Token Analyzer

Code Block Token Analyzer MCP Connector for Claude

A+

Calculate token density and code-to-text ratios in documents.

3 tools Official Updated Oct 1, 2026 Official Vinkius Partner

This MCP server provides deterministic analysis of text containing code blocks. It calculates token counts by applying specific density heuristics: code tokens are estimated at 3 characters per token, while non-code text is estimated at 4 characters per token. Use analyze_text_density to get a full breakdown of code blocks, character counts, and token ratios, or get_token_metrics_summary for a high-level overview of token distribution. It also includes validate_code_block_format to ensure text contains extractable triple-backtick blocks.

tokenscode-analysisdensityllm-optimizationtext-processing

3 tools expose this connector's capabilities to your AI agent.

validate_code_block_format

analyze_text_density

get_token_metrics_summary

See how to talk to your AI agent using Code Block Token Analyzer.

Analyze the token density of this text: 'Here is some code: ```const x = 10;```'

code_block_count: 1, total_code_chars: 14, code_tokens: 4, non_code_tokens: 4, total_tokens: 8, code_ratio: 0.5, optimization_suggested: false

Give me a summary of the token metrics for: '```print(hello)```'

total_tokens: 4, code_ratio: 1.0, is_code_heavy: true

Does this text contain valid code blocks: 'Just some plain text here.'

has_code_blocks: false, block_count: 0

Code tokens are calculated by dividing code characters by 3, and non-code tokens by 4.

Related Connectors