Developer knowsuchagency released mcp2cli, a tool that reduces AI agent token consumption by 96-99% by converting API schemas into command-line interfaces at runtime. The approach addresses a critical inefficiency where MCP servers inject full tool schemas into context on every turn, consuming thousands of tokens whether the model uses them or not.
Traditional MCP Architecture Creates Massive Token Overhead
Standard MCP implementations embed complete tool schemas in every prompt. With 30 tools consuming approximately 3,600 tokens per turn, a 25-turn conversation with 120 tools generates 362,000 tokens purely for schema definitions. This overhead occurs regardless of whether the model actually invokes the tools.
Runtime CLI Generation Eliminates Schema Embedding
Instead of embedding schemas, mcp2cli constructs command-line interfaces on demand. The LLM discovers tools with mcp2cli --mcp https://mcp.example.com/sse --list (approximately 16 tokens per tool), requests help for specific tools with --help flags (approximately 120 tokens once), and executes commands directly. No code generation is required—all CLI interfaces are built at runtime through API introspection.
Multi-Format API Support With Authentication
The tool supports three API formats without configuration changes:
- OpenAPI specifications (JSON/YAML, local or remote)
- GraphQL with automatic introspection
- MCP over HTTP or stdio
Authentication mechanisms include header-based auth, OAuth authorization code with PKCE, and OAuth client credentials. Secret management supports environment variables and file-based injection.
Measured Token Reductions and Additional Optimizations
Using the cl100k_base tokenizer, mcp2cli demonstrates:
- 96% token reduction for 30 tools over 15 turns
- 99% token reduction for 120 tools over 25 turns
- Additional 40-60% reduction on result data through TOON encoding for large uniform arrays
The system includes tool filtering with glob patterns, caching with configurable TTL (default 3600 seconds), and bake mode for persisting connection configurations.
Installation and Framework Integration
Developers can install mcp2cli as a skill for AI coding agents with npx skills add knowsuchagency/mcp2cli --skill mcp2cli. The GitHub repository has accumulated 957 stars, indicating strong developer interest in production-ready token efficiency solutions.
Key Takeaways
- mcp2cli reduces AI agent token consumption by 96-99% by converting API schemas to runtime CLI interfaces
- Traditional MCP implementations waste 362,000 tokens over 25 turns with 120 tools purely on schema definitions
- The tool supports OpenAPI, GraphQL, and MCP formats with OAuth and header-based authentication
- Measured reductions show 96% savings for 30 tools over 15 turns and 99% for 120 tools over 25 turns
- Installation requires npx skills add knowsuchagency/mcp2cli with the GitHub repository at 957 stars