Skip to main content
MindStudio
Pricing
Blog About
My Workspace

How to Build a CLI for Any Tool Using Claude Code and Printing Press

CLIs use 35x fewer tokens than MCP servers and are more reliable for AI agents. Learn how to build custom CLIs for tools without public APIs using Claude Code.

MindStudio Team RSS
How to Build a CLI for Any Tool Using Claude Code and Printing Press

Why AI Agents Work Better With CLIs Than MCP Servers

If you’re building AI agents that interact with external tools, you’ve probably heard a lot about MCP (Model Context Protocol). It’s Anthropic’s standard for connecting AI models to external capabilities, and it’s gained significant traction. But there’s a quieter, more practical approach that many production teams are switching to: building lightweight CLIs and calling them as shell commands.

The difference in efficiency is significant. CLIs use roughly 35x fewer tokens than equivalent MCP server implementations. For agents running hundreds or thousands of tool calls, that’s not a minor optimization — it fundamentally changes what’s economically feasible.

This guide covers how to build a CLI for any tool using Claude Code and Printing Press, including tools that don’t have a public API. You’ll walk away with a working pattern you can apply immediately.


The Case for CLIs Over MCP in Agent Workflows

Before getting into the how, it’s worth understanding why this approach exists.

What MCP Actually Costs You

MCP servers are powerful. They give AI systems a structured, schema-driven way to discover and call tools. But that structure has real costs:

  • Token overhead per call. Every MCP interaction includes verbose JSON schemas, capability declarations, and protocol framing. A simple action that takes 50 tokens as a shell command can require 1,700+ tokens through MCP.
  • Complexity creep. Running an MCP server means managing a persistent process, handling connection state, and dealing with protocol errors that have nothing to do with your actual task.
  • Debugging friction. When something goes wrong with an MCP call, the failure mode is often opaque. A CLI failure prints an error message directly to stdout/stderr — exactly what an AI agent can parse and reason about.

Remy doesn't write the code. It manages the agents who do.

R
Remy
Product Manager Agent
Leading
Design
Engineer
QA
Deploy

Remy runs the project. The specialists do the work. You work with the PM, not the implementers.

Why CLIs Are More Agent-Friendly

When Claude Code calls a shell command, the feedback loop is simple: input goes in, output or an error comes back. The agent can read the output, decide what to do next, and move on. There’s no schema to maintain, no server to keep alive, and no additional authentication layer to wrangle.

CLIs also compose naturally. You can pipe outputs between commands, wrap them in scripts, and version-control the whole thing alongside your agent’s code.

The practical upshot: CLIs tend to be more reliable in production agentic workflows, especially when your agent is operating autonomously over long tasks.


What Is Printing Press?

Printing Press is a framework for generating CLI interfaces for web-based tools and services — specifically ones that don’t expose a public REST API.

Most enterprise software, legacy SaaS products, and internal tools fall into this category. They have web UIs that work fine for humans but are inaccessible to AI agents through conventional API integration. Printing Press solves this by using browser automation to translate human-facing interfaces into typed, invocable command-line tools.

The output is a set of commands your AI agent can call directly. Instead of navigating a browser session or maintaining complex Playwright scripts, your agent runs something like:

printing-press submit-form --tool invoicing-app --fields '{"invoice_id": "INV-001", "amount": 500}'

Printing Press handles the browser session, element targeting, and state management under the hood. Your agent sees clean I/O.

Where It Fits in a Claude Code Workflow

Claude Code is designed to operate as a coding agent — it reads files, runs commands, edits code, and iterates. When you give Claude Code a well-structured CLI to call, it can:

  1. Use the CLI to perform actions in external tools as part of a larger coding or automation task
  2. Read the CLI output and adjust its next steps accordingly
  3. Chain multiple CLI calls together without token-heavy protocol overhead

The combination of Claude Code (reasoning and code generation) + Printing Press (browser-based CLI generation) + a clean shell interface is a practical stack for automating tools that were never designed for programmatic access.


Prerequisites

Before you start, make sure you have:

  • Claude Code installed and authenticated (npm install -g @anthropic-ai/claude-code or equivalent)
  • Node.js 18+ on your system
  • Printing Press installed (npm install -g @printing-press/cli)
  • Basic familiarity with command-line tools
  • The target tool’s web URL and a valid account with appropriate permissions

You don’t need to know how the target tool’s internals work. That’s part of what this process handles for you.


Step 1: Identify the Target Tool and Define What You Need From It

Start by being specific about what actions your agent actually needs to perform. Don’t try to wrap an entire application — focus on the two or three actions that matter.

For example, if you’re building an agent that automates invoice submission in an accounting tool with no API, you might only need:

  • Create a new invoice
  • Attach a file
  • Submit for approval

Not a coding agent. A product manager.

