CLI-Anything: Give Your Agent a CLI Instead of an MCP Server When You Have the Source Code

· AI & ML · By Zeeshan Ahmad

When people want an AI agent to use an application, the reflex today is "write an MCP server for it." The Model Context Protocol gives the agent a list of typed tools, the agent calls them, the server does the work. It is a good standard and it solved a real problem.

But a coding agent already has a tool that can drive almost anything: a shell. If the app you care about has a command-line interface, the agent can read --help, run commands, pipe the output into the next command, and check the result, with no extra protocol in the middle. The catch is that most software, especially desktop software, has no proper CLI.

CLI-Anything is an open-source project from the HKU Data Intelligence Lab (HKUDS) that closes that gap. You point it at an application's source code and it has your coding agent build a full, tested CLI for that application. For apps where you have the source, that is a real alternative to writing an MCP server.

#What CLI-Anything is

CLI-Anything is a plugin and skill for coding agents such as Claude Code, Cursor, Codex, OpenCode and others. Its main command takes a path or a repository:

bash
/cli-anything ./gimp

The agent then runs a fixed seven-phase pipeline:

1. Analyze the source code and map what the GUI does to the functions underneath. 2. Design the command groups, the project state model and the output formats. 3. Implement a Python CLI (built on Click) with a REPL, JSON output and undo/redo. 4. Plan tests in a TEST.md file, both unit and end-to-end. 5. Write the tests. 6. Document the results back into TEST.md, and generate a SKILL.md that tells agents how to use the new CLI. 7. Package it with setup.py so pip install -e . puts a cli-anything-<app> command on your PATH.

After that, a follow-up command, /cli-anything:refine, compares what the app can do against what the CLI covers and fills the gaps. You can run it again and again, optionally with a focus like "batch image filters."

The result is used the way you would use any CLI:

bash
cli-anything-gimp project new --width 1920 --height 1080 -o poster.json
cli-anything-gimp --json layer add -n "Background" --type solid --color "#1a1a2e"

An important detail: the generated CLI calls the real application as its backend. LibreOffice still renders the PDF, Blender still renders the scene. It is not a toy reimplementation, which is what you often end up with when someone writes a quick wrapper by hand.

The project also runs CLI-Hub, a registry of CLIs that the community has already generated (GIMP, Blender, Inkscape, LibreOffice, OBS Studio, Audacity, Zotero, Draw.io, n8n and many more). If someone has already done the work, you install it instead of generating it:

bash
pip install cli-anything-hub
cli-hub search image
cli-hub install gimp

#Why a CLI can be better than an MCP server

#1. The agent only loads what it needs

An MCP server announces all of its tools up front, with names, descriptions and JSON schemas, and that list sits in the model's context for the whole session. Connect a few large servers and you can burn thousands of tokens before the agent has done anything.

A CLI works by progressive disclosure. The agent sees one short SKILL.md, runs cli-anything-gimp --help when it needs to, then cli-anything-gimp layer --help for one command group. It pays for the documentation it actually reads.

#2. Commands compose

Shell commands chain. The agent can run a command, filter its JSON with jq, loop over files, and feed one tool's output into another, all in one step. With MCP, each tool call goes back through the model, and joining two servers' results means more round trips and more tokens.

#3. Humans can run exactly what the agent ran

When an agent uses a CLI, the transcript is a list of commands. You can copy one, run it yourself, put it in a script or a CI job, and get the same result. Debugging an MCP call usually means reading server logs or rebuilding the JSON request by hand.

#4. There is nothing to keep running

An MCP server is a process (or a remote service) that has to be configured, started and kept alive, per client. A CLI is a binary on your PATH. Any agent with a shell can use it, today and with whatever agent you switch to next year.

#5. You own and can test the code

Because CLI-Anything generates ordinary Python with its own test suite, you can read it, change it and review it like the rest of your codebase. The project reports thousands of tests across its harnesses, with end-to-end tests that run the real software, not mocks.

#6. It is built from the real code, not guessed from the outside

This is the part that makes "has source code" the key condition. With the source, the agent can see the real functions behind each menu item, so the CLI can cover most of what the app does. Without it, your options are a thin wrapper around whatever public API exists, or screen automation that clicks pixels and breaks when the UI changes. CLI-Anything replaces that kind of GUI automation for any app it can read.

#Where MCP is still the better choice

A CLI is not a replacement for MCP everywhere. Choose MCP when:

  • The agent has no shell. Chat apps and many hosted assistants can call MCP tools but cannot run commands. A CLI is useless there.
  • You do not have the source. For a closed SaaS product, an MCP server (often from the vendor) built on its public API is the practical route. CLI-Anything can work from API docs or SDKs too, but its main strength is reading source code.
  • You need hosted, multi-user access. Remote MCP servers handle OAuth, per-user permissions and audit in one place. A local CLI runs with the permissions of whoever runs it.
  • You want strict typed contracts. MCP tools have JSON schemas the client validates. A CLI's contract is its flags and its --json output, which is looser.
  • The agent should not have broad shell access. Giving an agent a shell is powerful and risky. MCP lets you expose a narrow, fixed set of actions.

The two also mix well. Nothing stops you from exposing a generated CLI through a small MCP server for clients without a shell, and CLI-Anything's registry already includes entries that bridge to MCP.

#A simple way to decide

  • You have the source, and your agent has a shell: generate a CLI with CLI-Anything, or install one from CLI-Hub.
  • It is closed SaaS with an API: use or write an MCP server.
  • Users talk to it from a chat app or a hosted assistant: MCP.
  • You need per-user auth and an audit trail across a team: remote MCP.
  • It is your own internal tool: a CLI first; add a thin MCP wrapper later only if a shell-less client needs it.

#Things to check before you rely on it

  • Review the generated code. It is written by an agent. Read the commands that write or delete data, and run the tests yourself.
  • Install the real app. A generated CLI drives the real backend, so GIMP, Blender or LibreOffice must be installed for it to work.
  • Expect gaps at first. Coverage after the first run is rarely complete. Plan on a few refine passes for the features you actually use.
  • Keep it in sync. If the upstream app changes, regenerate or refine the CLI, and let its test suite tell you what broke.
  • Mind the permissions. The CLI runs with your user's rights. Run agents in a sandbox or a separate account when they touch anything important.

#Bottom line

MCP is the right answer when the agent cannot run commands, when you only have an API, or when you need hosted, multi-user access. But if you have the source code and your agent works in a terminal, a real CLI is often simpler, cheaper in tokens, easier to debug and easier to reuse. CLI-Anything turns building that CLI from a week of wrapper code into one command and a few rounds of review.

#Sources

Related articles

Home · All Tools · Blog · Privacy · Terms