Token Lens
v0.2.37Count and cut tokens in prompts, chats and agents for any model.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
plan_coach Get the most out of your Claude plan
How much of the user's Claude plan (Free, Pro, Max, Team) is used and left, how many more messages fit this session in the open chat versus a new one, what is draining it, and what to do before it runs out or resets unused. Never switches the model or changes answers. Use when the user asks about usage, limits, their plan or subscription, or how to make it last.
| Parameter | Type | Description |
|---|---|---|
chat_tokens | integer | Your best estimate of this chat's size in tokens. |
plan | string | The user's plan, if they said; saved for next time. |
session_pct_used | number | Session usage % from Claude's Settings > Usage, if the user gave it. |
session_resets_in_minutes | number | |
week_pct_used | number |
optimize_prompt Optimize a prompt for fewer tokens
Rewrite a prompt to use fewer tokens for a given model, keeping its meaning. Detects the task (coding, debugging, writing, editing, summarizing, translation, research, analysis, brainstorming, chat), leaves code, quotes and pasted source text untouched, trims logs when debugging, and drops step-by-step instructions for reasoning models. Never suggests switching models. Returns the best prompt to paste (same answer, fewer tokens, with what it kept), the savings in tokens and dollars, and model- and task-specific tips. Use when the user asks to shorten, tighten or save tokens on a prompt.
| Parameter | Type | Description |
|---|---|---|
model * | string | Model in use, e.g. "gpt-5", "claude-sonnet-4-5"; your own if unsure. |
prompt * | string | The prompt to optimize, exactly as the user wrote it. |
conversation_tokens | integer | Tokens already in the conversation, if known. |
level | string | light: wording only; balanced: + politeness and filler; aggressive: + hedges. Default auto. |
pricing | object | USD per 1M tokens, only if not the list price. |
count_tokens Count tokens
Count the tokens in a text for a given model. Exact for OpenAI models (o200k tokenizer); for Claude and Gemini exact when the server runs with your own ANTHROPIC_API_KEY or GEMINI_API_KEY (it then asks the provider's free token-count endpoint), otherwise a per-family estimate. Use when the user asks how many tokens something is, or before pasting a large document.
| Parameter | Type | Description |
|---|---|---|
model * | string | Model in use, e.g. "gpt-5", "claude-sonnet-4-5"; your own if unsure. |
text * | string | |
pricing | object | USD per 1M tokens, only if not the list price. |
check_conversation Check conversation token budget
Estimate how full the context window is for a conversation and whether to hand off to a new chat. Pass the conversation text or a token count. When the chat is long, also offers an optional handoff request that produces a compact brief to continue in a fresh chat; this can change later answers, because the new chat only knows what the brief keeps, so present it as optional and never as same-output. Use when the user asks about chat length, usage limits, or the model forgetting earlier context.
| Parameter | Type | Description |
|---|---|---|
model * | string | Model in use, e.g. "gpt-5", "claude-sonnet-4-5"; your own if unsure. |
conversation | string | The conversation so far, as text. |
conversation_tokens | integer | Or: its size in tokens. |
latest_request | string | The user's latest message, to tailor the handoff to the task. |
pricing | object | USD per 1M tokens, only if not the list price. |
optimize_agent Find token hotspots and optimize an agent or conversation
Break down where tokens go in an agent or chat (system prompt, tool definitions, examples, conversation history, next prompt), find what is large or growing, and fix it. Safe fixes that keep the meaning (tighter wording with every number, negation and constraint kept; duplicate history removed) are applied and returned as an optimized spec. Returns the optimized system prompt, tool definitions and next prompt ready to paste. Every applied change is verified (facts and constraints kept, every instruction word kept, tool interface and conversation unchanged, same model) and the checks are return…
| Parameter | Type | Description |
|---|---|---|
model * | string | Model in use, e.g. "gpt-5", "claude-sonnet-4-5"; your own if unsure. |
calls_per_month | integer | How many calls this agent makes per month, if known, to show the monthly saving. |
examples | array | Few-shot examples. |
messages | array | Conversation history, oldest first. |
pricing | object | USD per 1M tokens, only if not the list price. |
prompt | string | The next user message. |
system | string | System prompt / instructions. |
tools | array | Tool definitions (parameters = JSON schema). |
audit_agent_rules Trim coding-agent rule files
Audit the instruction files a coding agent re-sends on every turn (CLAUDE.md, AGENTS.md, .cursorrules, .github/copilot-instructions.md, GEMINI.md and the like) and return trimmed versions ready to paste. Removes exact repeats within and across the files and tightens wording only where every number, negation, constraint and instruction word is kept, so the agent gets the same instructions. Lines that mention files missing from the repo are listed, never removed. Reports the tokens and dollars saved per turn and per 1,000 turns. Use when the user shares agent rule files or asks why a coding agen…
| Parameter | Type | Description |
|---|---|---|
files * | array | Each rule file: its path and full text. |
model * | string | Model in use, e.g. "gpt-5", "claude-sonnet-4-5"; your own if unsure. |
pricing | object | USD per 1M tokens, only if not the list price. |
repo_paths | array | Optional: the repo's file paths, to flag rules that mention files that no longer exist. |
list_model_profiles List model profiles
List the model families Token Lens adapts to, with their context windows, whether counts are exact, and the price used for cost figures.
compact_data Shrink pasted data without changing it
Shrink pasted JSON, API responses or logs with the data unchanged (removes only whitespace outside strings; proven by parsing). Returns paste-ready text and savings. Use when the user pastes large data.
| Parameter | Type | Description |
|---|---|---|
model * | string | Model in use, e.g. "gpt-5", "claude-sonnet-4-5"; your own if unsure. |
text * | string | Text with the pasted data, as written. |
compare_prompts Check a shortened prompt against the original
Check a prompt the user shortened against the original: savings, and any number, negation, constraint or instruction word lost. Use when asked if a shorter prompt is safe to send.
| Parameter | Type | Description |
|---|---|---|
edited * | string | |
model * | string | Model in use, e.g. "gpt-5", "claude-sonnet-4-5"; your own if unsure. |
original * | string |
estimate_cost Forecast monthly cost and same-answer savings
Monthly cost of an app or agent on its model (input, output, long-context rates) and what same-answer prompt caching and half-price batch save. Use for budgets and cutting an LLM bill.
| Parameter | Type | Description |
|---|---|---|
calls_per_day * | number | |
input_tokens * | integer | Per call. |
model * | string | Model in use, e.g. "gpt-5", "claude-sonnet-4-5"; your own if unsure. |
output_tokens * | integer | Per call, incl. reasoning. |
can_wait_share | number | Share of calls that can wait 24h. |
pricing | object | USD per 1M tokens, only if not the list price. |
repeated_prefix_tokens | integer | Unchanging start of each call: system, tools, examples. |
savings_report Show total tokens and money saved
Tokens and money Token Lens has saved: today, 7 and 30 days, total, by action and model.