Turn any MCP, OpenAPI, or GraphQL server into a CLI — at runtime, with zero codegen
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
# Add to your Claude Code skills
git clone https://github.com/knowsuchagency/mcp2cliGuides for using code generation skills like mcp2cli.
# Run directly without installing
uvx mcp2cli --help
# Or install globally
uv tool install mcp2cli
mcp2cli ships with an installable skill that teaches AI coding agents (Claude Code, Cursor, Codex) how to use it. Once installed, your agent can discover and call any MCP server or OpenAPI endpoint — and even generate new skills from APIs.
npx skills add knowsuchagency/mcp2cli --skill mcp2cli
After installing, try prompts like:
mcp2cli --mcp https://mcp.example.com/sse — interact with an MCP servermcp2cli create a skill for https://api.example.com/openapi.json — generate a skill from an API# Connect to an MCP server over HTTP
mcp2cli --mcp https://mcp.example.com/sse --list
# Call a tool
mcp2cli --mcp https://mcp.example.com/sse search --query "test"
# With auth header
mcp2cli --mcp https://mcp.example.com/sse --auth-header "x-api-key:sk-..." \
query --sql "SELECT 1"
# Force a specific transport (skip streamable HTTP fallback dance)
mcp2cli --mcp https://mcp.example.com/sse --transport sse --list
# Search tools by name or description (case-insensitive substring match)
mcp2cli --mcp https://mcp.example.com/sse --search "task"
--search implies --list and works across all modes (--mcp, --spec, --graphql, --mcp-stdio).
APIs that require OAuth are supported out of the box — across MCP, OpenAPI, and GraphQL modes. mcp2cli handles token acquisition, caching, and refresh automatically.
# Authorization code + PKCE flow (opens browser for login)
mcp2cli --mcp https://mcp.example.com/sse --oauth --list
mcp2cli --spec https://api.example.com/openapi.json --oauth --list
mcp2cli --graphql https://api.example.com/graphql --oauth --list
# Client credentials flow (machine-to-machine, no browser)
mcp2cli --spec https://api.example.com/openapi.json \
--oauth-client-id "my-client-id" \
--oauth-client-secret "my-secret" \
list-pets
# With specific scopes
mcp2cli --graphql https://api.example.com/graphql --oauth --oauth-scope "read write" users
# Local spec file — use --base-url for OAuth discovery
mcp2cli --spec ./openapi.json --base-url https://api.example.com --oauth --list
Tokens are persisted in ~/.cache/mcp2cli/oauth/ so subsequent calls reuse existing tokens
and refresh automatically when they expire.
The default authorization-code flow starts a callback server on 127.0.0.1, which only
works when the browser runs on the same machine. On a VPS over SSH or in a container,
add --oauth-manual-callback: mcp2cli prints the authorization URL instead of opening a
browser, and reads the redirect back from stdin.
mcp2cli --mcp https://mcp.linear.app/mcp --oauth --oauth-manual-callback --list
Open the printed URL in a browser on any machine, authorize, then paste the URL you land
on. That page will fail to load — nothing is listening on the loopback port — which is
expected; only its address matters, because it carries the code and state parameters.
PKCE and state verification are unchanged, so paste the URL unmodified.
Sensitive values (--auth-header values, --oauth-client-id, --oauth-client-secret) support
env: and file: prefixes to avoid passing secrets as CLI arguments (which are visible in
process listings):
# Read from environment variable
mcp2cli --mcp https://mcp.example.com/sse \
--auth-header "Authorization:env:MY_API_TOKEN" \
--list
# Read from file
mcp2cli --mcp https://mcp.example.com/sse \
--oauth-client-secret "file:/run/secrets/client_secret" \
--oauth-client-id "my-client-id" \
--list
# Works with secret managers that inject env vars
fnox exec -- mcp2cli --mcp https://mcp.example.com/sse \
--oauth-client-id "env:OAUTH_CLIENT_ID" \
--oauth-client-secret "env:OAUTH_CLIENT_SECRET" \
--list
# List tools from an MCP server
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" --list
# Call a tool
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" \
read-file --path /tmp/hello.txt
# Or hand the whole argument object over as JSON, no shell pipe needed
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" \
read-file --req-json '{"path": "/tmp/hello.txt"}'
# Pass environment variables to the server process
mcp2cli --mcp-stdio "node server.js" --env API_KEY=sk-... --env DEBUG=1 \
search --query "test"
--schema)--list shows a token-cheap, flattened view of each tool's parameters. When you
need the exact wire contract — nested objects, anyOf branches, default,
outputSchema — ask for the raw definition instead:
# Global form: wire name, or the kebab-case name shown by --list
mcp2cli --mcp https://example.com/mcp --schema getUserProfile
mcp2cli --mcp https://example.com/mcp --schema get-user-profile
# After the tool name, including inside a session
mcp2cli --mcp https://example.com/mcp get-user-profile --schema
mcp2cli --session work get-user-profile --schema
The output is the server's own tools/list entry. Property names such as
fooBar stay fooBar, and inputSchema / outputSchema / annotations keep
their wire spelling — nothing is renamed or flattened.
Only MCP sources support --schema; --spec and --graphql reject it.
A tool with its own schema parameter keeps --schema for that parameter, so
use the global form (--schema TOOL) to see its definition.
Expose one or more filesystem roots when a server scopes operations to a
workspace. Paths are converted to file:// URIs; explicit roots must also use
the file:// scheme.
mcp2cli --mcp-stdio "npx @modelcontextprotocol/server-filesystem /tmp" \
--root "$PWD" --root file:///var/shared --list
Request prompt-argument or resource-template completions with
REF:ARG=PREFIX:
mcp2cli --mcp https://example.com/mcp \
--complete "greeting:name=San"
mcp2cli --mcp https://example.com/mcp \
--complete "file:///docs/{topic}:topic=api"
Both options work when starting a persistent session; roots are retained by
the session daemon and completion requests can be sent through --session.
A one-shot call pays for starting the server and running initialize every
time. A named session keeps one daemon — and one MCP connection — alive and
routes later calls to it.
# Start a daemon that owns the connection
mcp2cli --session-start work --mcp-stdio "npx @modelcontextprotocol/server-filesystem ."
# Call tools through it — no reconnect, no re-initialize
mcp2cli --session work --list
mcp2cli --session work read-file --path ./README.md
# Inspect and stop
mcp2cli --session-list
mcp2cli --session-stop work
Sessions live under ~/.cache/mcp2cli/sessions (override with
MCP2CLI_CACHE_DIR). The daemon is detached from the shell that started it,
so closing that terminal does not end the session.
How a client reaches the daemon depends on the platform:
| Platform | Transport | Notes |
|---|---|---|
| macOS, Linux | Unix domain socket (<name>.sock) |
sessions/ is 0700, metadata 0600 |
| Windows | Loopback TCP on 127.0.0.1 |
Windows CPython has no socket.AF_UNIX |
Every request carries a per-session token that the daemon generates on start,
so another local process cannot drive your session by connecting to its port.
--session-stop asks the daemon to exit over that same channel, which lets it
close the MCP server cleanly and delete its own files. Set
MCP2CLI_SESSION_TRANSPORT=unix|tcp to pin a transport instead of taking the
platform default.
# List all commands from a remote spec
mcp2cli --spec https://petstore3.swagger.io/api/v3/openapi.json --list
# Call an endpoint
mcp2cli --spec ./openapi.json --base-url https://api.example.com list-pets --status available
# With auth
mcp2cli --spec ./spec.json --auth-header "Authorization:Bearer tok_..." create-item --name "Test"
# POST with a JSON body given inline
mcp2cli --spec ./spec.json create-pet --req-json '{"name": "Fido", "tag": "dog"}'
# ...or piped to stdin
echo '{"name": "Fido", "tag": "dog"}' | mcp2cli --spec ./spec.json create-pet --stdin
# Flags given with --req-json/--stdin are merged into the JSON (a conflicting value is an error)
echo '{"name": "Fido"}' | mcp2cli --spec ./spec.json create-pet --tag dog --stdin
# Local YAML spec
mcp2cli --spec ./api.yaml --base-url http://localhost:8000 --list
# List all queries and mutations from a GraphQL endpoint
mcp2cli --graphql https://api.example.com/graphql --list
# Call a query
mcp2cli --graphql https://api.example.com/graphql users --limit 10
# Call a mutation
mcp2cli --graphql https://api.example.com/graphql create-user --name "Alice" --email "[email protected]"
# Override auto-generated selection set fields
mcp2cli --graphql https://api.example.com/graphql --fields "id name email" users
# With auth
mcp2cli --graphql https://api.example.com/graphql --auth-header "Authorization:Bearer tok_..." users
mcp2cli introspects the endpoint, discovers queries and mutations, auto-generates selection sets, and constructs paramete
mcp2cli is an open-source code generation skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by knowsuchagency. Turn any MCP, OpenAPI, or GraphQL server into a CLI — at runtime, with zero codegen. It has 2,447 GitHub stars.
mcp2cli's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/knowsuchagency/mcp2cli" and add it to your Claude Code skills directory (see the Installation section above).
mcp2cli is primarily written in Python. It is open-source under knowsuchagency on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other Code Generation skills you can browse and compare side by side. Open the Code Generation category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh mcp2cli against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars