Skip to content
MCP server

TokenSlim MCP — verifiable token reduction for agents

MCP server that trims and audits LLM context, reporting before/after token counts

Runs locally

TokenSlim MCP — verifiable token reduction for agents is an open-source MCP server for developer tools. It runs locally on your machine and is started by your AI client.

Pricing
Open source
Platforms
CLI, Self-hosted, API
Runs
Locally
Version
0.1.0
Listing updated

Similar MCP servers

Install

Add with the CLI

Run in a terminal

claude mcp add tokenslim-mcp -- uvx tokenslim-mcp

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

Or share it with your project

Add to .mcp.json

{
  "mcpServers": {
    "tokenslim-mcp": {
      "command": "uvx",
      "args": [
        "tokenslim-mcp"
      ]
    }
  }
}

Claude Code setup guide

Add to claude_desktop_config.json

{
  "mcpServers": {
    "tokenslim-mcp": {
      "command": "uvx",
      "args": [
        "tokenslim-mcp"
      ]
    }
  }
}

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

Claude Desktop setup guide

Install in CursorOpens Cursor, which asks you to confirm. Or add it by hand:

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "tokenslim-mcp": {
      "command": "uvx",
      "args": [
        "tokenslim-mcp"
      ]
    }
  }
}

Use .cursor/mcp.json in a project to share it with the project.

Cursor setup guide

Install in VS CodeOpens VS Code, which asks you to confirm. Or add it by hand:

Add to ~/.copilot/mcp-config.json

{
  "mcpServers": {
    "tokenslim-mcp": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "tokenslim-mcp"
      ]
    }
  }
}

Or put the same entry in .mcp.json at your workspace root to share it.

VS Code setup guide

Add with the CLI

Run in a terminal

codex mcp add tokenslim-mcp -- uvx tokenslim-mcp

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.tokenslim-mcp]
command = "uvx"
args = ["tokenslim-mcp"]

Codex setup guide

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

{
  "mcpServers": {
    "tokenslim-mcp": {
      "command": "uvx",
      "args": [
        "tokenslim-mcp"
      ]
    }
  }
}
  • Gemini CLI and Antigravity

    Gemini CLI

    Add to ~/.gemini/settings.json

    {
      "mcpServers": {
        "tokenslim-mcp": {
          "command": "uvx",
          "args": [
            "tokenslim-mcp"
          ]
        }
      }
    }

    Or run: gemini mcp add -s user tokenslim-mcp uvx -- tokenslim-mcp

    Antigravity

    Add to ~/.gemini/config/mcp_config.json

    {
      "mcpServers": {
        "tokenslim-mcp": {
          "command": "uvx",
          "args": [
            "tokenslim-mcp"
          ]
        }
      }
    }

    Use .agents/mcp_config.json to add it to one workspace only.

    Gemini CLI and Antigravity setup guide

  • Devin Desktop (formerly Windsurf)

    Add to ~/.config/devin/mcp_config.json

    {
      "mcpServers": {
        "tokenslim-mcp": {
          "command": "uvx",
          "args": [
            "tokenslim-mcp"
          ]
        }
      }
    }

    On Windows the file is %APPDATA%\devin\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

    Devin Desktop setup guide

  • Cline

    Add to cline_mcp_settings.json

    {
      "mcpServers": {
        "tokenslim-mcp": {
          "command": "uvx",
          "args": [
            "tokenslim-mcp"
          ]
        }
      }
    }

    Open it from the MCP Servers icon → Configure → Configure MCP Servers.

    Cline setup guide

  • Zed

    Add to Zed settings.json

    {
      "context_servers": {
        "tokenslim-mcp": {
          "command": "uvx",
          "args": [
            "tokenslim-mcp"
          ]
        }
      }
    }

    Open it with zed: open settings file. Merge context_servers into the settings you already have.

    Zed setup guide

  • JetBrains AI Assistant and Junie

    AI Assistant

    Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add

    {
      "mcpServers": {
        "tokenslim-mcp": {
          "command": "uvx",
          "args": [
            "tokenslim-mcp"
          ]
        }
      }
    }

    Junie

    Add to ~/.junie/mcp/mcp.json

    {
      "mcpServers": {
        "tokenslim-mcp": {
          "command": "uvx",
          "args": [
            "tokenslim-mcp"
          ]
        }
      }
    }

    Use .junie/mcp/mcp.json to share it with a project.

    JetBrains AI Assistant and Junie setup guide

  • Kiro

    Add to ~/.kiro/settings/mcp.json

    {
      "mcpServers": {
        "tokenslim-mcp": {
          "command": "uvx",
          "args": [
            "tokenslim-mcp"
          ]
        }
      }
    }

    Use .kiro/settings/mcp.json to add it to one workspace only.

    Kiro setup guide

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