Remy doesn't type the next file. Remy runs the project — manages the agents, coordinates the layers, ships the app.

BY MINDSTUDIO

Write these out as a short list before touching any tooling. This list becomes the contract your CLI will fulfill.

Ask Claude Code to Help You Map the Interface

Open a Claude Code session and describe the tool and what you need. Claude Code can:

  • Help you write a spec for the CLI commands you need
  • Generate a Printing Press configuration scaffold
  • Draft the command signatures and flag definitions

Prompt example:

I need to build a CLI for [Tool Name]. It's a web-based invoicing app with no public API. 
I need three commands: create-invoice, attach-file, and submit-invoice. 
Help me write a Printing Press config file that defines these commands.

Claude Code will generate a structured config that Printing Press can use to build your CLI.


Step 2: Record the Browser Actions With Printing Press

Printing Press works by recording what a human does in a browser and converting those actions into reusable, parameterized commands.

Run the recorder:

printing-press record --url https://your-tool.example.com --output ./invoice-cli-config.json

This opens a browser session. Perform the actions you listed in Step 1 — slowly, one at a time. Printing Press watches the DOM, captures element selectors, and logs the interaction sequence.

When you’re done, stop the recorder. You’ll have a JSON config that describes the action steps for each command.

Cleaning Up the Config

Browser recordings are rarely perfect on the first pass. Common issues:

  • Brittle selectors. Generated selectors may target dynamic class names that change between sessions. Replace these with stable attributes like data-testid, aria-label, or name.
  • Timing assumptions. If the target tool has slow page loads or async state updates, add explicit wait conditions.
  • Hardcoded values. Replace any specific data values with parameter placeholders.

This is where Claude Code earns its keep. Paste the raw config into a Claude Code session and ask it to:

  • Identify brittle selectors and suggest more stable alternatives
  • Add appropriate wait conditions
  • Replace hardcoded values with properly typed parameters

Step 3: Generate and Test the CLI

Once the config is clean, generate the CLI:

printing-press generate --config ./invoice-cli-config.json --output ./invoice-cli/

This produces a Node.js package with a binary entry point, typed commands, and a help interface. Install it locally:

cd invoice-cli && npm install && npm link

Test each command manually first:

invoice-cli create-invoice --number INV-001 --client "Acme Corp" --amount 1500
invoice-cli attach-file --invoice-id INV-001 --file ./invoice.pdf
invoice-cli submit-invoice --invoice-id INV-001

If a command fails, the error output will tell you where the browser automation broke. Fix the config, regenerate, and retest.


Step 4: Integrate the CLI Into Your Claude Code Agent

With a working CLI, you can now hand it to Claude Code as a tool. The simplest approach is to add the CLI to your agent’s tool list using Claude Code’s shell execution capability.

In your agent’s system prompt or tool configuration, describe the CLI:

You have access to a CLI tool called `invoice-cli`. Use it to manage invoices in the accounting system.

Available commands:
- invoice-cli create-invoice --number <str> --client <str> --amount <num>
- invoice-cli attach-file --invoice-id <str> --file <path>
- invoice-cli submit-invoice --invoice-id <str>

Run commands using the shell tool. Check stdout for success confirmation and stderr for errors.

Claude Code will call these commands as needed, read the output, and continue reasoning from there.

Handling Errors Gracefully

Build error handling directly into the CLI. When Printing Press encounters a failure, it should:

  1. Print a human-readable error to stderr
  2. Exit with a non-zero status code
  3. Not silently succeed

Claude Code reads stderr and exit codes. A clear failure message lets the agent decide whether to retry, escalate, or take an alternative path.


Step 5: Version Control and Maintain the CLI

Web UIs change. When the target tool updates its interface, your browser automation may break. Build a maintenance strategy from the start:

  • Keep the recording session documented. Store a README alongside the config that describes the human steps to re-record each command.
  • Write a smoke test suite. Even a simple shell script that runs each command with test data and checks for success will catch regressions early.
  • Pin to a specific UI version where possible. Some enterprise tools let you lock to a specific release.

Claude Code can help maintain the CLI over time — run it against a broken command, paste the error, and ask it to diagnose and fix the config.


How MindStudio Fits Into This Pattern

If you’re building agents that need to do more than call a single CLI, MindStudio’s Agent Skills Plugin gives Claude Code and other agents access to 120+ typed capabilities as direct method calls — things like agent.sendEmail(), agent.searchGoogle(), or agent.runWorkflow().

This is the same philosophy as the CLI approach: give the agent clean, typed interfaces that handle infrastructure under the hood (rate limiting, auth, retries), so the agent can focus on reasoning rather than plumbing.

A practical pattern: build your Printing Press CLI for the tool-specific actions that nothing else covers, and use MindStudio’s Agent Skills Plugin for the general-purpose capabilities that are already solved. Your agent gets a consistent interface for both.

