Compress prompts 40-60% using local LLM + embedding validation. Preserves all conditionals.
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.
mcp-name: io.github.base76-research-lab/token-compressor
Semantic prompt compression for LLM workflows. Reduce token usage by 40β60% without losing meaning.
Built by Base76 Research Lab β research into epistemic AI architecture.
Intent Compiler MVP is now live and uses this project as part of the idea -> spec -> compressed output flow:
token-compressor is a two-stage pipeline that compresses prompts before they reach an LLM:
The result: shorter prompts, lower costs, same intent.
Key design principle: conditionality is never sacrificed. If your prompt says "only do X if Y", that constraint survives compression.
Result object:
| Field | Description |
|---|---|
output_text | Text to send to your LLM |
mode | compressed / raw_fallback / skipped |
coverage | Cosine similarity (0.0β1.0) |
tokens_in | Estimated input tokens |
tokens_out | Estimated output tokens |
tokens_saved | Difference |
Output: compressed text on stdout, stats on stderr.
Add to your ~/.claude/settings.json under hooks β UserPromptSubmit:
This runs on every prompt submission and writes the compressed version to a temp file, which can be injected back into context via a second hook or MCP server.
The MCP server exposes compression as a tool callable from Claude Code and any MCP-compatible client.
Install:
Tool: compress_prompt
text (string)Claude Code MCP config (~/.claude/settings.json):
Or from source:
Stage 1 β LLM compression
The compression prompt instructs the model to:
if, only if, unless, when, but only)Stage 2 β Embedding validation
Computes cosine similarity between the original and compressed text using nomic-embed-text. If similarity falls below threshold, the original is returned unchanged. This prevents silent meaning loss.
Tested across Swedish and English prompts, technical and natural language:
| Input | Tokens in | Tokens out | Saved |
|---|---|---|---|
| Research abstract (EN) | 89 | 38 | 57% |
| Session intent (SV) | 32 | 18 | 44% |
| Technical instruction | 47 | 22 | 53% |
| Short command (<80t) | β | β | skipped |
This tool implements the architecture from:
WikstrΓΆm, B. (2026). When Alignment Reduces Uncertainty: Epistemic Variance Collapse and Its Implications for Metacognitive AI. DOI: 10.5281/zenodo.18731535
Part of the Base76 Research Lab toolchain for epistemic AI infrastructure.
MIT β Base76 Research Lab, Sweden
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/token-compressor)<a href="https://allmcps.com/mcp/token-compressor"><img src="https://allmcps.com/api/badge/token-compressor?style=directory" alt="Token Compressor on AllMCPs" /></a>