Token Analyzer MCP
Precise token counting and context efficiency analysis for MCP (Model Context Protocol) servers. Optimize your Claude Code setup by analyzing token consumption and identifying optimization opportunities.
Features
🔍 Comprehensive Token Analysis
Real-time MCP Server Scanning: Automatically discovers and analyzes all configured MCP servers
Incremental Impact Analysis: Shows how each server affects your total token budget
Schema Complexity Measurement: Analyzes tool definitions for optimization opportunities
Context Window Optimization: Tracks usage against 200k token context limit
📊 Multiple Analysis Modes
Full Analysis: Complete token breakdown with detailed recommendations
Quick Estimation: Fast overhead estimation without server connections
Configuration Audit: Validate MCP setup and server accessibility
Health Check: Verify analyzer dependencies and permissions
🎯 Optimization Intelligence
Scenario Planning: Compare "what-if" optimization scenarios
Smart Recommendations: Prioritized suggestions based on impact analysis
Complexity Scoring: Identify overly complex tool schemas
Usage Pattern Detection: Find verbose descriptions and optimization opportunities
📈 Professional Reporting
Multi-format Export: JSON, CSV, and formatted text reports
Visual Context Tracking: Color-coded overhead warnings
Incremental Impact Tables: Step-by-step token accumulation analysis
Executive Summaries: Quick overview for decision making
Installation
Quick Start
Analyze Your Current Setup
Export Detailed Results
Usage Examples
Basic Analysis
Configuration Check
Analysis Results
Token Usage Overview
Incremental Impact Analysis
Configuration Requirements
The analyzer automatically discovers MCP configurations from standard locations:
~/.claude/claude_desktop_config.json
~/.config/claude-desktop/claude_desktop_config.json
Windows:
%APPDATA%/Claude/claude_desktop_config.json
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Supported Configuration Formats
Optimization Recommendations
The analyzer provides actionable recommendations:
High Priority
Token Overhead > 10%: Consider lazy loading or server reduction
Complex Schemas: Simplify tool definitions or break into smaller tools
Heavy Servers: Review servers consuming >2000 tokens
Medium Priority
Verbose Descriptions: Reduce description length while maintaining clarity
Unused Tools: Disable servers with low utilization
Schema Optimization: Flatten nested object structures
Low Priority
Naming Conventions: Use shorter but descriptive tool names
Documentation: Add examples instead of lengthy descriptions
Advanced Features
Scenario Analysis
Compare optimization scenarios:
Current Configuration: Baseline token usage
Without Heaviest Server: Impact of removing the largest consumer
Top 3 Only: Keep only the most valuable servers
50% Optimized: Simulated optimization results
Export Options
Programmatic Usage
Performance Considerations
Connection Timeout: 10 seconds per server (configurable)
Retry Logic: Up to 2 retry attempts for failed connections
Memory Usage: Minimal overhead, designed for continuous monitoring
Caching: Results can be cached for comparison over time
Troubleshooting
Common Issues
No MCP configuration found
Server connection failures
High token consumption
Development
Architecture
API Reference
IncrementalImpactAnalyzer
performCompleteAnalysis()
: Execute full token analysisanalyzeTokenImpact(servers)
: Measure token consumptionanalyzeIncrementalImpact(tokens)
: Calculate cumulative impactgenerateRecommendations(analysis)
: Create optimization suggestions
TokenMeasurementEngine
countServerTokens(server)
: Analyze individual server tokensanalyzeSchemaComplexity(schema)
: Calculate complexity metricsmeasureBaselineTokens()
: Get built-in tool overheadcalculateTotalOverhead(servers)
: Compute total token usage
Contributing
Fork the repository
Create a feature branch:
git checkout -b feature-name
Make your changes with tests
Run the test suite:
npm test
Submit a pull request
Guidelines
Follow existing code style
Add tests for new features
Update documentation
Ensure backward compatibility
License
MIT License - see LICENSE file for details.
Support
Optimize your Claude Code setup with precise token analysis!
This server cannot be installed
Provides intelligent analysis of token usage patterns and optimization recommendations to improve efficiency and reduce costs in Claude Code sessions. Offers real-time analysis, cost metrics, and actionable insights for better context window and tool usage optimization.