Skip to main content

mcptoon

Stop editing JSON for every agent. Add MCP tools once, use them everywhere.

Cursor wants .mcp.json. Claude Code wants .claude.json. Codex wants AGENTS.md. Same tool, configured three times โ€” one missing comma breaks everything.

mcptoon fixes this. Configure MCP servers once. Every agent uses them. No JSON editing. No restarts. No context window pollution.

PyPI Python 3.10+ License: Apache 2.0 Zero Dependencies Tests

๐Ÿ‘‰ pip install mcptoon ยท English ยท ไธญๆ–‡ๆ–‡ๆกฃ ยท Report Bug


The problem: MCP config hell

Every AI agent has its own MCP config format. Adding a tool means:

Agent Config file Format What breaks
Claude Code .claude.json JSON One missing comma = all tools stop working
Cursor .mcp.json JSON One wrong field = silent failure
Codex AGENTS.md Markdown One typo = agent ignores your tools
VS Code Copilot settings.json JSON Wrong nesting = MCP doesn't load

The reality: You have 3+ agents on your machine. Same MCP server, configured 3 times, in 3 different formats. Update one? Forget to update the others. Now they're out of sync.

"I just want to add a new MCP service. Why is it like going through hell?" โ€” A real developer


The fix: one command, all agents

pip install mcptoon                          # zero deps, ~250KB

# Add any MCP server โ€” one command:
mcptoon add fetch --stdio npx -y @modelcontextprotocol/server-fetch

# Call from any agent โ€” Claude Code, Cursor, Codex, anything:
mcptoon call fetch fetch '{"url":"https://example.com"}'

That's it. No .claude.json editing. No .mcp.json editing. No AGENTS.md editing.

Configure once in ~/.mcptoon/config.json. Every agent calls mcptoon via shell. Switch agents tomorrow โ€” your tools are still there, zero reconfiguration.

Benchmark: 255 tools, 90,804 โ†’ 117 tokens (tiktoken cl100k_base)

Demo: mcptoon in action


MCP security firewall (built-in)

MCP servers can execute code on your machine. mcptoon is the firewall.

Current MCP security landscape:

  • MCPoison (Check Point): Cursor RCE via MCP config tampering
  • Tool Poisoning (Invariant Labs): Malicious instructions in tool responses โ€” affects all major platforms
  • 50 known CVEs in MCP ecosystem, 13 critical
  • 200,000+ MCP servers exposed to RCE risk (OX Security)

mcptoon blocks these attacks with three layers โ€” all built-in, zero config:

Layer What it does Attack blocked
Prompt injection guard Scans tool results for injection patterns "ignore previous instructions" โ†’ blocked
Credential leak guard Scans results for exposed API keys/tokens sk-abc..., AKIA..., ghp_... โ†’ blocked
Dangerous-op blocker Blocks delete/drop/purge by default docker_remove โ†’ blocked unless --destructive
  • No telemetry. No analytics, no crash reports, no phone-home.
  • No credential storage. API keys pass through from your config or env vars.
  • No dependencies. Pure Python stdlib. No supply chain to audit.

30-second quick start

pip install mcptoon                          # zero deps, ~250KB

# Add any MCP server โ€” one command:
mcptoon add fetch --stdio npx -y @modelcontextprotocol/server-fetch

# See all available tools (117 tokens for 255 tools):
mcptoon manifest --compact

# Call a tool:
mcptoon call fetch fetch '{"url":"https://example.com"}'

# Or let mcptoon discover servers already on your machine:
mcptoon quickstart     # auto-discover + configure + show tools โ€” all in one command

Used by

Building something with mcptoon? Open an issue to be listed here.


Works with shell-capable AI agents

mcptoon is a CLI tool, not an MCP Server. It does not plug into mcpServers JSON config. Instead, your agent calls mcptoon via shell commands โ€” schemas stay out of context.

Agent How to use
Claude Code Write mcptoon commands in SKILL.md files
Codex (OpenAI) Add mcptoon to AGENTS.md
Cursor Add mcptoon to .cursorrules (agent generates shell commands)
OpenCode Use mcptoon in custom commands
Any agent If it runs shell commands, it can call mcptoon

Configure once in ~/.mcptoon/config.json. Every agent shares the same servers and tools. Switch agents โ€” config follows you.


Token savings (bonus, not the point)

mcptoon keeps tool schemas outside your agent's context window. This is a side benefit of the CLI architecture โ€” not the main selling point.

Tools JSON schemas in context mcptoon compact Savings
5 1,897 tokens 16 tokens 99%
50 17,790 tokens 117 tokens 99%
255 90,804 tokens 117 tokens 99.9%
  • --compact โ†’ tool names only: 99.9% savings (tiktoken cl100k_base)
  • --slim โ†’ tool schemas with params: 93% savings
  • --json โ†’ standard JSON (default)
  • --toon โ†’ TOON encoding (optional, 30-40% savings)
