# Compress-token

> Compress-token is an open-source MCP server for developer tools. MCP server that cuts token use for AI coding agents via compression and caching. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, VS Code, Linux, macOS, Windows
- **Repository:** https://github.com/f7brasil/compress-token
- **MCP Registry name:** io.github.F7BRASIL/compress-token
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-27

## About

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.

## Features

- **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

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add compress-token -- npx -y compress-token
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```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.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add compress-token -- npx -y compress-token
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.compress-token]
command = "npx"
args = ["-y", "compress-token"]
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

Or run: gemini mcp add -s user compress-token npx -- -y compress-token

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```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 (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```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 (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "compress-token": {
      "command": "npx",
      "args": [
        "-y",
        "compress-token"
      ]
    }
  }
}
```

## Tools

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_read` (name 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_get` (name suggests: reads): Looks up a stored response for a similar prompt.
- `cache_set` (name 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.

## 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.

## Alternatives

- [Token Optimizer MCP](https://ai-powered.com/mcp/token-optimizer-mcp): Token Optimizer MCP is an MCP server for ai models and llm tooling.
- [Smart Context MCP](https://ai-powered.com/mcp/smart-context-mcp): Smart Context MCP is an open-source MCP server for developer tools.
- [MCP Token Optimizer](https://ai-powered.com/mcp/mcp-token-optimizer-2): MCP Token Optimizer is an open-source MCP server for developer tools.
- [Token Lens](https://ai-powered.com/mcp/token-lens-2): Token Lens is an open-source MCP server for developer tools.
- [Ai Optimizer](https://ai-powered.com/mcp/ai-optimizer): Ai Optimizer is a freemium MCP server for developer tools.
- [Distil](https://ai-powered.com/mcp/distil): Distil is an open-source MCP server for developer tools.
- [llmtrim](https://ai-powered.com/mcp/llmtrim): llmtrim is an open-source MCP server for ai models and llm tooling.
- [Token Optimizer](https://ai-powered.com/mcp/token-optimizer): Token Optimizer is an open-source MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/compress-token
