Compress-token
MCP server that cuts token use for AI coding agents via compression and caching
Compress-token is an open-source MCP server for developer tools. It runs locally on your machine and is started by your AI client.
- Pricing
- Open source
- Platforms
- CLI, VS Code, Linux
- Runs
- Locally
- What it can do
- Can change data (1 tool)
- Version
- 1.4.1
- Listing updated
Similar MCP servers
Install
Add with the CLI
Run in a terminal
claude mcp add compress-token -- npx -y compress-tokenAdd --scope user to use it in every project, or --scope project to share it in .mcp.json.
Or share it with your project
Add to .mcp.json
{
"mcpServers": {
"compress-token": {
"command": "npx",
"args": [
"-y",
"compress-token"
]
}
}
}Add to claude_desktop_config.json
{
"mcpServers": {
"compress-token": {
"command": "npx",
"args": [
"-y",
"compress-token"
]
}
}
}Settings → Developer → Edit Config, then quit and reopen Claude Desktop.
Add to ~/.cursor/mcp.json
{
"mcpServers": {
"compress-token": {
"command": "npx",
"args": [
"-y",
"compress-token"
]
}
}
}Use .cursor/mcp.json in a project to share it with the project.
Add to ~/.copilot/mcp-config.json
{
"mcpServers": {
"compress-token": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"compress-token"
]
}
}
}Or put the same entry in .mcp.json at your workspace root to share it.
Add with the CLI
Run in a terminal
codex mcp add compress-token -- npx -y compress-tokenOr add to config.toml
Add to ~/.codex/config.toml
[mcp_servers.compress-token]
command = "npx"
args = ["-y", "compress-token"]Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"compress-token": {
"command": "npx",
"args": [
"-y",
"compress-token"
]
}
}
}Gemini CLI and Antigravity
Gemini CLI
Add to ~/.gemini/settings.json
{ "mcpServers": { "compress-token": { "command": "npx", "args": [ "-y", "compress-token" ] } } }Or run: gemini mcp add -s user compress-token npx -- -y compress-token
Antigravity
Add to ~/.gemini/config/mcp_config.json
{ "mcpServers": { "compress-token": { "command": "npx", "args": [ "-y", "compress-token" ] } } }Use .agents/mcp_config.json to add it to one workspace only.
Devin Desktop (formerly Windsurf)
Add to ~/.config/devin/mcp_config.json
{ "mcpServers": { "compress-token": { "command": "npx", "args": [ "-y", "compress-token" ] } } }On Windows the file is %APPDATA%\devin\mcp_config.json. Use .devin/mcp_config.json to share it with a project.
Cline
Add to cline_mcp_settings.json
{ "mcpServers": { "compress-token": { "command": "npx", "args": [ "-y", "compress-token" ] } } }Open it from the MCP Servers icon → Configure → Configure MCP Servers.
Zed
Add to Zed settings.json
{ "context_servers": { "compress-token": { "command": "npx", "args": [ "-y", "compress-token" ] } } }Open it with zed: open settings file. Merge context_servers into the settings you already have.
JetBrains AI Assistant and Junie
AI Assistant
Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add
{ "mcpServers": { "compress-token": { "command": "npx", "args": [ "-y", "compress-token" ] } } }Junie
Add to ~/.junie/mcp/mcp.json
{ "mcpServers": { "compress-token": { "command": "npx", "args": [ "-y", "compress-token" ] } } }Use .junie/mcp/mcp.json to share it with a project.
Kiro
Add to ~/.kiro/settings/mcp.json
{ "mcpServers": { "compress-token": { "command": "npx", "args": [ "-y", "compress-token" ] } } }Use .kiro/settings/mcp.json to add it to one workspace only.
Using several servers? Build one config file with the MCP config generator.
About Compress-token
Compress-token adds a set of tools to an MCP-compatible AI client so it can read and condense large files, logs, CSVs, JSON payloads and stack traces before they fill the context window. Reads are cached by content hash, so unchanged files are not sent again, and a file can be fetched as an outline or a line range instead of in full.
A semantic cache sits alongside these tools. Answers to prompts that closely resemble earlier ones can be looked up and reused, with matching based on character and word patterns rather than embeddings, and entries can be namespaced with tags to keep unrelated domains apart. A local HTML dashboard summarises tokens saved and estimated cost savings across models.
The package installs through npm and, according to its readme, registers itself with Claude Code, Cursor, VS Code and Windsurf, and adds hooks to Claude Code that suggest the compression tools when output grows large. It suits developers who run long agent sessions on big codebases or log files and want to keep token spend down.
Tools this server provides (12)
Taken from the project documentation; the running server may differ.
From the tool list in its README, going by the names, 1 of 12 tools changes data; 9 names don't say.
From the server's own tool labels and tool names; not verified by us.
- smart_readName suggests: reads
- Reads files with SHA-256 caching, outline mode and slice mode.
- compress_context
- Compresses logs, code and text while removing noise.
- session_budget
- Estimates context usage and can compress proactively.
- compress_image
- Resizes and compresses images to reduce vision tokens.
- compress_stacktrace
- Removes node_modules and library frames from stack traces.
- compress_csv
- Summarises CSV files by shape, types, statistics and a sample.
- compress_json
- Removes nulls, truncates long strings and limits large arrays.
- token_savings_report
- Reports tokens saved in the session and over history.
- cache_getName suggests: reads
- Looks up a stored response for a similar prompt.
- cache_setName suggests: changes
- Stores a computed response for later reuse.
- cache_report
- Reports cache entries, hits and tokens saved by reuse.
- cache_clear
- Deletes all cache entries.
What it does
- Cached file reads
- Re-reading an unchanged file returns the cached result instead of resending its full contents.
- Content compression
- Strips noise from logs, code, text, JSON, CSV and stack traces while keeping technical detail.
- Outline and slice reads
- Fetches only the structure or a chosen line range of large files.
- Semantic response cache
- Reuses earlier answers for prompts that closely resemble a stored one, with tag-based namespaces.
- Image downscaling
- Resizes and recompresses common image formats to reduce vision token usage.
- Savings dashboard
- Generates a local HTML report of tokens saved and estimated USD and BRL cost savings.
Good for
- Keeping long coding sessions within the context window when working with large logs
- Reading big source files in outline form before requesting specific sections
- Summarising large CSV or JSON files for an agent without sending the whole file
- Reusing answers to frequently repeated questions inside an agent workflow
- Tracking how many tokens an agent session has saved
Pricing
Open source
MIT licensed and free to install from npm.
Compress-token FAQ
How do I install Compress-token?
Run npm install -g compress-token. The installer registers the MCP server with the detected editors, and the editor needs a restart afterwards.
What are the requirements?
Node.js 18 or later. It runs on Windows, macOS and Linux.
Where is data stored?
Statistics and the semantic cache are kept as JSON files in the user's home directory. The stats file holds only token counters and savings percentages.
Is Compress-token free?
Yes. Compress-token is open source, so you can use and self-host it for free.
How do I add Compress-token to Claude Code?
Run this command in your terminal: claude mcp add compress-token -- npx -y compress-token
What are the best alternatives to Compress-token?
The closest alternatives to Compress-token are Token Optimizer MCP, Smart Context MCP, MCP Token Optimizer, Token Lens and Ai Optimizer.
Where this comes from
- Description: written from the project's README and its MCP Registry entry.
- Install steps: from the official MCP Registry entry.