MCP vs CLI-First

cli4ai takes a CLI-first approach to AI tool development. Instead of building MCP servers directly, you build simple CLI tools that cli4ai automatically wraps as MCP servers.

What is MCP?

MCP (Model Context Protocol) is a standardized protocol for AI assistants to interact with external tools. It uses JSON-RPC 2.0 over stdio to communicate between the AI client and tool servers.

When you add tools to Claude Code, Cursor, or other AI assistants, they use MCP to discover and call those tools.

The Traditional Approach

Building an MCP server the traditional way requires:

Without cli4ai
# Clone the repository
git clone https://github.com/someone/gmail-mcp-server

# Install dependencies
cd gmail-mcp-server && npm install

# Build the package
npm run build

# Edit Claude config manually
vim ~/.config/claude/mcp_settings.json

# Debug paths and environment variables...
# ~15 minutes per tool

And when building your own MCP server, you need to:

  • Implement the JSON-RPC protocol
  • Handle initialize, tools/list, tools/call methods
  • Manage stdio communication
  • Deal with complex error handling
  • Write boilerplate for every tool

The CLI-First Approach

cli4ai flips this around. Instead of building for MCP, you build simple CLI tools:

With cli4ai
$ cli4ai add gmail
✓ gmail@1.0.0 installed

# That's it. ~3 seconds.

How it works

  1. Tools are CLI programs first - Simple scripts that output JSON
  2. MCP is optional - Tools work standalone, making them testable and portable
  3. Automatic wrapping - cli4ai converts CLI tools to MCP servers on the fly

Side-by-Side Comparison

Aspect Traditional MCP CLI-First (cli4ai)
Installation Clone, install, build, configure cli4ai add pkg
Setup time ~15 minutes ~3 seconds
Tool architecture MCP server implementation Simple CLI script
Boilerplate High (protocol handling) Minimal (just manifest)
Testing Requires MCP client Run directly in terminal
Portability MCP-only Works anywhere (scripts, CI, cron)
Package management Manual npm-like experience
Configuration Manual JSON editing Auto-generated
Learning curve Steep (protocol knowledge) Shallow (CLI basics)

Building a Tool: Traditional vs CLI-First

Traditional MCP Server

// Lots of boilerplate to implement MCP protocol
import { Server } from "@modelcontextprotocol/sdk/server";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio";

const server = new Server({
  name: "my-tool",
  version: "1.0.0",
}, {
  capabilities: { tools: {} }
});

server.setRequestHandler("tools/list", async () => ({
  tools: [{
    name: "my_command",
    description: "Does something",
    inputSchema: {
      type: "object",
      properties: {
        arg: { type: "string" }
      }
    }
  }]
}));

server.setRequestHandler("tools/call", async (request) => {
  // Handle tool execution...
});

const transport = new StdioServerTransport();
await server.connect(transport);

CLI-First Tool

#!/usr/bin/env bun
// Just a simple CLI script!
import { cli, output } from '@cli4ai/lib/cli';

const program = cli('my-tool', '1.0.0', 'Does something');

program
  .command('my-command')
  .argument('', 'The argument')
  .action(async (arg) => {
    const result = await doSomething(arg);
    output(result);  // Output JSON
  });

program.parse();

With the manifest (cli4ai.json):

{
  "name": "my-tool",
  "version": "1.0.0",
  "entry": "run.ts",
  "commands": {
    "my-command": {
      "description": "Does something",
      "args": [{ "name": "arg", "required": true }]
    }
  },
  "mcp": { "enabled": true }
}

cli4ai reads the manifest and automatically creates the MCP wrapper. Zero protocol code required.

Benefits of CLI-First

Testability

Run your tool directly in the terminal. No MCP client needed for testing.

bun run run.ts my-command "test"

Portability

Use tools in shell scripts, cron jobs, CI pipelines - not locked to MCP.

cli4ai run slack send #alerts "Deploy done"

Simplicity

If you can write a CLI script that outputs JSON, you can build an AI tool.

output({ result: "success" })

Familiar

npm-like workflow. If you know npm, you already know cli4ai.

cli4ai add, cli4ai remove, cli4ai list

When to Use Each

Use cli4ai when:

  • You want tools that work with or without AI agents
  • You need easy installation and updates
  • You prefer simple CLI development over protocol implementation
  • You want to publish tools that others can install easily

Use traditional MCP when:

  • You need advanced MCP features (resources, prompts)
  • You're building deeply integrated AI experiences
  • You need real-time streaming responses

The Big Picture

"cli4ai doesn't replace MCP - it makes MCP accessible."

By treating tools as CLI-first and wrapping them with MCP automatically, cli4ai gives you:

  • Simple development - Build normal CLI tools
  • Wide compatibility - Use in Claude, Cursor, or any MCP client
  • Easy distribution - npm-style package management
  • Zero configuration - Everything just works

MCP is the protocol. CLI is the interface. cli4ai is the bridge.

Next Steps