MCPInstall

mcp2cli-api-to-cli

Turn any MCP, OpenAPI, or GraphQL server into a CLI at runtime with zero codegen, saving 96-99% of tokens wasted on tool schemas

Installs
225
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/reason-machines/mcp-skills --skill mcp2cli-api-to-cli
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads mcp2cli-api-to-cli automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

mcp2cli

Skill by ara.so — MCP Skills collection.

mcp2cli converts any MCP server, OpenAPI specification, or GraphQL endpoint into a CLI at runtime without code generation. It dramatically reduces token consumption by replacing repeated tool schema transmissions with simple CLI calls — saving 96-99% of tokens on every LLM turn.

Installation

# Run directly without installing
uvx mcp2cli --help

# Or install globally
uv tool install mcp2cli

# Install as a skill for AI agents
npx skills add knowsuchagency/mcp2cli --skill mcp2cli

Core Concepts

mcp2cli operates in four modes:

  • MCP HTTP/SSE: Connect to MCP servers over HTTP with SSE or streamable HTTP transport
  • MCP stdio: Launch and communicate with local MCP servers via stdio
  • OpenAPI: Generate CLI from OpenAPI 3.x specs (JSON or YAML)
  • GraphQL: Introspect and query GraphQL endpoints

All modes support:

  • Dynamic command generation (no codegen step)
  • Automatic caching with configurable TTL
  • OAuth 2.0 flows (authorization code + PKCE, client credentials)
  • Secret management (env vars, files)
  • Usage tracking and intelligent tool ranking

MCP HTTP Mode

Connect to MCP servers over HTTP with automatic transport negotiation:

# List available tools
mcp2cli --mcp https://mcp.example.com/sse --list

# Call a tool
mcp2cli --mcp https://mcp.example.com/sse search --query "rust async"

# With authentication
mcp2cli --mcp https://mcp.example.com/sse \
  --auth-header "x-api-key:env:MCP_API_KEY" \
  query --sql "SELECT * FROM users LIMIT 10"

# Force specific transport (skip auto-negotiation)
mcp2cli --mcp https://mcp.example.com/sse --transport sse --list

# Search tools by name or description
mcp2cli --mcp https://mcp.example.com/sse --search "database"

MCP stdio Mode

Launch local MCP servers and communicate via stdio:

# List tools from filesystem MCP server
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" --list

# Read a file
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" \
  read-file --path /tmp/data.json

# Pass environment variables to the server
mcp2cli --mcp-stdio "node ./custom-server.js" \
  --env DATABASE_URL=env:DATABASE_URL \
  --env DEBUG=1 \
  search --query "test"

OpenAPI Mode

Generate CLI from OpenAPI specifications:

# Remote spec
mcp2cli --spec https://petstore3.swagger.io/api/v3/openapi.json --list

# Local spec with base URL override
mcp2cli --spec ./openapi.yaml --base-url https://api.example.com --list

# Call an endpoint
mcp2cli --spec ./openapi.json --base-url https://api.example.com \
  list-pets --status available --limit 20

# POST with JSON body from stdin
echo '{"name": "Fido", "species": "dog"}' | \
  mcp2cli --spec ./openapi.json create-pet --stdin

# With authentication
mcp2cli --spec ./openapi.json \
  --auth-header "Authorization:Bearer env:API_TOKEN" \
  create-item --name "New Item"

GraphQL Mode

Query GraphQL endpoints with automatic introspection:

# List all queries and mutations
mcp2cli --graphql https://api.example.com/graphql --list

# Execute a query (auto-generates selection set)
mcp2cli --graphql https://api.example.com/graphql users --limit 10

# Execute a mutation
mcp2cli --graphql https://api.example.com/graphql \
  create-user --name "Alice" --email "alice@example.com"

# Override selection set fields
mcp2cli --graphql https://api.example.com/graphql \
  users --fields "id name email createdAt"

