# densely

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

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 8
- Author: alibaizhanov
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/alibaizhanov/densely
- Updated: 2026-08-13
- HTML: https://affpapa.org/en/nevibecode/mcp/densely

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

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
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>

### Codex

**Platform CLI**
```bash
codex mcp add densely -- uvx densely
```
uvx runs the command named after the package; if the README names another one, use uvx --from densely <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "densely": {
            "command": "uvx",
            "args": [
                "densely"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from densely <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "densely": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "densely"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from densely <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add densely uvx densely
```
uvx runs the command named after the package; if the README names another one, use uvx --from densely <command>

## When to use it
- 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
- 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?

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 386989
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81115
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119160
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43872

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
