If you're running AI agents with MCP tools, you've felt the pain: every tool's full schema gets injected into the system prompt on every single turn. A 50-endpoint API burns 3,500+ tokens of context before your conversation even starts — and that bill repeats on every message.
mcp2cli fixes this.
It's a Python CLI that turns any MCP server or OpenAPI spec into a fully functional command-line tool — at runtime, with zero code generation. Instead of stuffing thousands of tokens of tool schemas into your AI's context window, your agent just shells out to mcp2cli and gets the exact data it needs.
The token savings are insane: 96–99% reduction in wasted schema tokens.
HOW IT WORKS
→ Point it at any MCP server (HTTP/SSE or stdio) or OpenAPI spec
→ It dynamically generates subcommands from the tool definitions
→ Your AI agent calls it like any other CLI tool — clean, fast, token-efficient
KEY FEATURES
→ Works with MCP servers AND OpenAPI specs (JSON or YAML)
→ Built-in OAuth support (PKCE flow, client credentials, token caching)
→ Secure secret handling (env: and file: prefixes — no secrets in process listings)
→ TOON output format — token-efficient encoding that cuts another 40-60% for LLM consumption
→ Smart caching with configurable TTL
→ Ships with an installable AI skill so Claude Code, Cursor, and Codex can use it natively
QUICK START
pip install mcp2cli
List tools from an MCP server:
Call a tool:
Use with OpenAPI specs:
If you're building with MCP or connecting AI agents to APIs, this is a no-brainer addition to your toolkit. Stop paying the token tax.