Show HN: CLI-use – 一条命令将任何 MCP 服务器变成 CLI

1作者: justvugg3 个月前
大家好, 我开发了 cli-use,这是一个小型的 Python 工具,可以将任何 MCP 服务器转换为原生 CLI。 这个想法很简单: HTTP 有 curl,Docker 有 docker,Kubernetes 有 kubectl —— MCP 也应该有一个 shell 原生客户端。 我为什么开发它: MCP 很有用,但通过代理使用它会带来一些开销: * 每次会话都需要进行模式发现 * 每次调用都带有 JSON-RPC 框架 * 当有用的输出只有一两行时,响应通常是冗长的 JSON cli-use 将其转换为简洁的 CLI,因此可以像普通 shell 命令一样调用工具。 示例: ```bash pip install cli-use cli-use add fs /tmp cli-use fs list_directory --path /tmp ``` 之后,MCP 服务器的行为就像一个常规 CLI: * 可供代理使用 * 可供人类使用 * 可从脚本 / subprocess.run 使用 * 可与 grep、head、xargs 等组合使用 示例: ```bash cli-use fs search_files --path /tmp --pattern "*.md" | head cli-use fs read_text_file --path /tmp/notes.md | grep TODO ``` 我非常关注的一件事是代理的人体工程学。 每次添加还会发出一个 SKILL.md 以及一个 AGENTS.md 指针,因此在存储库中工作的代理可以自动发现和使用 CLI。 一些细节: * 纯 Python 标准库 * 零运行时依赖 * 持久别名 * 适用于 npm、pip、pipx 和本地 MCP 服务器 * 内置常用 MCP 服务器注册表 我还针对真实的 @modelcontextprotocol/server-filesystem 服务器(14 个工具)进行了基准测试。根据会话大小,令牌节省了大约 60-80%,这主要得益于消除了模式开销和冗余的请求 / 响应框架。 它仍处于 alpha 阶段,但已经可以使用了。 仓库: [https://github.com/JustVugg/cli-use](https://github.com/JustVugg/cli-use)
查看原文
Hi everyone,<p>I built cli-use, a small Python tool that turns any MCP server into a native CLI.<p>The idea is simple: HTTP has curl, Docker has docker, Kubernetes has kubectl — MCP should have a shell-native client too.<p>Why I made it:<p>MCP is useful, but using it through agents has overhead:<p>every session pays schema discovery cost every call carries JSON-RPC framing responses are often verbose JSON when the useful output is just a line or two<p>cli-use converts that into a terse CLI so tools can be called like normal shell commands.<p>Example:<p>pip install cli-use cli-use add fs &#x2F;tmp cli-use fs list_directory --path &#x2F;tmp<p>After that, the MCP server behaves like a regular CLI:<p>usable by agents usable by humans usable from scripts &#x2F; subprocess.run composable with grep, head, xargs, etc.<p>Example:<p>cli-use fs search_files --path &#x2F;tmp --pattern &quot;*.md&quot; | head cli-use fs read_text_file --path &#x2F;tmp&#x2F;notes.md | grep TODO<p>One thing I cared about a lot is agent ergonomics.<p>Every add also emits a SKILL.md plus an AGENTS.md pointer, so agents working in a repo can discover and use the CLI automatically.<p>A few details:<p>pure Python stdlib zero runtime deps persistent aliases works with npm, pip, pipx, and local MCP servers built-in registry for common MCP servers<p>I also benchmarked it against the real @modelcontextprotocol&#x2F;server-filesystem server (14 tools). Depending on session size, token savings were around 60–80%, mostly by removing schema overhead and verbose request &#x2F; response framing.<p>It’s still alpha, but already usable.<p>Repo: <a href="https:&#x2F;&#x2F;github.com&#x2F;JustVugg&#x2F;cli-use" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;JustVugg&#x2F;cli-use</a>