Token Lens MCP server
Context window token analysis and budget management
0 stars59 downloads/wk
Reviews
Write oneNobody has reviewed Token Lens yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
Token Lens tools (7)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
analyze_session_usageTrack which tools are actually called vs loaded in a session. Register tools, log calls, and generate waste reports showing unused tools ranked by token cost.
audit_context_budgetAnalyze the token cost of MCP tool definitions. Estimates tokens per tool using chars/4 on the full JSON definition. Returns per-tool costs and percentage of common context windows.
compress_schemaCompress a verbose tool schema to reduce token usage. Light: remove short descriptions. Medium: shorten descriptions, remove examples. Aggressive: strip all descriptions.
get_optimization_reportFull context window health check combining audit, removal suggestions, and compression recommendations. Returns an executive summary with health grade and projected savings.
health_checkReturns server health, uptime, version, and storage stats
optimize_tool_loadingGiven a task description, recommend the minimal set of tools needed. Uses keyword matching and category relevance scoring to rank tools.
suggest_removalsIdentify tools that can be removed based on usage history. Scores: never_used > not_used_30_days > rarely_used. Returns removal candidates with estimated token savings.
Public scan report
scanner v0.1.9 · 2026-09-27 · same rubric, same numbers if you re-run it
- Code scan13 source files scanned25/25
- –Live reliabilityno gateway calls yet and no remote to proben/a
- –Tool poisoningtools not inspected (local package is not executed); not countedn/a
- Auth qualitylocal package, no credentials required12/15
- Maintenancelast push 156 days ago8/15
- Maintainer identityregistry namespace matches repository owner6/10
How Token Lens compares
Against every graded MCP server, from our own scans and uptime checks. Updated after each scan run.
- Safety score
- 78/100
- higher than 57% of 48,255 servers
- Tools
- 7
- the typical server has 7
- Tools that change things
- 0%
- typical: 0%. Fewer write tools means less an agent can break
- Downloads a week
- 59
- more than 48% of 12,191 servers with a package
What its tools let an agent do: 7 read
Install Token Lens in Claude Code, Cursor or VS Code
Runs npx -y token-lens-mcp on your machine. Read the scan report first; the gateway never runs local packages.
claude mcp add token-lens -- npx -y token-lens-mcp
What the publisher says
From the Token Lens repository's README, as published. We do not edit it. Read it on GitHub
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 claudedesktopconfig.json:
{
"mcpServers": {
"token-lens": {
"command": "npx",
"args": ["token-lens-mcp"]
}
}
}Claude Code
claude mcp add token-lens -- npx token-lens-mcpTools
auditcontextbudget
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.
optimizetoolloading
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 accomplish
- available_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 tool
- schema — JSON Schema object to compress
- level — "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.
analyzesessionusage
Track which tools are actually called vs loaded during a session.
Params:
- session_id — Unique session identifier
- action — "registertool" | "logcall" | "report"
- toolname — Tool name (required for registertool/log_call)
- tooltokens — Token cost (for registertool, 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:
- usagehistory — Array of {toolname, callcount, lastuseddaysago}
Scoring: neverused (priority 3) > notused30days (priority 2) > rarely_used (priority 1)
Returns: Removal candidates with reasons and estimated token savings.
getoptimizationreport
Full context window health check combining audit, removal suggestions, and compression recommendations.
Params:
- tools — Array of tool definitions
- usage_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
Nothing above is checked by us. What we check is on the safety report.
Token Lens: common questions
- Is Token Lens MCP server safe?
- Mostly: it is graded B (78/100). Read the Token Lens safety report
- How do I install Token Lens?
- It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
- Does Token Lens need an API key?
- Not as far as the registry entry and our scan can tell: no credentials are declared or required.
- Is Token Lens maintained?
- The last commit was 194 days ago (2026-04-24). The latest release is v0.1.2.
- What can I use instead of Token Lens?
- Servers from other publishers that do the same job: Token Optimizer MCP server.
- How does Token Lens compare with other MCP servers?
- safety score 78/100 (higher than 57% of 48,255 servers); tools 7 (the typical server has 7); tools that change things 0% (typical: 0%. Fewer write tools means less an agent can break). Full comparison.
Alternatives to Token Lens
Same job from other publishers: the closest match first, then the best rated.
- Token OptimizerContext-window optimization: caching, compression & smart file tools that cut tokens 60-90%.not reviewedEstablishedC