slimctx-token-optimizer
Provides an MCP server that integrates with GitHub Copilot to compress context before sending to the LLM, reducing token usage while preserving reversible access to original content.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@slimctx-token-optimizerCompress the last 10,000 lines of logs keeping errors verbatim"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
slimctx — the token optimizer for AI agents
Zero-dependency, fully-reversible context compression for AI agents.
slimctx compresses what your agent reads — tool outputs, logs, JSON, source files, prose — before it reaches the LLM. Same answers, fraction of the tokens. Pure Python stdlib: no ML models, no downloads, no network calls, ever. Auditable end to end in ~1,600 lines.
from slimctx import Pipeline, Config
pipe = Pipeline(Config(target_tokens=32_000))
result = pipe.compress(messages) # OpenAI/Anthropic-style dicts
print(result.savings_ratio) # e.g. 0.82
original = pipe.retrieve("a1b2c3d4...") # byte-exact original, any timeResults (synthetic workloads modeled on real agent traffic)
Workload | Before | After | Savings | Key facts kept |
Code search (100 results) | 5,557 | 916 | 84% | ✓ |
SRE incident debugging | 61,699 | 298 | 100% | ✓ |
GitHub issue triage | 12,836 | 975 | 92% | ✓ |
Codebase exploration | 5,734 | 2,760 | 52% | ✓ |
Every run also verifies that each planted "needle" (the FIXME, the OOMKill,
the outlier) survives compression, and that every lossy transform is
byte-exact reversible. Reproduce with python3 benchmarks/bench.py.
Related MCP server: claw-tsaver
How it works
messages ──► ContentRouter ──► one of:
├─ JSON : lossless tabularization (repeated keys → header,
│ constant columns → legend), then relevance-ranked
│ row selection only if still over budget
├─ LOG : Drain-style template mining — repeated lines
│ collapse to `pattern [x1432]`; errors verbatim
├─ CODE : AST skeleton — signatures + docstrings kept,
│ bodies elided EXCEPT those relevant to the query
└─ TEXT : extractive sentence selection (BM25 + salience
+ position), verbatim, never paraphrasedThe four guarantees
Universal reversibility. Before any lossy transform, the original goes into a content-addressed store (memory / SQLite / bring-your-own cipher) and the output carries a
[slimctx-ref <hash> ...]marker. The model — or you — can always get the byte-exact original back.Errors are never dropped. Every compressor pins error/warning content: log errors pass verbatim, salient JSON rows are kept, salient sentences outrank filler.
Deterministic output. Same input → byte-identical output, across runs and processes. Compressed prefixes stay stable, so provider prompt-caches (Anthropic/OpenAI) keep hitting.
Net gain or no-op. If a transform doesn't save enough tokens to pay for its marker, the original is kept untouched. The live zone (system prompt + last N messages) is never modified at all.
Why not just use Headroom?
Headroom is the established project in this space and is more featureful today (provider proxy with SSE streaming, agent wrappers, cross-agent memory, an ML compression model). slimctx makes a different set of trade-offs, aimed at locked-down / client-site deployments:
Headroom | slimctx | |
Reversibility | JSON only (CCR); dropped text is gone | every lossy transform |
Log handling | generic text scoring | template mining ( |
Code handling | AST skeleton | AST skeleton + query-relevant bodies kept |
Dependencies | Rust core, ONNX runtime, 261MB HF model | stdlib only |
Network egress | HuggingFace pull on first run | none, ever |
Store encryption | none (plaintext SQLite) | cipher hook (bring your own) |
Determinism | cache-aligner component | by construction (pure functions + memo) |
Audit surface | ~10s of KLOC across 3 languages | ~1,200 lines of Python |
If you need the proxy/wrap ecosystem, use Headroom. If you need something you can read in an afternoon, run air-gapped, and certify for a client environment, use slimctx.
Install / test
pip install slimctx # from PyPI — or vendor the slimctx/ directory
python -m pytest tests/ -q # 26 tests: invariants, not examples
python3 benchmarks/bench.py # reproduce the numbers aboveIntegration sketches
As a library (any framework): call pipe.compress(messages) right
before your provider SDK call; expose pipe.retrieve as a tool named
retrieve so the model can pull originals.
As an MCP server (GitHub Copilot, Claude Code, Cursor, ...): ships built in, stdlib-only:
python3 -m slimctx.mcp_server --db ~/.slimctx/store.dbSee USAGE.md for the GitHub Copilot (.vscode/mcp.json) setup
and a security deployment checklist.
Encrypted store:
from cryptography.fernet import Fernet # optional, your choice
f = Fernet(key)
store = SqliteStore("ccr.db", cipher=(f.encrypt, f.decrypt))
pipe = Pipeline(store=store)License
Apache-2.0. Original implementation — no code derived from Headroom.
Available Tools
3 toolsslimctx_compressA
Compress large tool output, logs, JSON, or file content before reasoning over it. Returns a compact version that preserves errors, outliers, and query-relevant content. If the result contains a [slimctx-ref ...] marker, the full original can be recovered with slimctx_retrieve.
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Content to compress | |
| query | No | What you are looking for (steers relevance) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It reveals that the output is a compact version, preserves errors, outliers, and query-relevant content, and that recovery is possible via a [slimctx-ref ...] marker. This gives the agent meaningful expectations beyond the basic operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is three sentences, each serving a distinct purpose: first states the primary action, second explains what the output preserves, and third covers the recovery marker. It is front-loaded with the core purpose and contains no superfluous information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that there is no output schema, the description does a good job of explaining what the tool returns and its notable behavioral aspects, including preservation and recovery. It does not cover edge cases like missing query or size limits, but for a two-parameter tool, the description is sufficiently complete for an agent to invoke it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already provides 100% coverage of the parameters with clear descriptions ('Content to compress' and 'What you are looking for (steers relevance)'). The tool description adds limited new meaning, mainly aligning 'query-relevant content' with the query parameter. Since the schema does the heavy lifting, a baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's function: 'Compress large tool output, logs, JSON, or file content before reasoning over it.' It uses a specific verb and resource scope, and it distinguishes itself from the sibling tool slimctx_retrieve by explaining the recovery mechanism. This makes the purpose unmistakable and distinct.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear guidance on when to use the tool: before reasoning over large content. It also explains what to do after compression if a marker appears, pointing to slimctx_retrieve. However, it lacks explicit when-not-to-use guidance or comparison with slimctx_stats, so it stops short of a 5.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
slimctx_retrieveA
Recover the byte-exact original content for a [slimctx-ref ] marker seen in previously compressed output.
| Name | Required | Description | Default |
|---|---|---|---|
| ref | Yes | 24-char hex ref from a marker |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses the key behavior of returning 'byte-exact' content, which is valuable. However, it does not explicitly state that this is a read-only operation, nor does it describe error handling or what happens for invalid refs, leaving some transparency gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence that immediately states the core function. It is concise and free of extraneous content, making it easy for an agent to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
This is a simple tool with one parameter and no output schema. The description sufficiently explains the return value (the original content) and the input context. It does not mention edge cases like expired refs or session limitations, but given the low complexity, these are acceptable omissions.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema already covers the single parameter 'ref' with a clear description ('24-char hex ref from a marker'), and schema coverage is 100%. The description adds no significant semantic information beyond what the schema provides, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses the specific verb 'Recover' and names the exact resource ('byte-exact original content for a [slimctx-ref <ref>] marker'). It clearly distinguishes itself from sibling tools like slimctx_compress (which produces markers) and slimctx_stats (which provides statistics).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'seen in previously compressed output' provides clear context for when the tool should be used. It doesn't explicitly mention alternatives or when-not-to-use, but the context is unambiguous enough for a focused retrieval tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
slimctx_statsC
Token savings accumulated in this session.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must fully disclose behavioral traits. The text only states 'Token savings accumulated in this session' and gives no indication of side effects, read-only nature, or what happens upon invocation. This offers no meaningful behavioral transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely short, which contributes to conciseness, but it is a sentence fragment without a verb. This harms structural clarity, making it less effective than a concise sentence that conveys the action.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with no parameters, no annotations, and no output schema, the description is the only source of context. It fails to explain the tool's function, return value, or how it fits with sibling tools, leaving critical gaps for an agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has 0 parameters, and the schema is trivially complete (100% coverage). Per the rubric, 0 parameters earns a baseline of 4. The description need not elaborate on parameters, and it does not.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description is a noun phrase ('Token savings accumulated in this session') that identifies a resource but lacks an action verb. It does not state what the tool does (e.g., 'get' or 'display'), making the purpose vague and not clearly distinguishing it from sibling tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this tool versus alternatives. It does not mention any context, prerequisites, or exclusions, nor does it reference sibling tools (slimctx_compress, slimctx_retrieve). The agent is left without any direction for selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
3 tool updates
v0.1.0- First observed
slimctx_compress - First observed
slimctx_retrieve - First observed
slimctx_stats
TDQS
Each tool has a clearly distinct role: compress creates a reference, retrieve recovers original content from a reference, and stats reports session token savings. No overlap or ambiguity between them.
All tool names follow a consistent 'slimctx_' prefix followed by a clear verb: compress, retrieve, stats. The pattern is uniform and predictive.
Three tools is an ideal size for this focused server. Each tool is essential to the compression-retrieval-stats lifecycle, and no redundant or extraneous tools exist.
The tool surface fully covers the domain: compressing content, retrieving it when needed, and tracking token savings. There are no obvious workflow gaps for the stated purpose.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Cloud-hosted MCP server for durable AI memory
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
An MCP server that gives your AI access to the source code and docs of all public github repos
Related MCP Servers
- AlicenseAqualityAmaintenanceAn MCP server that preserves LLM context by intercepting large data outputs and returning only concise summaries or relevant sections. It enables efficient sandboxed code execution, file processing, and documentation indexing across multiple programming languages and authenticated CLIs.1117,96020,347Elastic 2.0
- AlicenseAqualityCmaintenanceAn MCP server that helps AI agents reduce token usage by compressing, summarizing, and managing conversation/context data more efficiently.11MIT
- AlicenseAqualityAmaintenanceLocal-first MCP server that gives any AI coding agent per-project memory, workflow intelligence, and always-on, lossless token & context optimization.37183MIT
- FlicenseNot gradedqualityCmaintenanceSemantic compression MCP server that reduces document token usage by 60-80% using structured symbolic notation, enabling Claude to efficiently store, retrieve, diff, and summarise documents across PRD, CODE, PAPER, and MEETING domains.-
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/omkar9854/token_optimizer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server