mcpfold

mcpfold
Native Tool Search only hides MCP schemas. mcpfold folds BOTH bloated schemas AND 30k-token JSON responses, chains multi-tool workflows into 1 turn, redacts leaked secrets, and compiles any MCP server into a standalone zero-dep CLI + SKILL.md.
Quick Start · Live Demo · Benchmarks · Why Not Tool Search? · Clients · Architecture
🎯 Why mcpfold?
Developers keep running into the exact same wall with MCP: enabling GitHub, Playwright, Postgres, or Linear burns 35,000–60,000+ tokens before you even type a prompt, and even after Claude Code and Cursor added deferred Tool Search, 3 huge bottlenecks remain broken:
Tool Output Explosion: A single
list_issues,query_rows, orbrowser_snapshotcall still dumps 10k–30k tokens of raw noisy JSON back into your context window.Slow Multi-Turn Round-Trips: Fetching a list, inspecting one record, reading comments, and summarizing wastes 4 separate slow LLM turns, re-sending context every round-trip.
Zero Output Security + Startup Lag: Community MCP responses pass raw API tokens (
ghp_,sk-) or hidden prompt injections straight to your model, while cold-starting multiple child servers eats seconds and RAM on every session.
mcpfold fixes all of them locally in 0 dependencies (MIT, no paid API keys):
Metric (48-Tool Enterprise Fixture) | Raw MCP | With | Savings |
Upfront schema tokens ( | 13,889 | 609 | -95.6% |
Compiled CLI + | 13,889 | 2,419 | -82.6% |
4-step workflow LLM round-trips ( | 4 turns | 1 turn | -75.0% |
Tool output payload tokens ( | 5,986 | 91 | -98.5% |
End-to-end 4-step session total | 61,542 | 700 | -98.9% |
Cold proxy startup ( | Spawns all servers | 5.41 ms | 0 startup spawns |
Security guard (secrets & prompt injections) | 0 caught | 3 secrets / 1 flagged | Protected |
Reproduce every single number on your own laptop in 3 seconds:
npx mcpfold bench
Related MCP server: wasmagent-mcp-server
🎬 Live Terminal Demo

📊 Verified Benchmarks & Token-Burn Graph
⚖️ Raw MCP vs. Native Tool Search vs. mcpfold
Capability | Raw MCP | Native Tool Search |
|
Hides bloated input schemas ( | ❌ | ✅ | ✅ |
Works uniformly on Claude Code, Antigravity & Cursor | ✅ | Claude/select harnesses | ✅ |
1-turn sandboxed chaining ( | ❌ | ❌ | ✅ |
Dot-path | ❌ | ❌ | ✅ |
Compile any MCP → standalone zero-dep CLI + | ❌ | ❌ | ✅ |
Secret redaction ( | ❌ | ❌ | ✅ |
| ❌ | Client-dependent | ✅ |
1-command multi-client X-Ray ( | ❌ | ❌ | ✅ |
🏗 Architecture
Cached Catalog (
sync): Probes downstream stdio servers once and caches schemas cleanly in.mcpfold/catalog.json. Proxy boot takes ~5.4 ms with 0 spawned child processes until a tool on that server is actually called.BM25 + Developer Synonym Search: Offline intent matcher splits
camelCase/snake_caseand resolves dev synonyms ("create pr"→open_pull_request,"db query"→postgres.query_rows).Two Modes You Can Switch Anytime:
mcpfold serve(Folded MCP Router): Exposes only 4 compact meta-tools (search_tools,inspect_tool,call_tool,pipe_tools) + optional--pinfast-path tools.mcpfold eject(MCP → CLI Compiler): Emits an executable zero-dependency.mjsCLI + tiny<server>.SKILL.mdcheat-sheet (-82.6%upfront tokens) for CLI-native workflows.
🚀 30-Second Quickstart
1. Audit your machine first (Read-Only X-Ray)
Scan Claude Code, Google Antigravity, and Cursor configs locally and generate a shareable dark-mode SVG scorecard + interactive HTML dashboard:
npx mcpfold audit --svg mcpfold-scorecard.svg --html mcpfold-report.htmlAdd --live to probe live tools/list schemas directly from configured servers.
| Metric | Raw MCP | With `mcpfold` | Delta |
| --- | ---: | ---: | ---: |
| Upfront schema tokens (48 tools) | 13,889 | 609 | **-95.6%** |
| Compiled CLI + `SKILL.md` tokens | 13,889 | 2,419 | **-82.6%** |
| 4-step workflow LLM turns | 4 | 1 | **-75%** |
| Tool output payload tokens | 5,986 | 91 | **-98.5%** |
| Total session tokens (schemas + payloads) | 61,542 | 700 | **-98.9%** |
| Cold proxy boot (cached catalog) | — | 5.41 ms | **0 child spawns** |
| Leaked secrets redacted / injections flagged | 0 caught | 3 secrets / 1 flags | **Protected** |2. Choose Your Mode
Option A — Folded Proxy + Safe Wrap (Claude Code, Google Antigravity, Cursor)
mcpfold wrap automatically saves a timestamped .mcpfold-backup.json before touching anything (mcpfold unwrap restores byte-for-byte anytime):
# Wrap all discovered clients (Claude Code, Antigravity, Cursor)
npx mcpfold wrap --client all
# Or target a single config file explicitly
npx mcpfold wrap --file ~/.gemini/antigravity/mcp_config.json
# Restore original config anytime
npx mcpfold unwrap --file ~/.gemini/antigravity/mcp_config.jsonOption B — Compile MCP Into Zero-Bloat CLI + SKILL.md (eject)
npx mcpfold sync --config .mcp.json
npx mcpfold eject --config .mcp.json --out ./ejected-tools
# Agents call tools with plain CLI commands (~82-95% less upfront schema context)
node ./ejected-tools/enterprise-cli.mjs --list
node ./ejected-tools/enterprise-cli.mjs summarize_sprint_notes --issueNumber 42💻 Quickstart by Client
{
"mcpServers": {
"mcpfold": {
"command": "npx",
"args": ["-y", "mcpfold", "serve", "--config", ".mcpfold/servers.json", "--pin", "read_file"]
}
}
}npx mcpfold sync --config ~/.gemini/antigravity/mcp_config.json
npx mcpfold wrap --client antigravitynpx mcpfold sync --config .cursor/mcp.json
npx mcpfold wrap --client cursor⚡ One-Turn Pipeline Example (pipe_tools)
Instead of spending 4 separate slow LLM turns pulling issues, details, comments, and notes, chain everything in 1 turn with field projection + automatic secret redaction:
{
"maxTokens": 320,
"steps": [
{
"id": "list",
"tool": "github.list_issues",
"args": { "repo": "core" },
"fields": ["number", "title"]
},
{
"id": "detail",
"tool": "github.get_issue",
"args": { "issueNumber": "{{list.items[0].number}}" },
"fields": ["number", "title", "user.login"]
}
]
}Or pass an isolated sandboxed script string using await call("server.tool", args) inside a hardened node:vm context with zero access to process, fs, require, or networking globals.
🛡️ Security Guard & Ecosystem
Credential Redaction: Automatically scrubs
ghp_/gho_/github_pat_,sk-, AWSAKIA, GoogleAIza, Slackxox*,Bearertokens, PEM private keys, and credential JSON keys before downstream payloads ever enter model context.Prompt-Injection & Steganography Sanitizer: Strips zero-width / bidirectional control characters (
\u200B-\u200F,\u202A-\u202E,\uFEFF) and flags suspicious instruction-hijack directives inside tool responses.Pair with
mcpprobe: Usemcpprobein CI to fuzz/audit your MCP server contracts, andmcpfoldin daily coding sessions to fold schemas, outputs, and round-trips.
📋 CLI Reference
Command | Purpose |
| Scan Claude Code, Antigravity & Cursor configs and export SVG/HTML X-Ray reports |
| Probe servers once and cache normalized tool catalog for |
| Start stdio folded MCP proxy ( |
| Compile MCP servers into standalone zero-dep |
| Run a 1-turn local tool pipeline directly from CLI |
| Safely replace client |
| Restore exact original client config from backup |
| Run deterministic 48-tool live benchmark fixture locally |
🛠 Development
git clone https://github.com/md1qamar/mcpfold.git
cd mcpfold
npm install
npm run typecheck
npm testsrc/tokenizer.ts— Deterministic token estimator, identifier splitter (camelCase,snake_case, dots), developer synonym map, and BM25 tool search index.src/compactor.ts— Dot-pathfieldsprojection, token-budget array slicing, base64 noise stripping, credential redactor, and prompt-injection/Unicode sanitizer.src/pipeline.ts— Single-turn declarative ({{step.path}}) and isolatednode:vmsandboxed pipeline executor (pipe_tools).src/stdio-client.ts— Zero-dependency NDJSON-RPC 2.0 client + lazy downstream process pool.src/compiler.ts— Standalone zero-dep MCP-to-CLI compiler + compactSKILL.mdemitter (mcpfold eject).src/proxy.ts—mcpfold servestdio MCP proxy exposing the 4 folded meta-tools +--pindirect tools.src/config.ts&src/audit.ts&src/visuals.ts— Claude Code / Antigravity / Cursor discovery, safewrap/unwrapbackups, terminal audit, SVG scorecards, and interactive HTML dashboard.
⭐ Support & Contributing
Found token waste with
npx mcpfold audit? Star this repo and share your before/aftermcpfold-scorecard.svg!PRs, new offline synonym packs, client discovery paths, and benchmark fixtures are welcome.
License
Available Tools
4 toolscall_toolC
Invoke a folded MCP tool with optional field projection, output token cap, and secret redaction.
Inputs: tool (required), args, fields, maxTokens.
inspect_toolARead-only
Get the exact JSON parameter schema for a folded tool before calling it.
Inputs: tool (required), server.
pipe_toolsB
Chain multiple MCP tool calls + filter/transform JSON locally in ONE turn inside a sandbox.
Inputs: steps, fields, script, maxTokens.
search_toolsARead-only
Search across all folded MCP tools by keyword or intent. Always run before call_tool.
Inputs: query (required), limit, server.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool maps to a distinct step in a discover→inspect→invoke workflow, and the descriptions reinforce ordering ('Always run before call_tool'). The only mild overlap is between call_tool and pipe_tools, since both ultimately execute folded tools, but the chaining/sandbox framing of pipe_tools separates them adequately.
All four names follow a strict snake_case verb_noun pattern (search_tools, inspect_tool, call_tool, pipe_tools) with a consistent plural/singular convention tied to whether the tool acts on one or many tools. No mixed styles or vague verbs.
Four tools is exactly the right scope for a folding/proxy server: discovery, schema inspection, single invocation, and chained invocation. Nothing feels padded or missing at the structural level.
The surface covers the full lifecycle of finding, understanding, calling, and composing folded tools, including projection, token caps, and redaction for output control. The main gap is the absence of an explicit list/browse operation for all folded tools or servers, forcing agents to rely on keyword search.
Maintenance
Related MCP Connectors
One MCP endpoint for Claude, GPT & Gemini: 100+ tools + no-code connectors + agent workers.
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA lightweight Claude MCP gateway that dynamically loads tools only when needed, cutting MCP token clutter by up to 95% and keeping your context lean, fast, and focused.7MIT
- AlicenseAqualityBmaintenanceCode-mode MCP server (docs_search + execute_code two-tool surface) backed by a unified capability manifest across three sandbox kernels (in-process node:vm, WASM via QuickJS / Pyodide / Wasmtime, and remote microVM via E2B / Cloudflare Sandbox). At N=30 tools the bootstrap-context cost drops to 13.6% of direct tool-use. Apache-2.0.27Apache 2.0
- AlicenseAqualityCmaintenanceMCP 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 gradedqualityBmaintenanceCompresses multi-turn conversation history by stripping verbose boilerplate and filler tokens while preserving critical tool parameters and named entities, deterministically cutting inference costs by 40-60%. Runs as a zero-dependency Python MCP server or importable module, compatible with Claude Desktop, Cursor, and other MCP runtimes.7MIT