mcp-slim
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-slim
Put mcp-slim in front of any stdio MCP server and Claude gets the same tool results with 50–80% fewer tokens.
GitHub, Linear and most REST-backed MCP servers return raw API JSON: pretty-printed, full of nulls, node_ids, avatar links and a dozen *_url hypermedia fields per object. Claude pays for every one of those tokens and gets nothing from them. mcp-slim is a transparent stdio proxy that strips that noise before it reaches the model. There is nothing to change in the server and nothing to change in the client.
Claude Desktop / Claude Code ⇄ mcp-slim ⇄ any stdio MCP server
│
prune · cap · minify · redact secrets · slim schemas · dedupeIt does the following:
Compresses results from
tools/call,resources/readandprompts/get.Redacts leaked credentials, such as GitHub tokens,
sk-keys, AWS keys, Bearer headers and PEM private keys, before Claude sees them.Minifies tool schemas and descriptions in
tools/list, which clients re-send to the model on every turn.Deduplicates repeat calls. An identical result to an identical call becomes a one-line note.
Adds terse-mode instructions that ask Claude for short replies, which cuts output tokens.
Includes two built-in tools,
slim_fetchandslim_extract. It also runs standalone with no wrapped server, for example on Koyeb or Render, so Claude on mobile and the web can reach it.
Benchmark
These are realistic GitHub REST API payloads, generated deterministically by benchmark.py (python benchmark.py reproduces them):
Payload | Original Tokens | mcp-slim Tokens | % Saved |
GitHub | 29,179 | 11,804 | 59.5% |
GitHub | 9,043 | 3,488 | 61.4% |
GitHub | 4,655 | 1,006 | 78.4% |
GitHub | 96,814 | 20,086 | 79.3% |
GitHub | 89,875 | 14,055 | 84.4% |
GitHub | 23,925 | 11,633 | 51.4% |
Markdown README (plain text path) | 1,524 | 1,498 | 1.7% |
Total | 255,015 | 63,570 | 75.1% |
Tokens are estimated at about 4 characters per token, which is the same estimator the proxy uses for its footer. Most of the savings come from pruning, not whitespace: even JSON that is already minified shrinks by half. The search_issues row includes the 50-item array cap, which drops data. Every other row is lossless for the fields that remain. Plain prose has little to remove, and mcp-slim does not paraphrase or summarise.
Related MCP server: ShadowShield MCP
30-second quickstart
# Wrap any stdio MCP server: everything after `--` is the original command.
uvx mcp-slim -- npx -y @modelcontextprotocol/server-githubOr install it:
pip install mcp-slim # or: uv tool install mcp-slim
mcp-slim --helpEvery compressed tool result ends with one short line:
[mcp-slim: saved ~17,412 tokens · session total ~52,980]Pass --quiet to turn it off. The footer is only added when a call saves more tokens than the footer itself costs.
Run it with no command to get a standalone server that only has the built-in tools:
uvx mcp-slimSetup
Claude Desktop (claude_desktop_config.json)
Put mcp-slim -- in front of the server's existing command. Environment variables are passed through to the wrapped server.
{
"mcpServers": {
"github": {
"command": "uvx",
"args": ["mcp-slim", "--", "npx", "-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<your-token>"
}
},
"my-python-server": {
"command": "uvx",
"args": ["mcp-slim", "--config", "/Users/me/.mcpslim.json", "--", "python", "-m", "my_mcp_server"]
}
}
}Claude Code
claude mcp add github \
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
-- uvx mcp-slim -- npx -y @modelcontextprotocol/server-githubThe same works in a project .mcp.json:
{
"mcpServers": {
"github": {
"command": "uvx",
"args": ["mcp-slim", "--quiet", "--", "npx", "-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" }
}
}
}CLI reference
mcp-slim [--config PATH] [--quiet] [--verbose] [-- <command> [args...]]
(no command) standalone mode: serve only slim_fetch and slim_extract
--config PATH use this .mcpslim.json instead of auto-discovery
-q, --quiet don't append the tokens-saved footer
-v, --verbose debug logging (to stderr)
--version print the versionWhat gets compressed
MCP message | What mcp-slim does |
| Compresses and redacts text blocks, deduplicates repeat results and adds the footer |
| Compresses and redacts text contents |
| Compresses and redacts text message content |
| Strips |
| Truncates descriptions to 120 characters ( |
| Appends terse-mode instructions ( |
Images, audio, embedded binary resources, structuredContent, outputSchema and errors pass through untouched.
JSON payloads (a text block that parses as a JSON object or array):
Rule | Default |
Drop | on |
Drop noisy keys: | on |
…except keys in | on |
Cap arrays, adding a | 50 items |
Truncate long strings, adding a | 1500 chars |
Minify ( | on |
Empty items inside arrays are kept, so positional data such as table rows keeps its shape.
Plain text and Markdown: runs of blank lines collapse to one, and trailing whitespace is removed (Markdown hard line breaks are kept). Fenced code blocks (``` and ~~~) are preserved byte for byte.
If compression would not make a block smaller, the original is sent unchanged, after secret redaction.
Secret redaction (redact_secrets) replaces these patterns with [REDACTED:<kind>]:
Kind | Pattern |
|
|
| OpenAI- and Anthropic-style |
|
|
|
|
| PEM |
Redaction runs on every string inside JSON payloads and on plain text. It catches common accidental leaks, such as a config file, a CI log or an .env file read by a tool. It does not replace a secret scanner.
Schema minification (slim_schemas) strips annotations only. Property names are never touched, even when a property is called title or default. type, enum, required, minimum and similar validation keywords stay exactly as they were.
Deduplication (dedupe_calls) keeps a SHA-256 hash of each (tool name, arguments) pair and of its compressed result. The cache holds hashes only, never tool output. When the same call returns the same output again in a session, mcp-slim sends Unchanged from earlier in this session (see previous result). instead. Error results are never deduplicated. Turn this off if your client drops old tool results from context, for example after compaction, and you need the model to always see the full output.
Terse mode (terse_mode) appends this to the server's instructions, which clients pass to Claude:
Response style: be ultra-concise. No filler, no preamble, no restating the request, no closing summaries. Use bullet points or code blocks unless the user asks for prose.
This shapes how Claude writes, not only what tools return. Set "terse_mode": false if you want normal replies.
Built-in tools
Built-in tools are on by default (builtin_tools). In proxy mode they are added to the wrapped server's tools, and if the wrapped server has a tool with the same name, that tool wins. In standalone mode they are the only tools.
Tool | Arguments | Returns |
|
| The page as readable text, with |
|
| Only the paragraphs that match the keywords in |
Both tools are built on the standard library only (urllib, re, html). Because they can run on a public host, they are locked down:
Only
http://andhttps://URLs are allowed, and URLs with embedded credentials are refused.No internal targets. A host that resolves to a loopback, private (RFC 1918 or ULA), link-local (including the
169.254.169.254cloud metadata endpoint), carrier-grade NAT, multicast or reserved address is refused. Every redirect hop is checked again.Responses are capped at 2 MB, requests time out after 15 seconds, and binary content types are refused.
To fetch from a local dev server, set MCPSLIM_ALLOW_PRIVATE_URLS=1. Never set it on a public deployment.
Configuration (.mcpslim.json)
mcp-slim looks for config in this order: --config PATH, then the $MCPSLIM_CONFIG environment variable, then ./.mcpslim.json, then ~/.mcpslim.json. Every key is optional.
{
"ignore_keys": ["url", "reactions", "author_association", "debug_*"],
"keep_keys": ["node_id"],
"max_str_len": 4000,
"max_list_len": 100,
"max_desc_len": 200,
"skip_tools": ["get_file_contents", "raw_*"],
"use_default_keys": true,
"redact_secrets": true,
"slim_schemas": true,
"dedupe_calls": true,
"terse_mode": false,
"builtin_tools": true
}Key | Type | Meaning |
|
| Extra keys to drop. These are shell-style globs ( |
|
| Keys that are never dropped by key rules. This wins over |
|
| Truncate strings longer than this. |
|
| Cap arrays at this many items. |
|
| Maximum length of tool, schema and resource descriptions when |
|
| Tool-name globs whose results are never touched, including by redaction and deduplication. |
|
| Set to |
|
| Redact credentials in every compressed payload. Default |
|
| Minify |
|
| Replace repeated identical |
|
| Append ultra-concise reply instructions to the server instructions. Default |
|
| Expose |
Invalid config exits with code 2 and a clear message. Unknown keys log a warning.
Tip: On GitHub servers, adding
"url"toignore_keysdrops theapi.github.comself-link on every object for a few more percent. It isn't a default because for many other serversurlis the payload.
Remote deployment (Koyeb, Render, Claude mobile and web)
The included Dockerfile runs mcp-slim behind supergateway, which turns the stdio server into an HTTP/SSE endpoint on port 8000:
GET /sseis the event stream to connect to.POST /messagecarries client-to-server messages.GET /healthzis the health check.
docker build -t mcp-slim .
# Standalone: only slim_fetch and slim_extract
docker run --rm -p 8000:8000 mcp-slim
# Wrap a server: set TARGET_MCP_CMD and pass its credentials as env vars
docker run --rm -p 8000:8000 \
-e TARGET_MCP_CMD="npx -y @modelcontextprotocol/server-github" \
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
-e MCPSLIM_ARGS="--quiet" \
mcp-slimEnv var | Meaning |
| Optional. The stdio MCP server to wrap. If unset, mcp-slim runs standalone. |
| Optional. Extra mcp-slim flags, such as |
| The listen port. Default |
Koyeb: create a Web Service from your fork of this repo with the Dockerfile builder. Expose port 8000 over HTTP, set the health check to /healthz, and add TARGET_MCP_CMD and any tokens as secrets.
Render: create a Web Service from the repo with the Docker runtime. Render sets PORT, and the image respects it.
Connecting Claude: in claude.ai, open Settings → Connectors → Add custom connector and enter https://<your-app>/sse. Connectors added on claude.ai are also available in the Claude mobile apps.
⚠️ The SSE endpoint has no authentication. Anyone who learns the URL can call every tool it exposes. That includes a wrapped GitHub server acting with your token. Before you wrap anything with credentials, put the service behind an authenticating proxy or a private network, or at minimum use an unguessable hostname and treat the URL as a secret. Standalone mode exposes only the built-in fetch tools, which are guarded against internal targets as described above.
How it works
mcp-slim is built on the official mcp Python SDK and supports both the 1.x (≥ 1.10) and 2.x low-level APIs.
It spawns the wrapped command as a child process and connects to it as an MCP client (
ClientSessionover stdio). In standalone mode this step is skipped.It initialises the upstream server, then serves a low-level MCP server on its own stdin and stdout. That server mirrors the upstream's name, version, instructions and capabilities, plus
toolsfor the built-in tools.tools/list,tools/call,resources/list,resources/templates/list,resources/read,prompts/listandprompts/getare forwarded with their params untouched, including pagination cursors. Upstream JSON-RPC errors are relayed with their original code and message. Built-in tools are appended to the first page oftools/list.Results are slimmed on the way back, as described in What gets compressed.
The compression code (compressor.py) and the built-in tools (builtin_tools.py) use only the standard library.
stdout carries only JSON-RPC. All logging, including the wrapped server's stderr, goes to stderr, which MCP clients show as server logs.
Limitations
stdio only. To wrap a remote (HTTP/SSE) server, put a stdio bridge such as
mcp-remoteafter the--.structuredContentis not modified, because clients validate it against the tool'soutputSchema. Clients that show structured output to the model instead of the text blocks won't see savings for those tools.Server-to-client features are not relayed: progress notifications, sampling, elicitation, roots and
list_changednotifications are dropped. Tool calls still complete normally.Token counts are estimates (about 4 characters per token), not tokenizer-exact.
The fetch tools check DNS answers before connecting, but
urllibresolves the name again when it connects. A host that changes its DNS answer between those two lookups (DNS rebinding) can slip past the address check. On a public host, also block outbound traffic to private ranges at the network level.
Use it as a library
from mcp_slim import compress_payload, compress_schema, load_config, redact_secrets
text, saved = compress_payload(raw_json, load_config())
schema = compress_schema(tool_input_schema, max_desc_len=120)
clean = redact_secrets(log_text)Contributing
Contributions are welcome. Please open an issue before starting large changes.
git clone https://github.com/your-org/mcp-slim && cd mcp-slim
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest # unit tests plus end-to-end proxy tests
python benchmark.py # update the README table if numbers changeGuidelines:
Never write to stdout outside the MCP transport. Use
logging, which is configured to write to stderr.Compression must be safe by default. If a rule could drop information an LLM needs, make it opt-in through
.mcpslim.json.Add a test for every new rule, and a benchmark scenario for every new payload shape.
Keep
compressor.pyandbuiltin_tools.pyfree of third-party dependencies.
New default ignore_keys for other noisy APIs (Jira, Slack, Notion, …) are especially welcome. Include a sample payload in benchmark.py.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
A hosted MCP suite providing workflow primitives: web search, content fetching, compression, deduplication, cost/budget management, and agent memory pipelines.
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP proxy that compresses tool schemas on the fly. Up to 98% token reduction, 100% signal preserved verified after every compression. Zero LLM calls, fully deterministic.53MIT
- AlicenseNot gradedqualityDmaintenanceA local-first MCP server that reduces LLM token usage by intercepting, deduplicating, compressing, and optimizing MCP tool calls and responses.MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP-compatible developer environments to shrink verbose tool outputs—test logs, git diffs, directory listings, and file dumps—before they reach the context window, preserving compiler errors, failure signatures, and decisive anchors. It runs either as direct callable tools or as a transparent proxy wrapping other MCP servers such as filesystem, git, or terminal providers.24 PyPI1MIT
- AlicenseAqualityBmaintenanceToken-saving MCP proxy. Hides your MCP servers' tool lists behind a search tool and shrinks large tool results (GitHub, Playwright, logs, test output), keeping the full result available on request. One-command setup for Claude Code, Codex, Claude Desktop and Cursor.1053 PyPI2MIT