Skip to main content
MCP server CX Codex

lcc — Claude Code MCP server: lossless context compaction

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

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

What lcc — Local Context Compiler 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.

What it helps with

  • 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 for the agent

  • 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

How to install lcc — Local Context Compiler

Platform CLI

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>

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 lcc — Local Context Compiler

How do I install lcc in Claude Code?

Set the flag export CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1, then run claude plugin marketplace add lucasmartins-ai/lcc and claude plugin install lcc@lcc --config provider=rules --config rulesMode=stashed. Allow the tool mcp__plugin_lcc_lcc__recall so the agent can retrieve removed outputs.

What does lcc do?

Compacts agent session context by removing spent tool outputs (logs, files, errors) while storing them locally. All user and assistant messages stay byte for byte. The agent calls recall with a hash and gets the exact output text back.

How does lcc differ from /compact in Claude Code?

The built-in /compact command rewrites the session with a model summary, losing exact error lines and paths. lcc keeps all messages as written and only removes old tool outputs, storing them in a local cache. On a test session of 193 messages, /compact replaced everything with one summary; lcc cut 49.5% while preserving 43 out of 43 messages.

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