Skip to main content
Glama
count-claude-config.js•3.26 kB
#!/usr/bin/env node import { readFile } from 'fs/promises'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; // Import the TokenMeasurementEngine from the deprecated analyzer const deprecatedPath = '/home/cordlesssteve/projects/Utility/DEV-TOOLS/mcp-workspace/archive/deprecated-token-analyzer/src/TokenMeasurementEngine.js'; const { TokenMeasurementEngine } = await import(deprecatedPath); async function countClaudeConfigTokens() { console.log('šŸ“Š Counting tokens in CLAUDE.md and all imports...\n'); const engine = new TokenMeasurementEngine(); const configBase = '/home/cordlesssteve/.claude'; // Read all config files const files = [ { path: `${configBase}/CLAUDE.md`, name: 'CLAUDE.md' }, { path: `${configBase}/config/intellectual-honesty.md`, name: 'intellectual-honesty.md' }, { path: `${configBase}/config/verification-protocols.md`, name: 'verification-protocols.md' }, { path: `${configBase}/config/file-organization.md`, name: 'file-organization.md' }, { path: `${configBase}/config/backup-systems.md`, name: 'backup-systems.md' }, { path: `${configBase}/config/mcp-discovery-protocol.md`, name: 'mcp-discovery-protocol.md' }, { path: `${configBase}/config/anti-pattern-guardrails.md`, name: 'anti-pattern-guardrails.md' } ]; let totalTokens = 0; let totalChars = 0; const results = []; for (const file of files) { try { const content = await readFile(file.path, 'utf-8'); const tokens = engine.approximateTokenCount(content); const chars = content.length; totalTokens += tokens; totalChars += chars; results.push({ name: file.name, tokens, chars, percentage: 0 // Will calculate after we have total }); console.log(`āœ“ ${file.name.padEnd(30)} ${tokens.toLocaleString().padStart(6)} tokens (${chars.toLocaleString()} chars)`); } catch (error) { console.log(`āœ— ${file.name.padEnd(30)} ERROR: ${error.message}`); } } // Calculate percentages results.forEach(r => { r.percentage = ((r.tokens / totalTokens) * 100).toFixed(1); }); console.log('\n' + '─'.repeat(70)); console.log(`Total: ${totalTokens.toLocaleString()} tokens (${totalChars.toLocaleString()} characters)`); console.log('─'.repeat(70)); console.log(`\nšŸ“ˆ Context Window Analysis:`); console.log(` Total config tokens: ${totalTokens.toLocaleString()}`); console.log(` Context window size: 200,000 tokens`); console.log(` Config overhead: ${((totalTokens / 200000) * 100).toFixed(2)}%`); console.log(` Remaining context: ${(200000 - totalTokens).toLocaleString()} tokens`); console.log(`\nšŸ“Š Breakdown by file:`); results .sort((a, b) => b.tokens - a.tokens) .forEach(r => { console.log(` ${r.name.padEnd(30)} ${r.percentage.padStart(5)}% (${r.tokens.toLocaleString()} tokens)`); }); console.log(`\nšŸ’” Token Estimation Method:`); console.log(` Using character-based approximation (~3.5-4 chars/token for technical content)`); console.log(` This is the same method used by the deprecated-token-analyzer`); } countClaudeConfigTokens().catch(error => { console.error('āŒ Error:', error.message); process.exit(1); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cordlesssteve/token-analyzer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server