
在运行时,将任何 MCP、OpenAPI 或 GraphQL 服务器都变成 CLI,无需任何代码生成
概览
将任何MCP服务器、OpenAPI规范或GraphQL端点转为CLI——运行时无需代码生成。每回合节省96–99%用于工具模式浪费的令牌。阅读完整文章→ mcp2cli 自带一个可安装的技能,可以教 AI 编码代理(Claude Code、Cursor、Codex)如何使用它。安装后,你的代理可以发现并调用任何 MCP 服务器或 OpenAPI 端点——甚至从 API 生成新技能。 安装后,尝试以下提示:- mcp2cli --mcp https://mcp.example.com/sse — 与MCP服务器交互- mcp2cli 为https://api.example.com/openapi.json 创建技能 — 从 API 生成技能 --搜索意味着 --列表,并且在所有模式(--mcp、--spec、--graphql、--mcp-stdio)上都能工作。 需要 OAuth 的 API 开箱即用——涵盖 MCP、OpenAPI 和 GraphQL 模式。MCP2CLI 自动处理令牌获取、缓存和刷新。 令牌在 ~/ 中被持久保存。
概述(AI 翻译)
MCP2CLI
将任何MCP服务器、OpenAPI规范或GraphQL端点都转化为CLI——运行时无需代码生成。 每回合节省96%到99%浪费在工具结构上的代币。 阅读完整文章→
安装
人工智能特工技能
mcp2cli 自带一个可安装的技能,可以教 AI 编码代理(Claude Code、Cursor、Codex)如何使用它。安装后,你的代理可以发现并调用任何 MCP 服务器或 OpenAPI 端点——甚至从 API 生成新技能。
安装后,尝试以下提示:
mcp2cli --mcp https://mcp.example.com/sse— 与MCP服务器交互mcp2cli create a skill for https://api.example.com/openapi.json— 从 API 生成技能
用途
MCP HTTP/SSE 模式
--search 蕴含 --list],并且适用于所有模式(--mcp、--spec、--graphql、--mcp-stdio)。
OAuth 认证
需要 OAuth 的 API 开箱即用——跨 MCP、OpenAPI 和 GraphQL 模式。 MCP2CLI自动处理令牌获取、缓存和刷新。
代币在~/.cache/mcp2cli/oauth/中被持久化,因此后续调用会重复使用已有代币
并且在过期时自动刷新。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
mcp2cli
Turn any MCP server, OpenAPI spec, or GraphQL endpoint into a CLI — at runtime, with zero codegen. Save 96–99% of the tokens wasted on tool schemas every turn. Read the full writeup →
Install
# Run directly without installing
uvx mcp2cli --help
# Or install globally
uv tool install mcp2cli
AI Agent Skill
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
Usage
MCP HTTP/SSE mode
# 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).
OAuth authentication
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.
安装
uvx mcp2cli --help