mcp2cli
Original:🇺🇸 English
Translated
Turn any MCP server or OpenAPI spec into a CLI. Use this skill when the user wants to interact with an MCP server or OpenAPI/REST API via command line, discover available tools/endpoints, call API operations, or generate a new skill from an API. Triggers include "mcp2cli", "call this MCP server", "use this API", "list tools from", "create a skill for this API", or any task involving MCP tool invocation or OpenAPI endpoint calls without writing code.
4installs
Sourceknowsuchagency/mcp2cli
Added on
NPX Install
npx skill4agent add knowsuchagency/mcp2cli mcp2cliTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →mcp2cli
Turn any MCP server or OpenAPI spec into a CLI at runtime. No codegen.
Install
bash
# Run directly (no install needed)
uvx mcp2cli --help
# Or install
pip install mcp2cliCore Workflow
- Connect to a source (MCP server or OpenAPI spec)
- Discover available commands with
--list - Inspect a specific command with
<command> --help - Execute the command with flags
bash
# MCP over HTTP
mcp2cli --mcp https://mcp.example.com/sse --list
mcp2cli --mcp https://mcp.example.com/sse create-task --help
mcp2cli --mcp https://mcp.example.com/sse create-task --title "Fix bug"
# MCP over stdio
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" --list
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" read-file --path /tmp/hello.txt
# OpenAPI spec (remote or local, JSON or YAML)
mcp2cli --spec https://petstore3.swagger.io/api/v3/openapi.json --list
mcp2cli --spec ./openapi.json --base-url https://api.example.com list-pets --status availableCLI Reference
mcp2cli [global options] <subcommand> [command options]
Source (mutually exclusive, one required):
--spec URL|FILE OpenAPI spec (JSON or YAML, local or remote)
--mcp URL MCP server URL (HTTP/SSE)
--mcp-stdio CMD MCP server command (stdio transport)
Options:
--auth-header K:V HTTP header sent with requests (repeatable)
--base-url URL Override base URL from spec
--env KEY=VALUE Env var for stdio server process (repeatable)
--cache-key KEY Custom cache key
--cache-ttl SECONDS Cache TTL (default: 3600)
--refresh Bypass cache
--list List available subcommands
--pretty Pretty-print JSON output
--raw Print raw response body
--toon Encode output as TOON (token-efficient for LLMs)
--version Show versionSubcommands and flags are generated dynamically from the source.
Patterns
Authentication
bash
# API key header
mcp2cli --spec ./spec.json --auth-header "Authorization:Bearer tok_..." list-items
# Multiple headers
mcp2cli --mcp https://mcp.example.com/sse \
--auth-header "x-api-key:sk-..." \
--auth-header "x-org-id:org_123" \
search --query "test"POST with JSON body from stdin
bash
echo '{"name": "Fido", "tag": "dog"}' | mcp2cli --spec ./spec.json create-pet --stdinEnv vars for stdio servers
bash
mcp2cli --mcp-stdio "node server.js" --env API_KEY=sk-... --env DEBUG=1 search --query "test"Caching
Specs and MCP tool lists are cached in (1h TTL). Local files are never cached.
~/.cache/mcp2cli/bash
mcp2cli --spec https://api.example.com/spec.json --refresh --list # Force refresh
mcp2cli --spec https://api.example.com/spec.json --cache-ttl 86400 --list # 24h TTLTOON output (token-efficient for LLMs)
bash
mcp2cli --mcp https://mcp.example.com/sse --toon list-tagsBest for large uniform arrays — 40-60% fewer tokens than JSON.
Generating a Skill from an API
When the user asks to create a skill from an MCP server or OpenAPI spec, follow this workflow:
-
Discover all available commands:bash
uvx mcp2cli --mcp https://target.example.com/sse --list -
Inspect each command to understand parameters:bash
uvx mcp2cli --mcp https://target.example.com/sse <command> --help -
Test key commands to verify they work:bash
uvx mcp2cli --mcp https://target.example.com/sse <command> --param value -
Create a SKILL.md that teaches another AI agent how to use this API via mcp2cli. Include:
- The source flag (,
--mcp, or--mcp-stdio) and URL--spec - Any required auth headers
- Common workflows with example commands
- The and
--listdiscovery pattern for commands not covered--help
- The source flag (
The generated skill should use mcp2cli as its execution layer — the agent runs commands rather than making raw HTTP/MCP calls.
uvx mcp2cli ...