Output formats reference
Flag What you get Token savings
--compact Tool names only 99.9% vs JSON (tiktoken)
--slim Tool schemas (name|param:type*) 93% vs JSON
--json Standard JSON (default) Baseline
--toon TOON encoding (toon-format v4.1 spec) 30-40% vs JSON
--raw Raw response Full size
--head N First N items only Variable
--max-chars N Truncate at N chars Variable
--full Disable default 4000-char truncation Full size
--stdin Read args from stdin (large payloads) โ€”
--fallback-json Fall back to JSON if TOON encoding errors Safety net
What is TOON? (optional reading)

TOON (Token-Oriented Object Notation) is an open data format specification by Johann Schopplich (toon-format/toon, 25K+ stars). It's designed to reduce token consumption when feeding structured data to LLMs.

mcptoon vendors python-toon v0.1.1 (MIT) for spec-compliant encoding. TOON is optional โ€” mcptoon defaults to JSON and works perfectly without TOON.


Install MCP servers โ€” one command each

# From npm (most MCP servers live here):
mcptoon install brave-search --npm @anthropic/mcp-server-brave-search

# From pip:
mcptoon install my-tool --pip mcp-my-tool

# HTTP/SSE server:
mcptoon install remote-api --url https://example.com/mcp

# List what you have:
mcptoon install --list

# Remove:
mcptoon install --remove brave-search

mcptoon auto-connects, discovers tools, generates a handler, and registers it. No restart needed.


All commands

mcptoon quickstart              # one-command onboarding (discover + configure + show tools)
mcptoon init --auto             # auto-discover MCP servers on your machine
mcptoon add <name> --stdio npx -y <package>   # add any MCP server
mcptoon install <name> --npm <package>        # install + auto-generate handler
mcptoon list                    # show configured servers
mcptoon manifest --compact      # all tool names (117 tokens for 255 tools)
mcptoon manifest --slim         # tool schemas (93% smaller than JSON)
mcptoon inspect <server> <tool> # show one tool's schema
mcptoon search <query>          # search tools across all servers
mcptoon call <server> <tool> '{"args":"here"}'   # call a tool
mcptoon call --auto <tool> '{"args":"here"}'     # auto-find the server
mcptoon sync                   # sync config to all agents (Claude Desktop, Cursor, etc.)
mcptoon sync --dry             # preview what would be written
mcptoon sync --agent cursor    # sync to one agent only
mcptoon health                 # health check all servers (catches zombie servers)
mcptoon health --json           # JSON output for CI/CD (exit 1 if any dead)
mcptoon serve                  # run as stdio MCP server (1 Agent โ†’ 100 servers)
mcptoon doctor                  # self-diagnose: Python, config, connectivity
mcptoon usage                   # local-only call statistics
mcptoon completion bash         # shell completion (bash/zsh/fish/ps)

Sync config to all agents

Configure once in mcptoon, sync to every agent automatically:

mcptoon sync                 # writes to Claude Desktop, Cursor, Cline, Windsurf, VS Code Copilot
mcptoon sync --dry           # preview without writing
mcptoon sync --agent cursor  # sync to one agent only

mcptoon detects which agents you have installed and writes their native config format. No more editing .claude.json, .cursor/mcp.json, or settings.json by hand. Update in mcptoon โ†’ sync โ†’ all agents see the same servers.


Health check (catch zombie servers)

52% of MCP servers are unreachable (source). Check before you use:

mcptoon health                 # check all servers: alive, dead, latency, tool count
mcptoon health --timeout 5     # 5s timeout per server
mcptoon health --json           # JSON for CI/CD (exits 1 if any dead)

Output:

โ”€โ”€ mcptoon health: 3/5 alive, 2 dead โ”€โ”€

  โœ“ fetch     [stdio]   3 tools    120ms  ok
  โœ— brave     [stdio]   0 tools  10002ms  timeout โ†’ Timed out after 10s
  โœ“ github    [http]   12 tools    340ms  ok
  โœ— broken    [stdio]   0 tools    500ms  error โ†’ Connection refused

Perfect for CI/CD: mcptoon health --json || exit 1 in your pipeline.


Run as MCP server (serve mode)

mcptoon can also act as a single MCP server in front of your agent โ€” proxying all underlying servers with safety checks:

// In your agent's mcpServers config:
"mcptoon": {
  "command": "mcptoon",
  "args": ["serve"]
}
  • Agent connects to 1 server (mcptoon), not 100 individual servers
  • All tool calls pass through mcptoon's security firewall (prompt injection + credential leak detection)
  • Parallel manifest loading: 100 servers in ~5s
  • Per-call timeout: no single server can hang the bridge
  • Tool namespacing: {server}_{tool} prevents conflicts
