token-lens-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@token-lens-mcpaudit the context budget of my MCP tools"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
token-lens-mcp
MCP server for analyzing and optimizing context window token usage. MCP tool definitions consume 40-72% of context windows before any user work begins — this server helps you measure, compress, and eliminate that waste.
Install
npx token-lens-mcpClaude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"token-lens": {
"command": "npx",
"args": ["token-lens-mcp"]
}
}
}Claude Code
claude mcp add token-lens -- npx token-lens-mcpRelated MCP server: Refract
Tools
audit_context_budget
Analyze the token cost of your MCP tool definitions. Estimates tokens per tool using chars/4 approximation on the full JSON definition.
Params:
tools— Array of{name, description, schema}objects
Returns: Per-tool token cost (sorted by cost), total tokens, percentage of 128K/200K/1M context windows.
optimize_tool_loading
Given a task description, recommend the minimal set of tools needed. Uses keyword matching and category relevance scoring.
Params:
task_description— What you're trying to accomplishavailable_tools— Array of{name, description, category?}
Returns: Recommended tools sorted by relevance, excluded tools, estimated tokens saved.
compress_schema
Compress verbose tool schemas to reduce token usage.
Params:
tool_name— Name of the toolschema— JSON Schema object to compresslevel—"light"|"medium"|"aggressive"
Levels:
light — Remove descriptions under 20 chars
medium — Shorten descriptions to 50 chars, remove examples
aggressive — Strip all descriptions, keep only types and required fields
Returns: Compressed schema, original/compressed token counts, savings percentage.
analyze_session_usage
Track which tools are actually called vs loaded during a session.
Params:
session_id— Unique session identifieraction—"register_tool"|"log_call"|"report"tool_name— Tool name (required for register_tool/log_call)tool_tokens— Token cost (for register_tool, default 50)
Report returns: Loaded vs used counts, waste percentage, unused tools ranked by token cost.
suggest_removals
Identify tools that can be safely removed based on usage patterns.
Params:
usage_history— Array of{tool_name, call_count, last_used_days_ago}
Scoring: never_used (priority 3) > not_used_30_days (priority 2) > rarely_used (priority 1)
Returns: Removal candidates with reasons and estimated token savings.
get_optimization_report
Full context window health check combining audit, removal suggestions, and compression recommendations.
Params:
tools— Array of tool definitionsusage_history— Optional usage history array
Returns: Executive summary with health grade (excellent/good/fair/poor), audit results, removal suggestions, compression opportunities, and actionable recommendations.
Resources
token-lens://tips
Best practices guide for reducing MCP context window bloat, including schema design tips, token budget guidelines, and dynamic tool loading strategies.
Development
npm install
npm test
npm run dev # watch modeLicense
MIT
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/mdfifty50-boop/token-lens-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server