About TokenSlim MCP — verifiable token reduction for agents

Its four tools cover the usual sources of bloat in an agent's context: auditing a message list to see where tokens go, compressing a prompt to a target rate while keeping named terms, shrinking a single tool output or log to a budget, and compacting a long message history. Every result includes token counts measured the same way before and after, so the saving can be checked from the output itself.

The underlying library is deterministic and model-free, with no API keys and no network calls. Compression is heuristic: code-like lines, numbers and caller-specified terms are protected, and an ERROR line buried in a long log is kept through trimming. Compaction summarizes older turns extractively and always respects the budget.

The server is aimed at developers running MCP clients such as Claude Code, Cursor or Codex who want to reduce token spend on tool-heavy sessions. Savings depend on how much of the context is tool output, and the server is stateless in this version.

Tools this server provides (4)

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

From the tool list in its README, going by the names, 4 names don't say.

From the server's own tool labels and tool names; not verified by us.

tokenslim_audit
Profile an OpenAI-style message list: where the tokens go.
tokenslim_compress
Compress a prompt to a target rate, protecting caller-named terms.
tokenslim_trim
Shrink one tool output or log to a token budget.
tokenslim_compact
Compact a message history to a budget.

What it does

Context audit
Profiles a message list by role, tool result share, largest messages and duplicate tool outputs.
Prompt compression
Compresses text to a target rate while protecting caller-named terms, code lines and numbers.
Tool output trimming
Cuts a log or tool output to a token budget by keeping its head, tail and highest-signal lines.
History compaction
Elides old tool results and summarizes older turns while keeping recent messages verbatim.
Verifiable token counts
Each result reports tokens before and after, produced by the same counter for both.
Offline counting option
Falls back to a chars/4 estimator when tiktoken is unavailable or disabled by environment variable.

Good for

  • Reducing token cost of long coding-agent sessions with bulky tool output
  • Trimming large build or application logs before passing them to a model
  • Checking which message types consume most of an agent's context window
  • Compacting a long conversation history to fit a fixed token budget
  • Compressing prompts while confirming that specific terms survive

Pricing

Open source

Free and MIT-licensed; self-hosted over stdio.

TokenSlim MCP — verifiable token reduction for agents FAQ

Does TokenSlim MCP — verifiable token reduction for agents call an LLM or external API?

No. The library is described as zero-dependency, deterministic and model-free, with no API keys and no network calls.

How do I install TokenSlim MCP — verifiable token reduction for agents?

Install from source with pip install . from the repository today; a PyPI release is planned. It runs over stdio and can be added to Claude Code with claude mcp add, or configured via uvx.

Are the results repeatable?

All four tools are described as read-only and deterministic: the same input gives the same output and counts.

Is TokenSlim MCP — verifiable token reduction for agents open source?

Yes, the server and the TokenSlim library are both released under the MIT licence.

Is TokenSlim MCP — verifiable token reduction for agents free?

Yes. TokenSlim MCP — verifiable token reduction for agents is open source, so you can use and self-host it for free.

How do I add TokenSlim MCP — verifiable token reduction for agents to Claude Code?

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

What are the best alternatives to TokenSlim MCP — verifiable token reduction for agents?

The closest alternatives to TokenSlim MCP — verifiable token reduction for agents are slimproof, Compress-token, Token Optimizer, Token Lens and MCP Token Optimizer.

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