# With authentication
mcp2cli --graphql https://api.example.com/graphql \
  --auth-header "Authorization:Bearer env:GRAPHQL_TOKEN" \
  users

OAuth Authentication

All modes support OAuth 2.0 flows:

# Authorization code + PKCE (opens browser)
mcp2cli --mcp https://mcp.example.com/sse --oauth --list
mcp2cli --spec https://api.example.com/openapi.json --oauth list-users
mcp2cli --graphql https://api.example.com/graphql --oauth users

# Client credentials (machine-to-machine)
mcp2cli --spec https://api.example.com/openapi.json \
  --oauth-client-id "env:OAUTH_CLIENT_ID" \
  --oauth-client-secret "env:OAUTH_CLIENT_SECRET" \
  list-resources

# With specific scopes
mcp2cli --graphql https://api.example.com/graphql \
  --oauth --oauth-scope "read:users write:users" \
  users

# Local spec — provide base URL for OAuth discovery
mcp2cli --spec ./openapi.json \
  --base-url https://api.example.com \
  --oauth \
  --list

Tokens are cached in ~/.cache/mcp2cli/oauth/ and automatically refreshed.

Secret Management

Avoid passing secrets as CLI arguments:

# Read from environment variable
mcp2cli --mcp https://mcp.example.com/sse \
  --auth-header "Authorization:env:MY_API_TOKEN" \
  --list

# Read from file
mcp2cli --spec ./openapi.json \
  --oauth-client-secret "file:/run/secrets/client_secret" \
  --oauth-client-id "file:/run/secrets/client_id" \
  --list

# Works with secret managers
vault kv get -field=token secret/api | \
  MY_TOKEN=$(cat) mcp2cli --mcp https://mcp.example.com/sse \
  --auth-header "Authorization:env:MY_TOKEN" \
  search --query "data"

Bake Mode — Save Connection Settings

Create reusable named configurations:

# Create baked tool from OpenAPI spec
mcp2cli bake create petstore \
  --spec https://api.example.com/openapi.json \
  --auth-header "Authorization:Bearer env:PETSTORE_TOKEN" \
  --exclude "delete-*,update-*" \
  --methods GET,POST \
  --cache-ttl 7200

# Create baked tool from MCP stdio server
mcp2cli bake create github \
  --mcp-stdio "npx @modelcontextprotocol/server-github" \
  --env GITHUB_TOKEN=env:GITHUB_TOKEN \
  --include "search-*,list-*" \
  --exclude "delete-*"

# Create baked tool from GraphQL endpoint
mcp2cli bake create hasura \
  --graphql https://hasura.example.com/v1/graphql \
  --auth-header "x-hasura-admin-secret:env:HASURA_SECRET"

# Use baked tool with @ prefix
mcp2cli @petstore --list
mcp2cli @petstore list-pets --limit 5
mcp2cli @github search-repos --query "mcp server"
mcp2cli @hasura users --limit 10

# Manage baked tools
mcp2cli bake list
mcp2cli bake show petstore
mcp2cli bake update petstore --cache-ttl 3600
mcp2cli bake remove petstore

# Install as standalone script
mcp2cli bake install petstore
# Creates ~/.local/bin/petstore wrapper

# Install to custom directory
mcp2cli bake install petstore --dir ./scripts/

Filtering Options

# Include only specific tool patterns
mcp2cli bake create myapi \
  --spec ./openapi.json \
  --include "list-*,get-*,search-*"

# Exclude dangerous operations
mcp2cli bake create myapi \
  --spec ./openapi.json \
  --exclude "delete-*,destroy-*"

# Limit to specific HTTP methods (OpenAPI only)
mcp2cli bake create myapi \
  --spec ./openapi.json \
  --methods GET,POST

Usage-Aware Tool Ranking

Reduce token costs with intelligent tool ranking:

# Default list (sorted by usage frequency when available)
mcp2cli @myapi --list

# Top 10 most-used tools, compact output (~20 tokens)
mcp2cli @myapi --list --top 10 --compact

