Skip to main content
MCP server CX Codex

token-compressor — Claude Code MCP server: install and use

Shortens prompts by 40–60% using local models and guards against semantic drift with vector similarity checks before sending text to LLMs.

Install into Claude Code · Platform CLI All methods and platforms ↓
claude mcp add token-compressor -- uvx token-compressor-mcp
Open on GitHub

What token-compressor does

The server cuts prompt token size through a two-step local workflow. First, a local model cleans out conversational padding and redundancy while keeping negations and conditional clauses intact.

Next, an embedding check computes cosine similarity between the draft and the source text. If the score falls below the 0.85 threshold, the pipeline discards the rewrite and returns original text unchanged. Requests under 80 tokens bypass the process entirely.

Without a local Ollama daemon hosting llama3.2:1b and nomic-embed-text, every tool execution will fail. The package also requires Python 3.10+ alongside numpy and ollama.

What it helps with

  • cut LLM prompt token consumption
  • strip wordy boilerplate from system prompts
  • keep conditional rules intact during prompt rewrites
  • prevent semantic drift using embedding score checks

Example prompts for the agent

  • Run compress_prompt on this draft instruction and check the token count
  • Shorten this long workflow context via token-compressor before submitting

How to install token-compressor

Platform CLI

claude mcp add token-compressor -- uvx token-compressor-mcp

uvx runs the command named after the package; if the README names another one, use uvx --from token-compressor-mcp <command>

Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

Questions about token-compressor

How do I install token-compressor in Claude Code?

Run claude mcp add token-compressor -- uvx token-compressor-mcp. Make sure to pull llama3.2:1b and nomic-embed-text in Ollama beforehand.

What does token-compressor do?

It rewrites prompts using a compact local model to cut size by 40–60%, falling back to original phrasing if vector similarity drops under 0.85.

What prerequisites are required?

You need Python 3.10+, an active Ollama instance, and the llama3.2:1b and nomic-embed-text models. The Python environment must also have ollama and numpy installed.

Similar MCP servers

All MCP servers for Agent setup: memory, context, orchestration →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor