[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-74152":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},74152,"mcp2cli","knowsuchagency\u002Fmcp2cli","knowsuchagency","Turn any MCP, OpenAPI, or GraphQL server into a CLI — at runtime, with zero codegen","https:\u002F\u002Fpypi.org\u002Fproject\u002Fmcp2cli\u002F",null,"Python",2219,154,7,1,0,4,32,105,12,92.57,"MIT License",false,"main",true,[27,28,29,30,31],"ai","cli","graphql","mcp","openapi","2026-06-12 04:01:13","\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fknowsuchagency\u002Fmcp2cli\u002Fmain\u002Fassets\u002Fhero.png\" alt=\"mcp2cli — one CLI for every API\" width=\"700\">\n\u003C\u002Fp>\n\n\u003Ch1 align=\"center\">mcp2cli\u003C\u002Fh1>\n\n\u003Cp align=\"center\">\n  Turn any MCP server, OpenAPI spec, or GraphQL endpoint into a CLI — at runtime, with zero codegen.\u003Cbr>\n  \u003Cstrong>Save 96–99% of the tokens wasted on tool schemas every turn.\u003C\u002Fstrong>\u003Cbr>\u003Cbr>\n  \u003Ca href=\"https:\u002F\u002Fwww.orangecountyai.com\u002Fblog\u002Fmcp2cli-one-cli-for-every-api-zero-wasted-tokens\">\u003Cstrong>Read the full writeup →\u003C\u002Fstrong>\u003C\u002Fa>\n\u003C\u002Fp>\n\n## Install\n\n```bash\n# Run directly without installing\nuvx mcp2cli --help\n\n# Or install globally\nuv tool install mcp2cli\n```\n\n## AI Agent Skill\n\nmcp2cli ships with an installable [skill](https:\u002F\u002Fskills.sh) 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.\n\n```bash\nnpx skills add knowsuchagency\u002Fmcp2cli --skill mcp2cli\n```\n\nAfter installing, try prompts like:\n- `mcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse` — interact with an MCP server\n- `mcp2cli create a skill for https:\u002F\u002Fapi.example.com\u002Fopenapi.json` — generate a skill from an API\n\n## Usage\n\n### MCP HTTP\u002FSSE mode\n\n```bash\n# Connect to an MCP server over HTTP\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse --list\n\n# Call a tool\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse search --query \"test\"\n\n# With auth header\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse --auth-header \"x-api-key:sk-...\" \\\n  query --sql \"SELECT 1\"\n\n# Force a specific transport (skip streamable HTTP fallback dance)\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse --transport sse --list\n\n# Search tools by name or description (case-insensitive substring match)\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse --search \"task\"\n```\n\n`--search` implies `--list` and works across all modes (`--mcp`, `--spec`, `--graphql`, `--mcp-stdio`).\n\n### OAuth authentication\n\nAPIs that require OAuth are supported out of the box — across MCP, OpenAPI, and GraphQL modes.\nmcp2cli handles token acquisition, caching, and refresh automatically.\n\n```bash\n# Authorization code + PKCE flow (opens browser for login)\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse --oauth --list\nmcp2cli --spec https:\u002F\u002Fapi.example.com\u002Fopenapi.json --oauth --list\nmcp2cli --graphql https:\u002F\u002Fapi.example.com\u002Fgraphql --oauth --list\n\n# Client credentials flow (machine-to-machine, no browser)\nmcp2cli --spec https:\u002F\u002Fapi.example.com\u002Fopenapi.json \\\n  --oauth-client-id \"my-client-id\" \\\n  --oauth-client-secret \"my-secret\" \\\n  list-pets\n\n# With specific scopes\nmcp2cli --graphql https:\u002F\u002Fapi.example.com\u002Fgraphql --oauth --oauth-scope \"read write\" users\n\n# Local spec file — use --base-url for OAuth discovery\nmcp2cli --spec .\u002Fopenapi.json --base-url https:\u002F\u002Fapi.example.com --oauth --list\n```\n\nTokens are persisted in `~\u002F.cache\u002Fmcp2cli\u002Foauth\u002F` so subsequent calls reuse existing tokens\nand refresh automatically when they expire.\n\n### Secrets from environment or files\n\nSensitive values (`--auth-header` values, `--oauth-client-id`, `--oauth-client-secret`) support\n`env:` and `file:` prefixes to avoid passing secrets as CLI arguments (which are visible in\nprocess listings):\n\n```bash\n# Read from environment variable\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse \\\n  --auth-header \"Authorization:env:MY_API_TOKEN\" \\\n  --list\n\n# Read from file\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse \\\n  --oauth-client-secret \"file:\u002Frun\u002Fsecrets\u002Fclient_secret\" \\\n  --oauth-client-id \"my-client-id\" \\\n  --list\n\n# Works with secret managers that inject env vars\nfnox exec -- mcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse \\\n  --oauth-client-id \"env:OAUTH_CLIENT_ID\" \\\n  --oauth-client-secret \"env:OAUTH_CLIENT_SECRET\" \\\n  --list\n```\n\n### MCP stdio mode\n\n```bash\n# List tools from an MCP server\nmcp2cli --mcp-stdio \"npx @modelcontextprotocol\u002Fserver-filesystem \u002Ftmp\" --list\n\n# Call a tool\nmcp2cli --mcp-stdio \"npx @modelcontextprotocol\u002Fserver-filesystem \u002Ftmp\" \\\n  read-file --path \u002Ftmp\u002Fhello.txt\n\n# Pass environment variables to the server process\nmcp2cli --mcp-stdio \"node server.js\" --env API_KEY=sk-... --env DEBUG=1 \\\n  search --query \"test\"\n```\n\n### OpenAPI mode\n\n```bash\n# List all commands from a remote spec\nmcp2cli --spec https:\u002F\u002Fpetstore3.swagger.io\u002Fapi\u002Fv3\u002Fopenapi.json --list\n\n# Call an endpoint\nmcp2cli --spec .\u002Fopenapi.json --base-url https:\u002F\u002Fapi.example.com list-pets --status available\n\n# With auth\nmcp2cli --spec .\u002Fspec.json --auth-header \"Authorization:Bearer tok_...\" create-item --name \"Test\"\n\n# POST with JSON body from stdin\necho '{\"name\": \"Fido\", \"tag\": \"dog\"}' | mcp2cli --spec .\u002Fspec.json create-pet --stdin\n\n# Local YAML spec\nmcp2cli --spec .\u002Fapi.yaml --base-url http:\u002F\u002Flocalhost:8000 --list\n```\n\n### GraphQL mode\n\n```bash\n# List all queries and mutations from a GraphQL endpoint\nmcp2cli --graphql https:\u002F\u002Fapi.example.com\u002Fgraphql --list\n\n# Call a query\nmcp2cli --graphql https:\u002F\u002Fapi.example.com\u002Fgraphql users --limit 10\n\n# Call a mutation\nmcp2cli --graphql https:\u002F\u002Fapi.example.com\u002Fgraphql create-user --name \"Alice\" --email \"alice@example.com\"\n\n# Override auto-generated selection set fields\nmcp2cli --graphql https:\u002F\u002Fapi.example.com\u002Fgraphql users --fields \"id name email\"\n\n# With auth\nmcp2cli --graphql https:\u002F\u002Fapi.example.com\u002Fgraphql --auth-header \"Authorization:Bearer tok_...\" users\n```\n\nmcp2cli introspects the endpoint, discovers queries and mutations, auto-generates selection sets, and constructs parameterized queries with proper variable declarations. No SDL parsing, no code generation — just point and run.\n\n### Bake mode — save connection settings\n\nTired of repeating `--spec`\u002F`--mcp`\u002F`--mcp-stdio` plus auth flags on every invocation? Bake them into a named configuration:\n\n```bash\n# Create a baked tool from an OpenAPI spec\nmcp2cli bake create petstore --spec https:\u002F\u002Fapi.example.com\u002Fspec.json \\\n  --exclude \"delete-*,update-*\" --methods GET,POST --cache-ttl 7200\n\n# Create a baked tool from an MCP stdio server\nmcp2cli bake create mygit --mcp-stdio \"npx @mcp\u002Fgithub\" \\\n  --include \"search-*,list-*\" --exclude \"delete-*\"\n\n# Use a baked tool with @ prefix — no connection flags needed\nmcp2cli @petstore --list\nmcp2cli @petstore list-pets --limit 10\nmcp2cli @mygit search-repos --query \"rust\"\n\n# Manage baked tools\nmcp2cli bake list                         # show all baked tools\nmcp2cli bake show petstore                # show config (secrets masked)\nmcp2cli bake update petstore --cache-ttl 3600\nmcp2cli bake remove petstore\nmcp2cli bake install petstore             # creates ~\u002F.local\u002Fbin\u002Fpetstore wrapper\nmcp2cli bake install petstore --dir .\u002Fscripts\u002F  # install wrapper to custom directory\n```\n\nFiltering options:\n- `--include` — comma-separated glob patterns to whitelist tools (e.g. `\"list-*,get-*\"`)\n- `--exclude` — comma-separated glob patterns to blacklist tools (e.g. `\"delete-*\"`)\n- `--methods` — comma-separated HTTP methods to allow (e.g. `\"GET,POST\"`, OpenAPI only)\n\nConfigs are stored in `~\u002F.config\u002Fmcp2cli\u002Fbaked.json`. Override with `MCP2CLI_CONFIG_DIR`.\n\n### Usage-aware tool ranking\n\nmcp2cli tracks tool invocations locally and uses that data to rank `--list` output, reducing token costs for LLM agents working with large servers.\n\n```bash\n# Default --list: ~1,400 tokens for 96 tools\nmcp2cli @myapi --list\n\n# Top 10 most-used tools, names only: ~20 tokens\nmcp2cli @myapi --list --top 10 --compact\n\n# Sort by most recently used\nmcp2cli @myapi --list --sort recent\n\n# Alphabetical sort\nmcp2cli @myapi --list --sort alpha\n```\n\nWhen usage data exists for a source, `--list` defaults to sorting by call frequency. Otherwise insertion order is preserved. Usage data is stored in `~\u002F.cache\u002Fmcp2cli\u002Fusage.json`.\n\n### Output control\n\n```bash\n# Pretty-print JSON (also auto-enabled for TTY)\nmcp2cli --spec .\u002Fspec.json --pretty list-pets\n\n# Raw response body (no JSON parsing)\nmcp2cli --spec .\u002Fspec.json --raw get-data\n\n# Truncate large responses to first N records\nmcp2cli --spec .\u002Fspec.json list-records --head 5\n\n# Pipe-friendly (compact JSON when not a TTY)\nmcp2cli --spec .\u002Fspec.json list-pets | jq '.[] | .name'\n\n# TOON output — token-efficient encoding for LLM consumption\n# Best for large uniform arrays (40-60% fewer tokens than JSON)\nmcp2cli --mcp https:\u002F\u002Fmcp.example.com\u002Fsse --toon list-tags\n```\n\n### Caching\n\nSpecs and MCP tool lists are cached in `~\u002F.cache\u002Fmcp2cli\u002F` with a 1-hour TTL by default.\n\n```bash\n# Force refresh\nmcp2cli --spec https:\u002F\u002Fapi.example.com\u002Fspec.json --refresh --list\n\n# Custom TTL (seconds)\nmcp2cli --spec https:\u002F\u002Fapi.example.com\u002Fspec.json --cache-ttl 86400 --list\n\n# Custom cache key\nmcp2cli --spec https:\u002F\u002Fapi.example.com\u002Fspec.json --cache-key my-api --list\n\n# Override cache directory\nMCP2CLI_CACHE_DIR=\u002Ftmp\u002Fmy-cache mcp2cli --spec .\u002Fspec.json --list\n```\n\nLocal file specs are never cached.\n\n## CLI reference\n\n```\nmcp2cli [global options] \u003Csubcommand> [command options]\n\nSource (mutually exclusive, one required):\n  --spec URL|FILE       OpenAPI spec (JSON or YAML, local or remote)\n  --mcp URL             MCP server URL (HTTP\u002FSSE)\n  --mcp-stdio CMD       MCP server command (stdio transport)\n  --graphql URL         GraphQL endpoint URL\n\nOptions:\n  --auth-header K:V       HTTP header (repeatable, value supports env:\u002Ffile: prefixes)\n  --base-url URL          Override base URL from spec\n  --transport TYPE        MCP HTTP transport: auto|sse|streamable (default: auto)\n  --env KEY=VALUE         Env var for MCP stdio server (repeatable)\n  --oauth                 Enable OAuth (authorization code + PKCE flow)\n  --oauth-client-id ID    OAuth client ID (supports env:\u002Ffile: prefixes)\n  --oauth-client-secret S OAuth client secret (supports env:\u002Ffile: prefixes)\n  --oauth-scope SCOPE     OAuth scope(s) to request\n  --cache-key KEY         Custom cache key\n  --cache-ttl SECONDS     Cache TTL (default: 3600)\n  --refresh               Bypass cache\n  --list                  List available subcommands\n  --search PATTERN        Search tools by name or description (implies --list)\n  --sort MODE             Sort --list output: usage|recent|alpha|default\n  --top N                 Show only the top N tools in --list output\n  --compact               Space-separated tool names only, no descriptions\n  --verbose               Show full tool descriptions (unwrapped)\n  --fields FIELDS         Override GraphQL selection set (e.g. \"id name email\")\n  --pretty                Pretty-print JSON output\n  --raw                   Print raw response body\n  --toon                  Encode output as TOON (token-efficient for LLMs)\n  --head N                Limit output to first N records (arrays)\n  --version               Show version\n\nBake mode:\n  bake create NAME [opts]   Save connection settings as a named tool\n  bake list                 List all baked tools\n  bake show NAME            Show config (secrets masked)\n  bake update NAME [opts]   Update a baked tool\n  bake remove NAME          Delete a baked tool\n  bake install NAME         Create ~\u002F.local\u002Fbin wrapper script\n  @NAME [args]              Run a baked tool (e.g. mcp2cli @petstore --list)\n```\n\nSubcommands and their flags are generated dynamically from the spec or MCP server tool definitions. Run `\u003Csubcommand> --help` for details.\n\n> For token savings analysis, architecture details, and comparison to Anthropic's Tool Search, see the **[full writeup on the OCAI blog](https:\u002F\u002Fwww.orangecountyai.com\u002Fblog\u002Fmcp2cli-one-cli-for-every-api-zero-wasted-tokens)**.\n\n## Development\n\n```bash\n# Install with test + MCP deps\nuv sync --extra test\n\n# Run tests (96 tests covering OpenAPI, MCP stdio, MCP HTTP, caching, and token savings)\nuv run pytest tests\u002F -v\n\n# Run just the token savings tests\nuv run pytest tests\u002Ftest_token_savings.py -v -s\n```\n\n---\n\n## License\n\n[MIT](LICENSE)\n\n---\n\n\u003Csub>mcp2cli builds on ideas from [CLIHub](https:\u002F\u002Fkanyilmaz.me\u002F2026\u002F02\u002F23\u002Fcli-vs-mcp.html) by Kagan Yilmaz (CLI-based tool access for token efficiency)\u003C\u002Fsub>\n","mcp2cli 是一个将MCP、OpenAPI或GraphQL服务器实时转换为命令行界面（CLI）的工具，无需代码生成。它支持多种协议和认证方式，包括OAuth，并能自动处理令牌获取、缓存及刷新，显著减少了与API交互时的令牌浪费。该工具特别适合需要频繁调用不同API接口的开发人员使用，尤其在AI编码助手场景下，通过安装特定技能，可以让AI更好地理解和利用API资源。基于Python构建，开源且遵循MIT许可协议。",2,"2026-06-11 03:49:04","high_star"]