MCP tool outputs are full of noise. Pretty-printed JSON, ANSI color codes, repeated log lines, inline comments — none of it adds information, all of it costs tokens. On a busy session with filesystem and git tools, this quietly burns 30–50% of your context budget before the model even starts thinking.
trimcp sits transparently between your LLM client and every MCP server. It strips the noise, caches identical calls, and reports exactly what it saved.
LLM client (Claude Code, Cursor, claude_desktop…)
↓
trimcp ← strips ANSI, minifies JSON, deduplicates lines, caches
↙ ↓ ↘
MCP1 MCP2 MCP3
[trimcp] session summary
Requests : 47
Tokens in : 84,312
Tokens out : 31,847 (62% smaller)
Cache hits : 12 / 47
Zero configuration required — it works out of the box.
Install
Quick start
# Register your MCP servers once
# Point your LLM client at trimcp instead of the server directly
LLM client configuration
Replace your server commands with trimcp proxy <name>. Nothing else changes.
Claude Code (~/.claude/settings.json):
Cursor / claude_desktop (claude_desktop_config.json):
What gets compressed
| Strategy | What it removes | Typical saving |
|---|---|---|
strip_ansi |
Terminal color/cursor codes (\x1b[…) |
~5% |
compact_json |
Whitespace in pretty-printed JSON | ~30% |
dedup |
Consecutive identical lines → line (xN) |
~40% on logs |
minify |
Trailing whitespace, extra blank lines | ~5% |
strip_comments |
// full-line comments in code blocks |
~10% |
All strategies are lossless — no information is truncated or dropped.
Configuration
~/.config/trimcp/config.toml — created automatically on first add.
[]
= "npx"
= ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
[]
= true # master switch
= true
= true
= true
= true
= false
[]
= true
= 300 # cache lifetime in seconds
[]
= true # print summary to stderr at session end
= false # print running total after each tool call
Optional: semantic code context (semtree feature)
Enable the semtree feature to inject relevant code snippets into every tools/call response. The model sees the context it needs without you having to ask for it.
# Cargo.toml
= { = "0.1", = ["semtree"] }
# ~/.config/trimcp/config.toml
[]
= "/path/to/your/project"
= 3
# Index the codebase once
# trimcp semtree-index my-server
CLI
trimcp add <name> -- <command> [args…] Register a server
trimcp remove <name> Remove a server
trimcp list List configured servers
trimcp proxy <name> Run as proxy (used by LLM clients)
trimcp stats Show compression statistics
trimcp knowledge Inspect the semantic knowledge store
trimcp semtree-index <name> Index a codebase (--features semtree)
License
MIT — see LICENSE