Skip to main content
MCP server CX Codex

densely — Claude Code MCP server: lossless context compression

Packs large logs, JSON and dumps into 2–8x fewer tokens. Expands them back byte for byte, with a sha256 check.

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

What densely does

densely runs text through lzma, splits the result into 16-bit chunks and maps them onto English carrier words. One such word costs a single token, so two bytes of compressed data fit into each one. A neural backend is available too: an integer arithmetic coder takes next-token probabilities from Qwen2.5-Coder-0.5B.

The agent gets three tools. compress_file(path) is meant to be called instead of reading a big log or JSON, and returns a preview plus the dense payload. compress_text(text) does the same for tool output already in hand. expand(payload | payload_file, start_line, end_line) gives the original back after verifying the hash; the line range keeps the agent from paying for the whole thing. A .dense sidecar lands next to the original — plain text you can commit or archive.

Install with pip install "densely[mcp]"; the neural backend needs the [neural] extra, which pulls in torch and transformers. For hands-off use there is a PostToolUse hook that compresses Bash output and reads of non-code files from 5000 tokens up, with DENSELY_HOOK_MIN_TOKENS as the knob. Point ~/.claude/settings.json at an absolute path to densely-hook, since hooks run outside your PATH. Code files the agent is editing are left alone.

What it helps with

  • fit a huge log into context without losing lines
  • restore the original JSON from a payload byte for byte
  • pull just one line range out of a payload
  • compress Bash output automatically instead of calling a tool by hand
  • see how many tokens a session saved

Example prompts for the agent

  • Compress install.log and show me the preview, don't read the whole thing
  • Expand lines 200 to 260 from payload.dense
  • How many tokens have we saved this session?

How to install densely

Platform CLI

claude mcp add densely -- uvx densely

uvx runs the command named after the package; if the README names another one, use uvx --from densely <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 densely

How do I install densely in Claude Code?

Run claude mcp add densely -- uvx densely. The compression itself needs the package: pip install "densely[mcp]".

What does densely do?

It shrinks text to 2–8x fewer tokens and rebuilds it losslessly, checking sha256 on every expand. The MCP server exposes three tools: compress a file, compress text, and expand.

How is this different from dropping content from context?

The data stays in the context itself and comes back byte-exact, with no external cache and no expiry. Compression below the entropy of the data is impossible, so the gain stops at that bound.

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