mcptoon serve                  # stdio mode (for Claude Code, Cursor, etc.)
mcptoon serve --listen :8080   # HTTP mode (for remote/multi-agent)
mcptoon serve --auth <token>    # HTTP mode with Bearer token auth

How it works

mcptoon is a CLI tool, not an MCP client library or MCP Server. Your agent doesn't connect to MCP servers โ€” it runs mcptoon commands. Schemas live on disk in ~/.mcptoon/config.json, not in your context window.

Two layers, fully decoupled:

Layer 1: mcptoon CLI (~200KB, zero deps)
         Runs in your agent's shell. No schemas in context. Ever.
                    โ”‚
Layer 2: Actual MCP Servers (npm/pip packages)
         Launched on-demand only when you call a tool. Zero overhead until use.
  • 1,000 servers configured โ†’ 0 running until you use one
  • mcptoon ships zero bundled servers โ€” you add what you want, one command each
  • Delete mcptoon? Your MCP servers keep working independently

Python API

from mcptoon.client import MCPClient
from mcptoon.output import toon_encode, toon_decode

with MCPClient(stdio=["npx", "-y", "@modelcontextprotocol/server-fetch"]) as c:
    tools = c.list_tools()
    result = c.call_tool("fetch", {"url": "https://example.com"})

Architecture

src/mcptoon/
โ”œโ”€โ”€ cli.py        # CLI entry + arg parsing
โ”œโ”€โ”€ client.py     # MCPClient โ€” stdio + HTTP transport
โ”œโ”€โ”€ installer.py  # One-command MCP server installation + auto-handler
โ”œโ”€โ”€ router.py     # Tool routing + poisoning/credential leak detection
โ”œโ”€โ”€ config.py     # Server config (JSON + TOML)
โ”œโ”€โ”€ manifest.py   # Tool discovery with cache + cross-server search
โ”œโ”€โ”€ discover.py   # Zero-config auto-discovery (4-layer)
โ”œโ”€โ”€ output.py     # TOON (vendored python-toon) + compact/slim rendering
โ”œโ”€โ”€ toon_vendored.py  # Vendored spec-compliant TOON encoder/decoder (MIT)
โ”œโ”€โ”€ cache.py      # Schema cache (5-min TTL)
โ”œโ”€โ”€ sync.py       # Config sync to AI agents (Claude Desktop, Cursor, Cline, etc.)
โ”œโ”€โ”€ health.py     # Batch health check for all MCP servers
โ”œโ”€โ”€ usage.py      # Local usage tracking
โ””โ”€โ”€ errors.py     # Structured error envelopes + fix suggestions

~6,800 lines. 513 tests. Zero third-party imports. ~250KB source.


Docker

docker build -t mcptoon .
docker run --rm mcptoon help
docker run --rm -v ~/.mcptoon:/root/.mcptoon mcptoon manifest --compact

Contributing

git clone https://github.com/activeing123/mcptoon.git
cd mcptoon
pip install -e . --no-build-isolation
pip install pytest pytest-cov
python -m pytest tests/ -v   # 513 tests, 0.5s

Zero dependencies is a hard rule. New features need tests. See CONTRIBUTING.md.


License

Apache 2.0. See LICENSE and NOTICE.


mcptoon is an independent third-party MCP client. Not affiliated with Anthropic.

Found this useful? Star the repo to help others find it.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcptoon-0.5.4.tar.gz (124.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcptoon-0.5.4-py3-none-any.whl (98.9 kB view details)

Uploaded Python 3

File details

Details for the file mcptoon-0.5.4.tar.gz.

File metadata

  • Download URL: mcptoon-0.5.4.tar.gz
  • Upload date:
  • Size: 124.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for mcptoon-0.5.4.tar.gz
Algorithm Hash digest
SHA256 ed0a15bce413d62d1e93d6b1b985af860985360dc0c9b6d0a600ff3be0a029e0
MD5 884776bfdd4b4ca68bedd54da7fbee1e
BLAKE2b-256 9766ff8b7195a16bb538d91c130acf25c97fdf940790d2068606077241d6b94b

See more details on using hashes here.

File details

Details for the file mcptoon-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: mcptoon-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 98.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for mcptoon-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1793b9d2df6de46d74ac5c58a9a10fb49ed723a0c99b7031fe13b0924ecfa1fe
MD5 9847c5f2b58d909758652e167098a83b
BLAKE2b-256 8247f7d8ff7c82786509150b8c3f7925ce2b4e6655e71353bf13d065845a93ab

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.6

2 files

0.5.5

2 files

This release

0.5.4 This release

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page