Skip to main content
Glama
v01dst

CtxSlim

by v01dst

CtxSlim

Your MCP servers are eating your context. Put them on a diet.

npm version npm downloads CI license node PRs welcome stars

One config entry. Every MCP server you already have. A fraction of the context.


Every MCP server you connect dumps its entire tool catalog into your LLM's context โ€” every name, every description, every JSON Schema property. Connect a database server, a browser server and a GitHub server and you can burn 30,000+ tokens before you've asked a single question. Your responses get slower, your bill gets bigger, and your agent gets dumber because it's drowning in tool definitions it doesn't need.

CtxSlim is a proxy that fixes this. It sits between your MCP client and your servers, exposes only the tools that matter for the current task, and compresses the schemas of what it does expose โ€” with zero API keys, zero cloud calls, zero config rewriting.

๐Ÿ“Š Measured savings

Real numbers from the bundled benchmark (npm run bench), measured through actual MCP transports โ€” not marketing math:

Setup

Context before

After compression

With top-24 ranking

2 servers ร— 8 tools

7.4k tokens

โˆ’17.7%

โˆ’17.7%

4 servers ร— 10 tools

18.5k tokens

โˆ’17.7%

โˆ’50.6%

6 servers ร— 12 tools

33.4k tokens

โˆ’17.7%

โˆ’72.6%

The more servers you stack, the more Slim saves. And that's with modest schemas โ€” real-world servers (GitHub, Notion, browser automation) ship far heavier definitions.

โšก Quick start

Option 1 โ€” the one-liner. Let CtxSlim wire itself into your client:

npx -y ctxslim init                # shows what it found on your machine
npx -y ctxslim init --client cursor --yes   # writes it (with a backup first)

Option 2 โ€” manual. Replace your stack of MCP server entries with a single one:

{
  "mcpServers": {
    "ctxslim": {
      "command": "npx",
      "args": ["-y", "ctxslim"]
    }
  }
}

That's it. CtxSlim auto-discovers the servers already configured in your existing client config (read-only โ€” your files are never modified) and connects to all of them itself.

Works with:

  • Claude Desktop ยท Claude Code ยท Cursor ยท Windsurf ยท VS Code

  • Or point it at any config explicitly: npx -y ctxslim --config /path/to/mcp.json

  • Or drop a ctxslim.json in your project directory

{
  "mcpServers": {
    "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"] },
    "postgres": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"] }
  },
  "slim": {
    "mode": "auto",
    "maxTools": 24
  }
}

๐Ÿง  How it works

flowchart LR
    C[MCP Client<br/>Claude ยท Cursor ยท Codex] <--> S[CtxSlim<br/>stdio proxy]
    S <--> A[Server A<br/>files]
    S <--> B[Server B<br/>database]
    S <--> D[Server D<br/>browser]
    style S fill:#16a34a,stroke:#14532d,color:#fff
  1. On connection, Slim aggregates every upstream server behind one surface.

  2. In auto mode it exposes only the top-K most relevant tools, plus a search_tools meta-tool your agent uses to pull in anything else on demand โ€” progressive disclosure instead of a 40-tool firehose.

  3. Exposed schemas are compressed: boilerplate keywords stripped, descriptions trimmed to a budget, unused $defs dropped โ€” measured with a chars/4 token estimator and reported back to you.

  4. Tool calls are routed transparently to the right upstream server. Your agent can't tell the difference โ€” except its context is lighter.

Your agent gets four superpowers:

Meta tool

What it does

search_tools

Semantic-ish BM25 search across all connected servers

enable_tools

Pin tools for the session so they're never swapped out

list_servers

See what's connected and how healthy it is

slim_stats

Live report of tokens saved this session

๐ŸŽ› Modes

Mode

Behavior

auto

Top-K relevant tools per turn + meta tools. Default.

manual

Only servers you allowlist, only tools you pin. Deterministic.

off

Pure aggregation proxy โ€” every tool, uncompressed. Useful just to unify N servers behind one entry.

๐Ÿ›  CLI

ctxslim                       start the proxy
ctxslim init                  wire the proxy into a detected client config
                              (--client <name|path>, --yes to write, backup included)
ctxslim --config <path>       use a specific config
ctxslim --mode <mode>         auto | manual | off
ctxslim --max-tools <n>       override top-K (default 24)
ctxslim --no-stats            don't persist session stats
ctxslim --quiet               minimal logging
ctxslim stats                 show lifetime savings
ctxslim doctor                validate config + connectivity

Session stats live in ~/.ctxslim/stats.jsonl. Run ctxslim stats after a week of work and watch the cumulative savings.

๐Ÿ”’ Privacy

CtxSlim is 100% local. No API keys. No telemetry. No network calls except to the MCP servers you configure. Your tool definitions never leave your machine. The optional stats file stays on your disk and never leaves it.

โ“ FAQ

Does my agent really find tools that aren't exposed? Yes โ€” that's what search_tools is for. Modern agents call it when a task needs something outside the exposed set, get the full compressed schema back, and call the tool. Even if a model skips search and calls a known-but-hidden tool by name, Slim routes it anyway. Nothing is ever hard-blocked.

Why not just install fewer servers? Because you installed them for a reason. The problem isn't having tools โ€” it's paying for all of them in every single prompt.

What about tool-name collisions? If two servers expose the same tool name, Slim prefixes them (server__tool) and routes correctly.

Does it work with HTTP servers? Yes โ€” url entries are proxied via Streamable HTTP alongside stdio servers.

Where are the tests? 43 of them, covering the compressor, the ranking engine, config discovery and a full integration suite that speaks real MCP over real transports. npm test.

๐Ÿค Contributing

Contributions are genuinely welcome โ€” see CONTRIBUTING.md for the how and the why. The codebase is small, strict and comment-free on purpose; it's a nice one to read.

โญ Star history

If CtxSlim saved you tokens, a star helps other developers find it:

Star History Chart

License

MIT ยฉ 2026


Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/v01dst/ctxslim'

If you have feedback or need assistance with the MCP directory API, please join our Discord server