Skip to content
MCP server

ctxprune

Local MCP server and CLI that shrinks logs, JSON and test output before an LLM reads them

Runs locally
Install
Pricing
Open source
Platforms
CLI, API, Linux
Runs
Locally
Version
0.3.2
Listing updated
today

Similar MCP servers

About ctxprune

ctxprune is an open-source MCP server for developer tools. It runs locally on your machine and is started by your AI client.

The README describes ctxprune as a local tool for reducing how many tokens an LLM reads from big logs, JSON dumps and test output. Its lossless mode rewrites tool output so it takes fewer tokens while every key and value can still be recovered, and a separate token-pruning mode deletes low-value words when a lossy result is acceptable.

As an MCP server it exposes two read tools, one lossless and one pruned, that run over stdio and read only the files a client asks for. The same functionality is available as a Python library with LangChain and LlamaIndex integrations, a command-line filter for piped output, and per-agent hooks for coding assistants such as Claude Code.

The README says nothing leaves the machine in the default preset and that the hooks use only the Python standard library. Its savings figures are measured on the author's own trace sets, and the author reports that lossy modes can change what an agent does next, so the lossless path is the default.

Install

Run in a terminal

claude mcp add ctxprune -- uvx ctxprune

Add to claude_desktop_config.json

{
  "mcpServers": {
    "ctxprune": {
      "command": "uvx",
      "args": [
        "ctxprune"
      ]
    }
  }
}
Install in CursorOpens Cursor, which asks you to confirm. Or add it by hand:

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "ctxprune": {
      "command": "uvx",
      "args": [
        "ctxprune"
      ]
    }
  }
}
Install in VS CodeOpens VS Code, which asks you to confirm. Or add it by hand:

Add to .vscode/mcp.json

{
  "servers": {
    "ctxprune": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "ctxprune"
      ]
    }
  }
}

Add to ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "ctxprune": {
      "command": "uvx",
      "args": [
        "ctxprune"
      ]
    }
  }
}

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "ctxprune": {
      "command": "uvx",
      "args": [
        "ctxprune"
      ]
    }
  }
}

Using several servers? Build one config file with the MCP config generator.

Tools this server provides (2)

Taken from the project documentation; the running server may differ.

read_compact
Reads a file through the lossless safe pipeline, with optional start and end lines.
read_pruned
Reads a file with token pruning at a chosen keep ratio, protecting identifiers by default.

What it does

Lossless output compaction
Rewrites large logs and JSON so the original content can be decoded back, with byte-exact checks on each rule.
Token pruning mode
Deletes low-value words at a chosen keep ratio, with an option to protect identifiers, numbers and paths.
Two MCP read tools
Provides read_compact and read_pruned tools to any MCP client over stdio.
Local-only operation
Runs on the local machine with no API key and no network calls in the default preset.
RAG pipeline integrations
Includes LangChain document compressor and LlamaIndex node postprocessor classes.
Command-line filter
Pipes command output through ctxprune with a set keep ratio from the shell.

Good for

  • Reading large JSON dumps or MCP results without filling the model context
  • Trimming test runner or CI output before pasting it into a chat
  • Compressing retrieved documents in a LangChain or LlamaIndex pipeline
  • Letting an MCP client read big log files through a compacted view

Pricing

Open source

Free open-source package (0BSD); no paid plan mentioned.

ctxprune FAQ

Does it send data anywhere?

The README says nothing leaves the machine and the safe preset makes no network calls. The token-pruning model is downloaded from Hugging Face on first use.

Is the lossless mode really lossless?

The README says the decoder returns the original bytes for most rules, and it lists exceptions such as ANSI colour removal and JSON whitespace compaction, which keep values but not exact bytes.

Which license does it use?

The README states the package is licensed under 0BSD, with earlier versions under Apache-2.0.

Is ctxprune free?

Yes. ctxprune is open source, so you can use and self-host it for free.

How do I add ctxprune to Claude Code?

Run this command in your terminal: claude mcp add ctxprune -- uvx ctxprune

What are the best alternatives to ctxprune?

The closest alternatives to ctxprune are MCP Token Optimizer, headroom, AsterMind MCP, OneTool MCP and Trace MCP.

Where this comes from

  • Description: written from the project's README and its MCP Registry entry.
  • Install steps: from the official MCP Registry entry.

How AIPoweredBot checks servers