ScriptsApr 6, 2026·2 min read

mcp2cli — Turn MCP Servers into CLI Tools, Zero Codegen

Convert any MCP server, OpenAPI spec, or GraphQL endpoint into a full CLI at runtime. Saves 96-99% of tokens wasted on tool schemas every turn.

MC
MCP Hub · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

  1. Install via uv: uv tool install mcp2cli
  2. Run: mcp2cli --server your-mcp-server
  3. All MCP tools become CLI commands instantly

Or run directly without installing:

uvx mcp2cli --help

Intro

mcp2cli is a developer tool that turns any MCP server, OpenAPI spec, or GraphQL endpoint into a command-line interface at runtime — no code generation needed. With 1,900+ GitHub stars and MIT license, it saves 96–99% of the tokens wasted on tool schemas every turn by using usage-aware tool ranking. Works with Claude Code, Cursor, and any MCP-compatible AI tool.

Best for: developers who use multiple MCP servers and want to reduce token overhead. Works with: Claude Code, Cursor, any MCP client. Setup time: under 1 minute.


mcp2cli — Runtime CLI from Any API

Key Features

  • Zero Codegen: No code generation step — MCP tools become CLI commands instantly
  • Multi-Protocol: Supports MCP servers (stdio/SSE), OpenAPI specs, and GraphQL endpoints
  • Token Savings: Usage-aware tool ranking saves 96–99% of tokens wasted on schema overhead
  • Built-in OAuth: OAuth support across all API types
  • Bake Mode: Save connection configurations for repeated use
  • Output Filtering: jq support and TOON encoding for LLM-efficient output
  • Caching: Customizable TTL caching for repeated queries

Installation

# Option 1: Direct execution (no install)
uvx mcp2cli --help

# Option 2: Global install
uv tool install mcp2cli

# Option 3: pip
pip install mcp2cli

Usage Examples

# Connect to an MCP server
mcp2cli --server my-mcp-server

# Use with OpenAPI spec
mcp2cli --openapi https://api.example.com/openapi.json

# Use with GraphQL
mcp2cli --graphql https://api.example.com/graphql

# Bake a connection for reuse
mcp2cli bake my-server --server my-mcp-server

How It Works

mcp2cli introspects the target API at runtime, discovers all available tools/endpoints, and generates CLI commands dynamically. The usage-aware ranking system tracks which tools you use most and prioritizes them, dramatically reducing the token cost of tool schemas in every conversation turn.

FAQ

Q: What is mcp2cli? A: mcp2cli is a CLI tool that converts MCP servers, OpenAPI specs, and GraphQL endpoints into command-line interfaces at runtime without code generation, saving 96–99% of tokens on tool schemas.

Q: Is mcp2cli free? A: Yes, mcp2cli is free and open source under the MIT license.

Q: How do I install mcp2cli? A: Run uv tool install mcp2cli or pip install mcp2cli, or use directly with uvx mcp2cli.


🙏

Source & Thanks

Created by Stephan Fitzpatrick. Licensed under MIT.

mcp2cli — ⭐ 1,900+

Thank you for building a tool that makes MCP servers accessible from the command line.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets