prompt-compressor-mcp
v1.0.4MCP server for rule-based prompt compression — cut LLM token usage without a model, without an API, without sending data anywhere.
⭐ Find it useful? Star it on GitHub · 🐛 Found a bug or have an idea? Open an issue Gives Claude, Cursor, VS Code, Windsurf, or any MCP client tools to shrink prompts, system prompts, docs, logs and JSON before they go into context. Built on prompt-compressor. Fully deterministic and runs locally. Template variables like {{name}} are preserved. Resource: prompt-compressor://levels lists which algorithms run at each level.
Summary extracted from the README.
prompt-compressor-mcp
MCP server for rule-based prompt compression. Cut LLM token usage without a model, without an API key, and without sending data anywhere.
⭐ Find it useful? Star it on GitHub · 🐛 Found a bug or have an idea? Open an issue
Gives Claude, Cursor, VS Code, Windsurf, or any MCP client tools to shrink prompts, system prompts, docs, logs and JSON before they go into context. Built on prompt-compressor. Fully deterministic and runs locally. Template variables like {{name}} are preserved.
No model. No API key. Deterministic. Zero dependencies. Your data never leaves your machine. At the default level it cut 22% of tokens across 8 real-world prompt types while keeping 94/94 critical instructions. See the benchmark.
Tools
| Tool | What it does |
|---|---|
compress_prompt |
Compress text at a chosen risk level → compressed text + token stats |
compress_file |
Read a local text file and return a compressed version (the file is not modified) |
compare_levels |
Run all four levels on the same text and show the savings for each |
estimate_tokens |
Quick token estimate for any text |
Resource: prompt-compressor://levels lists which algorithms run at each level.
Risk levels
| Level | What runs | Measured saving (benchmark) |
|---|---|---|
none |
Whitespace, unicode normalization, indentation | 2% avg (0–16%) |
very-low |
+ filler lead-ins, phrase shortening, JSON/SQL minify | 8% avg (0–32%) |
low (default) |
+ hedging, code comments, deduplication, stack-trace truncation | 22% avg (2–56%), 100% of critical facts kept |
medium |
+ Near-duplicate removal (fuzzy / n-gram / Levenshtein), TextRank on plain prose only | 24% avg (5–56%), 100% of critical facts kept |
medium=low+ near-duplicate removal + light summarization of plain prose. Code blocks, lists, tables,Key: valuelines, questions, and any sentence with a rule, number, ID or variable are never removed. On the dense prompts in the benchmark it saves about the same aslow(24% vs 22%) and kept 94/94 critical facts. It helps most on long, chatty prose. (Before 1.0.3,mediumchained three summarizers and kept only 22% of critical facts. Upgrade if you used it.)
Install
No install step. Your MCP client runs it with npx.
Claude Desktop / Claude Code
{
"mcpServers": {
"prompt-compressor": {
"command": "npx",
"args": ["-y", "prompt-compressor-mcp"]
}
}
}
Claude Code one-liner:
claude mcp add prompt-compressor -- npx -y prompt-compressor-mcp
Cursor / Windsurf
Add the same mcpServers block to ~/.cursor/mcp.json or ~/.codeium/windsurf/mcp_config.json.
VS Code
{
"servers": {
"prompt-compressor": {
"type": "stdio",
"command": "npx",
"args": ["-y", "prompt-compressor-mcp"]
}
}
}
Example
"Compress the system prompt in
prompts/support.mdat low risk and show me how many tokens it saves."
Tokens: 1200 → 820 (saved 380, 31%)
Use it in your own server
import { createServer } from 'prompt-compressor-mcp';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
await createServer().connect(new StdioServerTransport());
Want the library without MCP? Use prompt-compressor directly, or try the web tool at prompt-compressor.com.
License
MIT © Tom Ketter