# mcp2cli
> Turn any MCP server or OpenAPI spec into a CLI instantly

## Summary
Runtime CLI generator that converts MCP servers and OpenAPI specs into command-line interfaces without code generation, dramatically reducing LLM token consumption.

## Capabilities
- Convert any MCP server into a CLI at runtime
- Convert OpenAPI specs (JSON/YAML, local or remote) into CLIs
- Support HTTP/SSE, stdio, and streamable MCP transports
- OAuth authentication with automatic token caching
- TOON output format for token-efficient LLM consumption
- On-demand tool discovery via --list and --help
- Secrets management via environment variables or files

## When to Use
- You need a CLI for an MCP server without writing code
- You want to reduce token usage when connecting LLMs to tools
- You need to interact with OpenAPI services from the terminal

## When NOT to Use
- You need a compiled, standalone CLI binary

## Key Flags
- `--mcp URL`: Connect to an HTTP/SSE MCP server
- `--mcp-stdio "command"`: Run a stdio-based MCP server
- `--spec URL|FILE`: Use an OpenAPI specification
- `--list`: Discover available tools

## Usage Patterns
### List tools from an MCP server
```
mcp2cli --mcp http://localhost:8080 --list
```
Discover all tools exposed by the MCP server

### Use an OpenAPI spec
```
mcp2cli --spec https://api.example.com/openapi.json --list
```
Generate CLI from a remote OpenAPI spec

### Call a specific tool
```
mcp2cli --mcp http://localhost:8080 tool_name --arg value
```
Invoke a tool with arguments

## Input / Output
- **stdout**: Tool output, JSON, or TOON-formatted results

## Installation
- **pip**: `pip install mcp2cli`
- **uvx**: `uvx mcp2cli --help`

---
Source: https://littlescripts.sh/tools/mcp2cli
