{
  "source_file": "0930",
  "source_platform": "Dev.to",
  "author": "Mariano Gobea Alcoba",
  "title_listed": "Show HN: Mcp2cli – One CLI for every API, 96-99% fewer tokens than native MCP!",
  "keywords": "",
  "domain": "大模型算法",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://dev.to/mgobea/show-hn-mcp2cli-one-cli-for-every-api-96-99-fewer-tokens-than-native-mcp-5c49",
  "publish_date": "2026-03-09",
  "corpus_stage": "",
  "notes": "",
  "id": "40e132ff00a0",
  "collected_at": "2026-10-02T14:05:46",
  "title": "Show HN: Mcp2cli – One CLI for every API, 96-99% fewer tokens than native MCP! - DEV Community",
  "body_markdown": "Introduction\nIn the realm of Model Control Protocol (MCP) servers, efficiency and token usage are critical considerations. Traditional MCP servers inject their full tool schemas into the context on every turn, which can lead to significant token overhead. For instance, a server with 30 tools would cost approximately 3,600 tokens per turn, even if the model does not use all the tools. Over 25 turns with 120 tools, this can amount to 362,000 tokens just for schemas. This inefficiency is a significant concern, especially in environments where token usage directly impacts costs.\nEnter\nmcp2cli\n, a command-line interface (CLI) tool designed to address these issues.\nmcp2cli\ntransforms any MCP server or OpenAPI specification into a CLI at runtime, allowing the language model (LLM) to discover tools on demand. This approach significantly reduces token usage and enhances the overall efficiency of the system. In this article, we will delve into the technical details of\nmcp2cli\n, including its architecture, usage, and the benefits it offers.\nArchitecture of\nmcp2cli\nOverview\nmcp2cli\noperates by dynamically discovering and invoking tools from an MCP server or OpenAPI specification. Instead of loading all tool schemas upfront, it fetches and processes only the necessary information when required. This on-demand discovery mechanism minimizes token usage and improves performance.\nComponents\nCLI Interface\n: The user interacts with\nmcp2cli\nthrough a simple CLI interface. Commands are structured to mimic traditional CLI tools, making it intuitive for developers to use.\nMCP Server Integration\n:\nmcp2cli\ncan connect to any MCP server using a WebSocket or HTTP endpoint. It fetches the list of available tools and their schemas as needed.\nOpenAPI Specification Handling\n:\nmcp2cli\nsupports both local and remote OpenAPI specifications (in JSON or YAML format). It parses the specification to extract tool information and provides a consistent interface for invoking APIs.\nToken Management\n:\nmcp2cli\noptimizes token usage by fetching and processing tool schemas only when they are required. This dynamic approach ensures that the model is not burdened with unnecessary context.\nWorkflow\nInitialization\n: The user starts by specifying the MCP server or OpenAPI specification using the\n--mcp\nor\n--openapi\nflag.\nTool Discovery\n: When the user lists available tools or requests help for a specific tool,\nmcp2cli\nfetches the necessary information from the server or specification.\nTool Invocation\n: When a tool is invoked,\nmcp2cli\nsends the request to the server and processes the response. The output is presented to the user in a structured format.\nUsage Examples\nListing Available Tools\nTo list all available tools from an MCP server:\nmcp2cli\n--mcp\nhttps://mcp.example.com/sse\n--list\nEnter fullscreen mode\nExit fullscreen mode\nThis command fetches the list of tools and displays them, using approximately 16 tokens per tool.\nGetting Help for a Specific Tool\nTo get detailed help for a specific tool:\nmcp2cli\n--mcp\nhttps://mcp.example.com/sse create-task\n--help\nEnter fullscreen mode\nExit fullscreen mode\nThis command fetches the schema for the\ncreate-task\ntool and displays the help information, using approximately 120 tokens.\nInvoking a Tool\nTo invoke a tool with specific parameters:\nmcp2cli\n--mcp\nhttps://mcp.example.com/sse create-task\n--title\n\"Fix bug\"\nEnter fullscreen mode\nExit fullscreen mode\nThis command sends a request to the server to create a task with the specified title, using the minimum necessary tokens.\nUsing OpenAPI Specifications\nmcp2cli\ncan also handle OpenAPI specifications. For example, to list available endpoints from a local OpenAPI file:\nmcp2cli\n--openapi\n./api-spec.yaml\n--list\nEnter fullscreen mode\nExit fullscreen mode\nTo get help for a specific endpoint:\nmcp2cli\n--openapi\n./api-spec.yaml get-user\n--help\nEnter fullscreen mode\nExit fullscreen mode\nTo invoke an endpoint:\nmcp2cli\n--openapi\n./api-spec.yaml get-user\n--id\n123\nEnter fullscreen mode\nExit fullscreen mode\nToken Savings\nThe primary benefit of\nmcp2cli\nis its significant reduction in token usage. By fetching and processing tool schemas on demand, it avoids the overhead of injecting full schemas into the context on every turn. The token savings are substantial, as demonstrated by the following measurements:\n30 Tools Over 15 Turns\n: 96% reduction in token usage.\n120 Tools Over 25 Turns\n: 99% reduction in token usage.\nThese savings are calculated using the\ncl100k_base\ntokenizer and represent a significant improvement in efficiency and cost-effectiveness.\nInstallation and Setup\nPrerequisites\nNode.js (v14 or later)\nnpm (v6 or later)\nInstallation\nTo install\nmcp2cli\n, you can use npm:\nnpm\ninstall\n-g\nmcp2cli\nEnter fullscreen mode\nExit fullscreen mode\nAlternatively, you can install it as a skill for AI coding agents like Claude Code, Cursor, or Codex:\nnpx skills add knowsuchagency/mcp2cli\n--skill\nmcp2cli\nEnter fullscreen mode\nExit fullscreen mode\nConfiguration\nAfter installation, you can configure\nmcp2cli\nto connect to your MCP server or OpenAPI specification. For example:\nmcp2cli\n--mcp\nhttps://mcp.example.com/sse\n--list\nEnter fullscreen mode\nExit fullscreen mode\nOr for an OpenAPI specification:\nmcp2cli\n--openapi\n./api-spec.yaml\n--list\nEnter fullscreen mode\nExit fullscreen mode\nAdvanced Features\nCustomization\nmcp2cli\nallows for customization of the CLI interface and behavior. You can define custom commands and flags to suit your specific needs. For example, you can create a custom command to fetch and display a subset of tools:\nmcp2cli\n--mcp\nhttps://mcp.example.com/sse\n--custom-command\nfetch-tools\n--filter\n\"type:admin\"\nEnter fullscreen mode\nExit fullscreen mode\nError Handling\nmcp2cli\nincludes robust error handling mechanisms to ensure that issues are reported clearly and concisely. For example, if a tool invocation fails, the error message will include the relevant details:\nmcp2cli\n--mcp\nhttps://mcp.example.com/sse create-task\n--title\n\"Fix bug\"\nError: Failed to create task. Reason: Invalid task title.\nEnter fullscreen mode\nExit fullscreen mode\nLogging and Debugging\nFor troubleshooting and debugging,\nmcp2cli\nprovides logging options. You can enable verbose logging to see detailed information about the requests and responses:\nmcp2cli\n--mcp\nhttps://mcp.example.com/sse create-task\n--title\n\"Fix bug\"\n--verbose\nEnter fullscreen mode\nExit fullscreen mode\nConclusion\nmcp2cli\nis a powerful tool that addresses the inefficiencies of traditional MCP servers by dynamically discovering and invoking tools on demand. This approach significantly reduces token usage and enhances the overall performance of the system. Whether you are working with an MCP server or an OpenAPI specification,\nmcp2cli\nprovides a consistent and efficient CLI interface.\nBy adopting\nmcp2cli\n, you can achieve substantial token savings and improve the efficiency of your language models. For more information and consulting services, visit\nhttps://www.mgatc.com\n.\nOriginally published in Spanish at\nwww.mgatc.com/blog/mcp2cli/",
  "metadata": {
    "title": "Show HN: Mcp2cli – One CLI for every API, 96-99% fewer tokens than native MCP! - DEV Community",
    "description": "Introduction   In the realm of Model Control Protocol (MCP) servers, efficiency and token... Tagged with mcp2cli, cli, api, tokens.",
    "keywords": "mcp2cli, cli, api, tokens, software, coding, development, engineering, inclusive, community",
    "author": null,
    "og:type": "article",
    "og:url": "https://dev.to/mgobea/show-hn-mcp2cli-one-cli-for-every-api-96-99-fewer-tokens-than-native-mcp-5c49",
    "og:title": "Show HN: Mcp2cli – One CLI for every API, 96-99% fewer tokens than native MCP!",
    "og:description": "Introduction   In the realm of Model Control Protocol (MCP) servers, efficiency and token...",
    "og:site_name": "DEV Community",
    "og:image": "https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkgs6hmepezbov58ithug.png",
    "twitter:site": "@thepracticaldev",
    "twitter:creator": "@",
    "twitter:title": "Show HN: Mcp2cli – One CLI for every API, 96-99% fewer tokens than native MCP!",
    "twitter:description": "Introduction   In the realm of Model Control Protocol (MCP) servers, efficiency and token...",
    "twitter:card": "summary_large_image",
    "twitter:widgets:new-embed-design": "on",
    "twitter:image:src": "https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkgs6hmepezbov58ithug.png"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "file": "attachments/40e132ff00a0/code/body-000.txt",
      "chars": 49,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-001.txt",
      "chars": 61,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-002.txt",
      "chars": 72,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-003.txt",
      "chars": 41,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-004.txt",
      "chars": 50,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-005.txt",
      "chars": 52,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-006.txt",
      "chars": 23,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-007.txt",
      "chars": 54,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-008.txt",
      "chars": 49,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-009.txt",
      "chars": 41,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-010.txt",
      "chars": 93,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-011.txt",
      "chars": 130,
      "language": "text"
    },
    {
      "file": "attachments/40e132ff00a0/code/body-012.txt",
      "chars": 82,
      "language": "text"
    }
  ],
  "images": [],
  "audio": [],
  "videos": [],
  "links": [
    {
      "href": "https://www.mgatc.com/",
      "label": "https://www.mgatc.com",
      "type": "a"
    },
    {
      "href": "https://www.mgatc.com/blog/mcp2cli/",
      "label": "www.mgatc.com/blog/mcp2cli/",
      "type": "a"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:50:08Z",
  "source_url": "https://dev.to/mgobea/show-hn-mcp2cli-one-cli-for-every-api-96-99-fewer-tokens-than-native-mcp-5c49",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 7018,
  "expected_body_images": 0,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/40e132ff00a0/pages/source.html",
  "local_html": "attachments/40e132ff00a0/pages/article.html",
  "body_base_path": "attachments/40e132ff00a0/pages/",
  "body_markdown_path": "attachments/40e132ff00a0/pages/article.md"
}