Repository navigation
mcp-slim: Zero-dependency MCP stdio proxy & CLI profiler (-50% to -98.7% schema tokens, $ref inlining, SecretGuard) #6459
Replies: 2 comments 1 reply
|
One concrete compatibility case for the benchmark: the root-union fixture starts with A useful paired test would send an org-only request, an id+org request and a slug+org request through both paths, then compare server acceptance and model retries. For This is source inspection and a proposed test, not an executed result. AI-assisted reply, posted by Codex on Shabbir's behalf. |
|
@shabbiryk Great catch on that root-union semantic gap. Intersecting Just shipped
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
While building and benchmarking FastMCP servers with 40 to 60+ tools, we kept hitting two recurring pain points across different LLM providers and MCP clients:
tools/listschema token tax: Autogenerated Pydantic/JSON schemas ($defs/$refpointer trees, repeatedtitlefields, verbose docstrings, and voidoutputSchema: {"result": {"type": "null"}}from postponed-> Noneannotations) easily consume 8,000 to 15,000+ prompt tokens on every single turn.$defs/$ref,["string", "null"]nullable type arrays, or root-levelanyOf/oneOf, while smaller models frequently pass stringified scalars ("limit": "25") or slight parameter name typos (per_pagevsperPage,filtersvsfilter).To solve this transparently at the stdio boundary without touching server code, we built mcp-slim, a zero-dependency Python 3.10+ MCP JSON-RPC 2.0 proxy and CLI profiler.
What
mcp-slimdoes out of the box-49.6%to-53.9%tokens): Recursively inlines local$defs/$refdefinitions, collapses nullable["T", "null"]type arrays, flattens rootanyOf/oneOf/allOfobject branches, strips FastMCP voidoutputSchema/x-fastmcp-wrap-resultmetadata, and deterministically sorts keys to maximize LLM prompt KV-cache hits.--lazy,-98.7%tokens): Replaces 50+ static tool declarations with 2 lightweight meta-tools (mcp_search_toolsusing zero-dependency BM25 +mcp_call_tool), shrinking a 60-tool12,512-token catalog down to168tokens."42" -> 42,"true" -> True, stringified JSON arrays/objects, andsnake_case/camelCaseor singular/plural argument typos before forwardingtools/callto FastMCP (can be toggled off with--no-coercefor raw benchmarks).EmbeddedResourceFlattening: Compacts JSON/JSONL/Markdown tables, elides middle log lines while preserving head/tail stack traces, and flattens textEmbeddedResourceblocks for clients that only readTextContent.SecretGuard: Redacts leaked API keys (sk-ant-,ghp_,AKIA,hf_), URL query secrets (?token=,?private_token=,X-Amz-Signature=), and<IMPORTANT>prompt-injection blocks in real time.Quick Start
Repository & benchmarks: https://github.com/SalyyS1/mcp-slim
If you find this useful for profiling or slimming down your FastMCP servers, a star on SalyyS1/mcp-slim is really appreciated. Feedback and benchmark ideas are very welcome!
All reactions