tokencut
Analyzes pull requests for token impact and generates Markdown summaries for GitHub PR review comments, helping prevent context bloat from lockfiles and fixtures.
Supports Gemini CLI with context compression and optimizes Gemini prompt caching by detecting cache-invalidating dynamic content.
Reduces token consumption for OpenAI-powered coding sessions such as ChatGPT macOS by compacting terminal output and structured payloads while preserving failures.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
UsageTrim
A local CLI and MCP server for compacting verbose test and build output. Filters use format-specific rules to retain diagnostic context; cached output is recoverable after recognized secrets are redacted, while the entry remains stored. Integrations are available for Claude Code, Codex, Cursor, and Claude Desktop; the macOS companion is optional.
Install
Requires Python 3.11+ and uv (pipx works too).
uv tool install git+https://github.com/00200200/usagetrim
usagetrim demoTry without installing: uvx --from git+https://github.com/00200200/usagetrim usagetrim demo.
Add it inside your app
App | Install |
Claude Code |
|
Claude Desktop | Customize → Plugins → add the marketplace |
Codex app & CLI |
|
Cursor, Windsurf |
|
Plugins run the pinned release wheel through uvx, so they need uv on PATH. The .mcpb extension installs its own copy through Claude Desktop.
verbose tool text → keep the failure → recover the rest by referenceRelated MCP server: Concisr
See it cut
usagetrim demo runs authored fixtures with no model calls. It checks failure retention and exact recovery for those fixtures, which contain no recognized secrets. These checks do not guarantee preservation of every diagnostic in arbitrary output.
Fixture | Tokens |
| 18,360 → 107 (99.4%) |
| 3,281 → 64 (98.0%) |
| 6,409 → 276 (95.7%) |
| 3,795 → 185 (95.1%) |
pytest noisy (xdist + I/O) | 5,111 → 349 (93.2%) |
| 8,127 → 595 (92.7%) |
pytest recovery demo | 1,562 → 174 (88.9%) |
| up to 98.8% / 79% |
Local o200k_base estimate — not billing, quality, or subscription-limit claims. Full matrix: usagetrim demo --json.
usagetrim run -- pytest -v
usagetrim run -- docker build -t app .
usagetrim run -- docker compose logs
usagetrim run -- cargo test
usagetrim run -- go test ./...
usagetrim run -- kubectl describe pod api-7d8f9c-xk2m9
usagetrim run -- terraform plan
usagetrim run -- npx eslint . --format codeframeWhat you get
Compact supported MCP text formats. The Claude Code hook rewrites results from other MCP servers: uniform JSON rows become TSV with the keys once,
{"result": "…"}wrappers lose their escaping, and indentation goes. The rewrites target supported JSON shapes and preserve recognized<untrusted-data-…>delimiters and surrounding warnings; they do not provide a prompt-injection defense. Measured below.Focused helper agents. The plugin adds
scout(read-only search) andrunner(tests and builds, failures only) agents on Haiku.usagetrim install --cheap-exploreconfigures Claude Code's built-in Explore to use Haiku./output-style usagetrim:leantrims reply preambles and recaps.Compose logs.
docker compose/docker-compose/podman compose/podman-composeupandlogsfold repeated successful healthchecks, HTTP health polls and Redis heartbeats per service. Unknown lines, errors and exit events remain intact. Before every exit, the last ten lines of every observed service are preserved: even an exact name match can refer to another service's container. This deliberately favors crash context over maximum compression when project or custom container names are ambiguous. ANSI-decorated or other unrecognized formats are left unchanged; no Docker/Podman daemon is needed by the filter.Cut noise, keep the failure. Specialized filters for pytest, Docker, cargo, go, vitest, eslint, tsc, mypy, pyright, kubectl, terraform/tofu plan|apply|destroy, GitHub Actions / GitLab CI log folding (
gh run view --log-failed,glab ci trace),uv sync/uv add, git diff, ruff…Session dedup + spill. Same
runoutput or identicalcat/ MCPusagetrim_readview within ~15 minutes → short cache ref. Payloads over ~20 KiB → file + preview (USAGETRIM_SPILL_BYTES).Recover by reference.
usagetrim retrieve tc_…returns cached text after recognized secrets are redacted. Cache entries can be evicted when the size budget is exceeded, pruned, or cleared; references are not permanent backups. Redaction uses patterns and may miss sensitive content.Measure it.
usagetrim gain/ MCPusagetrim_gain— per-tool-family savings and passthrough candidates (local estimates, not account quotas).Desktop-ready. MCP for Claude Code / Codex / Cursor / Claude Desktop; Prepare-for-chat clipboard flow; optional macOS pet.
usagetrim gain # summary + by tool family + passthrough tips
usagetrim gain --history # same tables + recent Raw→Compact / Saved rows
usagetrim gain --passthrough # near-zero cuts only (specializer candidates)
usagetrim prepare --file draft.txtMeasured on real sessions
Maintainer-reported results from 14 days of Claude Code transcripts, replayed offline through the same functions the hook runs. Token counts are local o200k_base estimates, not billing; the private transcripts are not included as a public benchmark dataset.
Tool results | Count | Tokens before → after | Cut |
All third-party MCP results | 11,058 | 7.17M → 5.85M | 18.3% |
Supabase | 6,571 | 4.97M → 4.03M | 18.9% |
Google Search Console analytics | 223 | 702k → 434k | 38.2% |
Vercel | 43 | 250k → 210k | 16.1% |
All 3,144 SQL results rewritten as TSV decoded back to the original rows (reproduce on your own transcripts: uv run python scripts/replay_mcp_transcripts.py). Browser and page-text tools return prose and were left alone. Bash output in the same sessions was mostly ad-hoc scripts, where the filters saved under 1%. Test and build logs are where the Bash filters pay off, so results depend on what your tools print.
How it fits
UsageTrim sits on the tool path (CLI wrapper, MCP, Prepare-for-chat). It does not intercept or rewrite the chat stream. Its filters aim to retain failure details while reducing repetitive output; inspect the cached text when the compact view is insufficient.
Approach | What UsageTrim does instead |
Blind head/tail truncation | Specialized cutters retain recognized failure details; redacted cached text is available via |
Rewrite the whole chat stream | MCP + |
Opaque “saved tokens” badges |
|
Same CCR idea as peers (compress → cache → retrieve). Differentiation is specialized cutters, session dedup, spill-to-file, and Desktop/MCP install paths — not a claim that we beat RTK/snip/headroom on every workload.
Connect your agent
Desktop & Coding profiles: 11 and 9 tools respectively, compared with 16 in the full profile, with shorter schema descriptions. Schema token counts depend on the release, serialization, and tokenizer; smaller schemas do not guarantee lower per-turn usage.
# One-command installer for Codex & Claude Desktop
usagetrim install --codex # configures ~/.codex/config.toml
usagetrim install --claude-desktop # configures Claude Desktop MCP
usagetrim install --mcpb # Extension manifest for one-click packaging
usagetrim install --all # configures all at onceFor Claude Code CLI:
claude mcp add --scope user usagetrim -- usagetrim mcp --profile coding
# or, without installing first:
claude mcp add --scope user usagetrim -- uvx --from git+https://github.com/00200200/usagetrim usagetrim mcpManual MCP configuration for Claude Desktop, Cursor, Codex, Windsurf:
{
"mcpServers": {
"usagetrim": {
"command": "/absolute/path/to/usagetrim",
"args": ["mcp", "--profile", "desktop"]
}
}
}Path: command -v usagetrim. Use --profile full for every tool, --profile coding for core terminal tools, or --profile desktop for chat apps. Client setup →
# Prepare messy logs or stack traces with prompt-cache prefix stabilization:
usagetrim prepare --desktop -f error.log
# Initialize or optimize lean, cache-aligned instructions (CLAUDE.md / AGENTS.md):
usagetrim rules --init --client claude # writes lean CLAUDE.md (~120 tokens)
usagetrim rules --init --client codex # writes lean AGENTS.md (~120 tokens)
usagetrim rules --optimize --write -f CLAUDE.md # strips filler, aligns prompt cachingDesktop companion
Mint robot on your Mac — draggable pet or menu-bar mode. Local measurements, task memory, optional account-limit readings. English UI. No extra AI calls.
Example balances are remaining allowance — not savings caused by UsageTrim.
Prepare for chat — paste a log, preview the cut, copy into Codex / Claude Desktop. Log prep →
macOS 13+ · ad-hoc signed, not notarized. CLI and MCP work without the pet. Build →
Roadmap
Possible follow-up work, separate from the features available today:
Ranked repo map (Aider-style PageRank over the symbol graph) fitted to a token budget.
LSP-backed references and rename (Serena-style), falling back to the ast-grep index.
Lossless log templating (Drain-style) for dev-server, Docker and CI logs.
A paired A/B harness on provider-reported tokens and task pass rate, because output-size savings alone can hide extra turns.
Contributing
Lost context or an incorrect filter result? Open an issue with a small redacted input, the command, and the expected output. See CONTRIBUTING.md for development setup and checks.
Guide · Measurements · MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Compress coding-agent context ~64%. Hosted Neural Keep MCP for Cursor/Claude/Codex.
Provide your AI coding tools with token-efficient access to up-to-date technical documentation for…
Shared memory for coding agents. Stop re-explaining your codebase every session.
Shared distillation cache for AI agents — every fetch ~73-89% fewer tokens via a shared cache.
Related MCP Servers
- AlicenseBqualityDmaintenanceMaximizes AI agent context window by enabling compact code reading and editing, reducing tokens by 40% for deeper codebase understanding.1910 npm3MIT
- AlicenseNot gradedqualityDmaintenanceToken compression for AI contexts, reducing token consumption by compressing conversation exchanges before they enter the LLM context window.MIT
- AlicenseNot gradedqualityBmaintenanceDeterministic context compression for MCP agents, reducing token usage via 11 tools for prompts, history, shell output, file deltas, and code navigation without ML or GPU.9MIT
- AlicenseNot gradedqualityBmaintenanceReduces token consumption for AI coding agents by 50-70% through intelligent code context filtering, Git delta tracking, and local SQLite/Tree-sitter indexing.167 npmMIT