# lcc — Local Context Compiler

MCP server that compacts agent context without summarizing: removes spent tool outputs, stores them locally, and recalls them by hash.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 15
- Author: lucasmartins-ai
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/lucasmartins-ai/lcc
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/mcp/lcc-local-context-compiler

## What it does

The server cuts session context, keeping every user and assistant message byte for byte, while moving old tool outputs (a `read_file` result, build log, error trace) into a local content-addressed store at `~/.cache/lcc/stash`. The agent calls `recall` with an identifier and gets the exact text back. On a real Claude Code session of 193 messages and 75 tool calls, the server cut 57,083 tokens to 28,807 (−49.5%), preserving all 43 messages and removing 33 tool outputs. Median across 299 long sessions: 21.8% reduction.

Inside are three providers: `specialist-v3` (ranks blocks locally on CPU), `mechanical` (rule-based cuts), and `rules` (hybrid). The `stashed` mode writes a placeholder with line count and size, not tokens — identical on any machine. Each pass writes a JSON report; `lcc explain` shows the reason for every removed block. No FFmpeg, API keys, or network: judges run in Python, tokens are counted by `tiktoken` (`o200k_base`), storage is content-addressed.

In Claude Code, install it as a plugin with hooks (requires version 2.1.274+ and the `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1` flag) or as a standard MCP server via `uvx`. There's a CLI for checking any session or document.

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

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add lcc -- uvx local-context-compiler
```
uvx runs the command named after the package; if the README names another one, use uvx --from local-context-compiler <command>

### Codex

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

### Cursor

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

### GitHub Copilot

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

### Gemini CLI

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

## When to use it
- compact a long agent session without losing exact errors and paths
- recall a removed tool output by hash, verifying integrity
- count tokens in a Claude Code session offline, using `o200k_base`
- estimate how many tokens go to cache reads, tool results, and schema
- compact any document or notes on request, keeping what's relevant

## Example prompts
- Compact this session's context, `stashed` mode, `rules` provider
- Recall the removed output with identifier `<id>` using `recall`
- Count tokens in the session file `~/.claude/projects/<project>/<session>.jsonl` and show the median across all modes

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