CtxSlim
CtxSlim
Your MCP servers are eating your context. Put them on a diet.
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.jsonOr drop a
ctxslim.jsonin 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:#fffOn connection, Slim aggregates every upstream server behind one surface.
In
automode it exposes only the top-K most relevant tools, plus asearch_toolsmeta-tool your agent uses to pull in anything else on demand โ progressive disclosure instead of a 40-tool firehose.Exposed schemas are compressed: boilerplate keywords stripped, descriptions trimmed to a budget, unused
$defsdropped โ measured with a chars/4 token estimator and reported back to you.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 |
| Semantic-ish BM25 search across all connected servers |
| Pin tools for the session so they're never swapped out |
| See what's connected and how healthy it is |
| Live report of tokens saved this session |
๐ Modes
Mode | Behavior |
| Top-K relevant tools per turn + meta tools. Default. |
| Only servers you allowlist, only tools you pin. Deterministic. |
| 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 + connectivitySession 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:
License
MIT ยฉ 2026
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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