# Sort by most recently used
mcp2cli @myapi --list --sort recent

# Alphabetical sort
mcp2cli @myapi --list --sort alpha

# Show full descriptions
mcp2cli @myapi --list --verbose

Usage data is tracked locally in ~/.cache/mcp2cli/usage.json.

Output Control

# Pretty-print JSON (auto-enabled for TTY)
mcp2cli --spec ./openapi.json --pretty list-users

# Raw response body (no JSON parsing)
mcp2cli --spec ./openapi.json --raw get-binary-data

# Limit output to first N records
mcp2cli --spec ./openapi.json list-logs --head 20

# TOON output (40-60% fewer tokens for LLMs)
mcp2cli --mcp https://mcp.example.com/sse --toon list-large-dataset

# Pipe-friendly output
mcp2cli --spec ./openapi.json list-users | jq '.[] | .email'

Caching

Control spec and tool list caching:

# Force refresh (bypass cache)
mcp2cli --spec https://api.example.com/openapi.json --refresh --list

# Custom TTL (7 days)
mcp2cli --spec https://api.example.com/openapi.json --cache-ttl 604800 --list

# Custom cache key
mcp2cli --spec https://api.example.com/openapi.json --cache-key prod-api --list

# Override cache directory
MCP2CLI_CACHE_DIR=/tmp/my-cache mcp2cli --spec ./openapi.json --list

Default cache location: ~/.cache/mcp2cli/ Default TTL: 3600 seconds (1 hour)

Common Patterns

Create a Skill from an API

# Generate a skill configuration for an OpenAPI service
mcp2cli --spec https://api.example.com/openapi.json --list

# Create baked tool for easier access
mcp2cli bake create myservice \
  --spec https://api.example.com/openapi.json \
  --auth-header "Authorization:Bearer env:MYSERVICE_TOKEN"

# Use in skill workflows
mcp2cli @myservice list-resources --format json | jq '.[] | select(.active == true)'

Multi-Environment Setup

# Development environment
mcp2cli bake create myapi-dev \
  --spec https://dev-api.example.com/openapi.json \
  --auth-header "Authorization:Bearer env:DEV_TOKEN"

# Production environment
mcp2cli bake create myapi-prod \
  --spec https://api.example.com/openapi.json \
  --auth-header "Authorization:Bearer env:PROD_TOKEN"

# Use environment-specific tools
mcp2cli @myapi-dev test-endpoint --data "test"
mcp2cli @myapi-prod get-metrics --period "24h"

Chaining with MCP Servers