For teams that prefer a no-code approach, MindStudio also lets you build and deploy entire automated workflows visually — connecting web tools, AI models, and data sources without writing CLI wrappers at all. You can try it free at mindstudio.ai.


Common Mistakes and How to Avoid Them

Over-engineering the CLI scope

Wrapping an entire application is slow, fragile, and usually unnecessary. Start with the minimum viable set of commands your agent actually needs. You can always add more later.

Skipping manual testing before agent integration

Always test CLI commands manually before handing them to an agent. Agents will call commands in unexpected combinations. A command that works in isolation may fail when called rapidly in sequence due to session state issues.

Ignoring authentication expiration

Browser sessions expire. Build session refresh logic into your CLI, or run Printing Press commands inside a session management wrapper that re-authenticates as needed.

Using MCP when a CLI would do

If your tool interaction is a single action with clear inputs and outputs, a CLI is almost always the right choice. Reserve MCP for cases where you need dynamic capability discovery or bidirectional streaming.


FAQ

Other agents start typing. Remy starts asking.

YOU SAID "Build me a sales CRM."
01 DESIGN Should it feel like Linear, or Salesforce?
02 UX How do reps move deals — drag, or dropdown?
03 ARCH Single team, or multi-org with permissions?

Scoping, trade-offs, edge cases — the real work. Before a line of code.

What is the difference between a CLI and an MCP server for AI agents?

A CLI is a command-line tool that an AI agent calls via shell execution. The agent runs a command, gets output, and continues. An MCP server is a persistent process that exposes tools through Anthropic’s Model Context Protocol, which includes schema definitions, capability declarations, and structured JSON communication. CLIs require far fewer tokens per interaction — roughly 35x fewer in typical use — because they skip the protocol framing. MCP is more appropriate when you need dynamic tool discovery or when multiple systems need to share access to the same tool definition.

Can I build a CLI for a tool that uses JavaScript-heavy single-page applications?

Yes. Printing Press uses browser automation (Playwright under the hood), so it handles JavaScript-rendered content, dynamic state changes, and client-side routing. The recorder waits for DOM stability before capturing element states, which means SPAs work as well as traditional server-rendered pages. The main challenge with SPAs is selector stability — dynamic class names are common, so you’ll need to rely on data-testid attributes or ARIA labels where available.

Does Claude Code work well as an orchestrator for CLI-based tools?

Claude Code works well for this use case precisely because it’s built around shell execution. It can call CLI commands, read their output, reason about what to do next, and chain multiple tool calls together. The key is giving Claude Code a clear description of each command’s interface in the system prompt, so it knows what flags to use and what output format to expect.

How do I handle authentication for CLIs built with Printing Press?

Authentication depends on the target tool. For username/password login, Printing Press can record the login flow and replay it as part of session initialization. For tools that use SSO or MFA, you’ll typically want to store session cookies after a manual authentication step and have the CLI reload them on startup. Environment variables are the right place to store credentials — never hardcode them in the config or commit them to version control.

What happens when the target tool’s UI changes and breaks my CLI?

Re-record the affected command using Printing Press and regenerate the CLI. If you’ve kept a README documenting the exact human steps for each recording, this is usually a 15–30 minute fix. Automated smoke tests will catch UI changes before they cause silent failures in production agent runs.

Is this approach safe for production agent workflows?

It can be, with appropriate guardrails. The main risks are session management (expired auth), UI instability (selectors breaking), and unintended side effects from agents calling commands in unexpected sequences. Mitigate these with: explicit session refresh logic, smoke tests run on a schedule to catch UI drift, and rate limiting or human-in-the-loop checks for high-stakes actions like financial transactions or data deletion.


Key Takeaways

  • CLIs use roughly 35x fewer tokens than MCP server implementations, making them significantly more cost-effective for production agent workflows.
  • Printing Press converts browser-based tool interactions into clean, invocable CLI commands — including for tools with no public API.
  • Claude Code can help you design the CLI spec, clean up Printing Press configs, and maintain the CLI when the target UI changes.
  • Focus your CLI on the minimum set of commands your agent actually needs. Don’t wrap entire applications.
  • Pair your Printing Press CLIs with a platform like MindStudio for the general-purpose capabilities — email, search, workflow orchestration — that are already solved infrastructure.
REMY IS NOT
  • a coding agent
  • no-code
  • vibe coding
  • a faster Cursor
IT IS
a general contractor for software

The one that tells the coding agents what to build.

The CLI-first approach to agent tool integration isn’t glamorous, but it’s practical. Fewer tokens, cleaner error handling, and no persistent server to babysit. For agents doing real work in production, that reliability compounds quickly.

Presented by MindStudio

No spam. Unsubscribe anytime.