Honest token economics for MCP agents. Rust binary, zero ML, reproducible benchmarks.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Deterministic context compression for MCP agents. One Rust binary. Zero ML at query time. Reproducible benchmarks, real-data measurements.
Sophon is a deterministic context layer for agents speaking the Model Context Protocol. It compresses prompts, conversation memory, code digests, file deltas, and shell output β without an embedding model at query time, without a GPU, and without API keys.
Single 5.2 MB Rust binary. MCP-native. cl100k_base-accurate. Default build pulls no Python, no ML weights, no network.
| Tool | What it solves |
|---|---|
compress_prompt | Long structured prompt β keep only sections relevant to the query |
compress_history | Growing conversation β summary + facts + recent window + optional retrieval |
compress_output | Shell stdout/stderr β 21 domain-aware filters (git, cargo, docker, kubectl, JSON, β¦) |
read_file_delta / write_file_delta | Re-reads + edits β diffs only, never the whole file |
encode_fragments | Repeated boilerplate β single token reference |
update_memory | Append turn β JSONL persist + incremental rolling summary |
navigate_codebase | Repo digest with tree-sitter / regex + PageRank, ranked by query |
11 MCP tools total (full table below).
We built four independent benches that each capture a different chunk of an agent's tool traffic. All four run against this repo's actual git history + working tree on the operator's machine. Reproducible byte-for-byte by anyone with cargo build --release.
| Dimension | What it measures | Saved | Bench |
|---|---|---|---|
| history | compress_history over real commits | 94.6 % | real_session_capture.py |
| shell | compress_output on real git/cargo/gh/ls stdout | 84.4 % | real_session_shell.py |
| filereads | compress_prompt on real Rust / Python / Markdown / TOML files | 71.7 % | real_session_filereads.py |
| search | compress_output on real grep/find patterns | 79.5 % | real_session_search.py |
| π― Weighted blend (35/30/20/15) | typical agent session estimate | 84.7 % | real_session_holistic.py |
real_session_holistic.py runs all four sub-benches with --json, parses them, and produces the weighted blend. Default weights reflect this repo's observed shape; pass --weights "history=0.4,..." to model your own workload.
| Saved per session | |
|---|---|
| Naive input pricing ($15/MT) | $2.03 |
| With prompt caching (25-turn reads at $1.50/MT) | $3.24 |
Pass
--model sonnetor--model haikutoreal_session_deep_dive.pyif you're re-pricing for a cheaper tier.
git captures (commits + diffs) β typically ~5-10 % of a real session's tool traffic. The 94.6 % is the upper bound, not the typical case.git diff 95 %) with commands that don't (gh repo view --json adds tokens, β9 %). 84.4 % is a real-world average, not a curated highlight.compress_prompt on raw source files compresses by budget cap, not by query routing β same file with 3 different queries β identical output. Section detection only fires on structured input (Markdown headers, XML tags). Documented inline in the bench.grep TODO.The blended 84.7 % is napkin-math from a linear weighted average across four real measurements. Not a cherry-picked synthetic. Run the benches yourself to verify.
| Test | Result | Bench |
|---|---|---|
compress_output across 18 command families | 90.1 % weighted aggregate | compress_output_per_command.py |
| 25-turn synthetic Claude Code session | 68.1 % session tokens saved | session_token_economics.py |
compress_prompt across 22 prompt shapes | 70.2 % mean, 36 ms mean latency | prompt_compression_extended.py |
| Code retrieval on "where is X?" questions | recall@3 = 70 % (vs grep 10 %, FULL 20 %) | repo_qa.py |
| vs LLMLingua-2 on structured prompts | +8.9 pt accuracy at 35Γ lower latency | llmlingua_compare.py |
| Sophon + Anthropic prompt caching | +24 % tokens / +49 % $ on top of caching | sophon_plus_prompt_caching.py |
| Sophon + mem0 | Additional savings on retrieved memories | sophon_plus_mem0.py |
Sophon is not a memory platform, a recall system, an OCR stack, or a replacement for provider-side caching. It's a deterministic compressor that slots in front of whatever memory / cache / code-nav layer you already use, and attacks the tokens those layers can't.
Provider caching handles the static half of a request β system prompt, tool definitions, reused documents. It doesn't touch the dynamic half (growing conversation history, tool outputs). Sophon compresses exactly that half. The two stack cleanly.
+24 % tokens / +49 % $ saved on top of prompt caching on a 25-turn Claude session β because the uncached dynamic block is billed at 10Γ the cached rate. See
sophon_plus_prompt_caching.py.
Memory systems retrieve the right memories. Sophon shrinks what gets sent to the LLM after retrieval. If mem0 returns 2 kB of raw memories, compress_prompt keeps only the sections the query actually references.
Honest caveat: on very short retrieved blocks (< ~200 tokens) Sophon's wrapper adds overhead and you should pass through. The bench reports this directly.
Primary use case. Every repeat file read becomes a read_file_delta; every shell command output goes through compress_output; every repeated boilerplate block gets a fragment_cache token. Install transparently with sophon hook install --agent claude --global.
navigate_codebase produces a PageRanked repo digest that a RAG retriever would otherwise spend expensive embedding calls to build. Tree-sitter / regex symbol extraction over 11 languages, sub-second.
The postinstall script downloads the right prebuilt binary for your platform from the GitHub Releases page. Supported: macOS arm64/x64, Linux arm64/x64, Windows x64.
Optional features:
Requires Rust 1.75+.
Most clients accept this snippet (Claude Desktop, Claude Code, Cursor, Cline, Continue):
Run sophon doctor to print the right config path for your client.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/sophon)<a href="https://allmcps.com/mcp/sophon"><img src="https://allmcps.com/api/badge/sophon?style=directory" alt="Sophon on AllMCPs" /></a>