# Use filesystem MCP to read config, then call API
CONFIG=$(mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /etc" \
  read-file --path /etc/myapp/config.json)

echo "$CONFIG" | jq -r '.api_endpoint' | \
  xargs -I {} mcp2cli --spec {}/openapi.json --list

Filtering Large Tool Lists

# Search tools related to users
mcp2cli @myapi --search "user"

# List only creation operations
mcp2cli @myapi --list | grep "^create-"

# Get compact list of top tools for LLM context
mcp2cli @myapi --list --top 20 --compact

Python API Usage

While mcp2cli is primarily a CLI tool, you can use its components programmatically:

from mcp2cli.openapi import load_spec
from mcp2cli.client import make_request
import asyncio

async def call_api():
    # Load OpenAPI spec
    spec = await load_spec("https://api.example.com/openapi.json")
    
    # Make request
    response = await make_request(
        spec=spec,
        operation_id="listPets",
        params={"limit": 10},
        auth_headers={"Authorization": "Bearer token"}
    )
    
    return response

result = asyncio.run(call_api())

Troubleshooting

OAuth Flow Fails

# Clear cached tokens
rm -rf ~/.cache/mcp2cli/oauth/

# Retry with verbose output
mcp2cli --spec ./openapi.json --oauth --list --verbose

MCP Server Connection Issues

# Test transport explicitly
mcp2cli --mcp https://mcp.example.com/sse --transport sse --list
mcp2cli --mcp https://mcp.example.com/sse --transport streamable --list

# Check server logs if using stdio
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" \
  --env DEBUG=* \
  --list

Cache Issues

# Force refresh
mcp2cli --spec ./openapi.json --refresh --list

# Clear all cache
rm -rf ~/.cache/mcp2cli/

# Use temporary cache location
MCP2CLI_CACHE_DIR=/tmp/test-cache mcp2cli --spec ./openapi.json --list

Tool Not Found After Baking

# Check baked tool exists
mcp2cli bake list

# Verify configuration
mcp2cli bake show myapi

# Recreate with explicit filters
mcp2cli bake update myapi --include "*"

Large Response Truncation

# Use --head to limit records
mcp2cli @myapi list-all --head 100

# Use --raw to get full response
mcp2cli @myapi list-all --raw > output.json

# Use TOON for token efficiency
mcp2cli @myapi list-all --toon

Configuration

Configuration directory: ~/.config/mcp2cli/ Cache directory: ~/.cache/mcp2cli/

Override with environment variables:

  • MCP2CLI_CONFIG_DIR: Configuration directory
  • MCP2CLI_CACHE_DIR: Cache directory

Baked tools are stored in ~/.config/mcp2cli/baked.json Usage tracking in ~/.cache/mcp2cli/usage.json OAuth tokens in ~/.cache/mcp2cli/oauth/

FAQ

What does the mcp2cli-api-to-cli skill do?

Turn any MCP, OpenAPI, or GraphQL server into a CLI at runtime with zero codegen, saving 96-99% of tokens wasted on tool schemas

How do I install mcp2cli-api-to-cli?

Run npx skills add https://github.com/reason-machines/mcp-skills --skill mcp2cli-api-to-cli in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/mcp2cli-api-to-cli/ (personal) or .claude/skills/mcp2cli-api-to-cli/ (project).

Which AI agents can use mcp2cli-api-to-cli?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is mcp2cli-api-to-cli safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains mcp2cli-api-to-cli?

It is published by reason-machines in reason-machines/mcp-skills. It has 225 recorded installs.

More from reason-machines/mcp-skills

View all →

codebase-memory-mcp-intelligence

reason-machines/mcp-skills

High-performance code intelligence MCP server that indexes codebases into knowledge graphs for structural queries, call traces, and architecture analysis

AI & Agents505 installs

playwright-mcp-server

reason-machines/mcp-skills

Browser automation MCP server using Playwright's accessibility tree for LLM-friendly web interaction

AI & Agents285 installs

tradingview-mcp-assistant

reason-machines/mcp-skills

AI-assisted TradingView chart analysis and automation via Chrome DevTools Protocol for Claude Code

AI & Agents262 installs

lanhu-mcp-collaboration

reason-machines/mcp-skills

AI-powered design collaboration server connecting Lanhu design platform with AI coding assistants for requirements analysis, UI design extraction, and team knowledge sharing

AI & Agents256 installs

google-meta-ads-ga4-mcp

reason-machines/mcp-skills

MCP server for Google Ads, Meta Ads & GA4 — 250+ tools for campaign management, analytics & optimization across all platforms

Marketing & SEO240 installs

chrome-devtools-mcp-automation

reason-machines/mcp-skills

Expert guidance for Chrome DevTools MCP server - browser automation, debugging, and performance analysis for AI agents

AI & Agents239 installs

Popular backend & apis skills

View category →

find-skills

vercel-labs/skills

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

OfficialBackend & APIs4.1M installs

entra-app-registration

microsoft/azure-skills

Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.

OfficialBackend & APIs566.7K installs

This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).

Backend & APIs514.8K installs

embedded-captions

heygen-com/hyperframes

Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.

Backend & APIs453.3K installs

entra-agent-id

microsoft/azure-skills

Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).

OfficialBackend & APIs336.6K installs

neon

neondatabase/agent-skills

Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.

Backend & APIs237.1K installs