{
  "markdown": "# token-lens-mcp\n\nMCP 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.\n\n## Install\n\n```bash\nnpx token-lens-mcp\n```\n\n### Claude Desktop\n\nAdd to `claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"token-lens\": {\n      \"command\": \"npx\",\n      \"args\": [\"token-lens-mcp\"]\n    }\n  }\n}\n```\n\n### Claude Code\n\n```bash\nclaude mcp add token-lens -- npx token-lens-mcp\n```\n\n## Tools\n\n### audit_context_budget\n\nAnalyze the token cost of your MCP tool definitions. Estimates tokens per tool using chars/4 approximation on the full JSON definition.\n\n**Params:**\n- `tools` — Array of `{name, description, schema}` objects\n\n**Returns:** Per-tool token cost (sorted by cost), total tokens, percentage of 128K/200K/1M context windows.\n\n### optimize_tool_loading\n\nGiven a task description, recommend the minimal set of tools needed. Uses keyword matching and category relevance scoring.\n\n**Params:**\n- `task_description` — What you're trying to accomplish\n- `available_tools` — Array of `{name, description, category?}`\n\n**Returns:** Recommended tools sorted by relevance, excluded tools, estimated tokens saved.\n\n### compress_schema\n\nCompress verbose tool schemas to reduce token usage.\n\n**Params:**\n- `tool_name` — Name of the tool\n- `schema` — JSON Schema object to compress\n- `level` — `\"light\"` | `\"medium\"` | `\"aggressive\"`\n\n**Levels:**\n- **light** — Remove descriptions under 20 chars\n- **medium** — Shorten descriptions to 50 chars, remove examples\n- **aggressive** — Strip all descriptions, keep only types and required fields\n\n**Returns:** Compressed schema, original/compressed token counts, savings percentage.\n\n### analyze_session_usage\n\nTrack which tools are actually called vs loaded during a session.\n\n**Params:**\n- `session_id` — Unique session identifier\n- `action` — `\"register_tool\"` | `\"log_call\"` | `\"report\"`\n- `tool_name` — Tool name (required for register_tool/log_call)\n- `tool_tokens` — Token cost (for register_tool, default 50)\n\n**Report returns:** Loaded vs used counts, waste percentage, unused tools ranked by token cost.\n\n### suggest_removals\n\nIdentify tools that can be safely removed based on usage patterns.\n\n**Params:**\n- `usage_history` — Array of `{tool_name, call_count, last_used_days_ago}`\n\n**Scoring:** never_used (priority 3) > not_used_30_days (priority 2) > rarely_used (priority 1)\n\n**Returns:** Removal candidates with reasons and estimated token savings.\n\n### get_optimization_report\n\nFull context window health check combining audit, removal suggestions, and compression recommendations.\n\n**Params:**\n- `tools` — Array of tool definitions\n- `usage_history` — Optional usage history array\n\n**Returns:** Executive summary with health grade (excellent/good/fair/poor), audit results, removal suggestions, compression opportunities, and actionable recommendations.\n\n## Resources\n\n### token-lens://tips\n\nBest practices guide for reducing MCP context window bloat, including schema design tips, token budget guidelines, and dynamic tool loading strategies.\n\n## Development\n\n```bash\nnpm install\nnpm test\nnpm run dev  # watch mode\n```\n\n## License\n\nMIT\n",
  "bytes": 3253,
  "sha": "6d6b25b1135ed68494c12f05a975df1e32d870241dd64fee427f25b6da22d9f2",
  "repo_slug": "mdfifty50-boop/token-lens-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_mdfifty50_boop_token_lens_ee9fafd2/readme"
}