cli-mcp examples/serve

NAME

demo - tiny cli served as MCP tools

SYNOPSIS

demo

DESCRIPTION

demo is the smallest end-to-end exercise of cli-mcp: a one-leaf urfave/cli tree projected as a single MCP tool over the stdio transport.

How the projection works:

- Every leaf command becomes an MCP tool. Tool name is the
  underscore-joined command path with the root stripped, so the
  leaf `hello` becomes the tool `hello`. Multi-level trees produce
  tool names like `module_latest`, `cluster_node_drain`.
- The tool's input schema is derived from the leaf's flags and
  ArgsUsage. Bool flags become boolean inputs, string flags
  become strings with default values, positional args go into
  an `args` array.
- The same Action runs whether a human typed `demo hello world`
  or an agent called the MCP tool `hello` with `{"args":["world"]}`.
  The stdio.Reader / stdio.Writer plumbing just changes who
  reads and writes; the Action body is identical.

Operating model for an agent calling these tools:

- stdio transport: the agent spawns the binary and exchanges
  JSON-RPC over the child's stdin/stdout. Used by editor
  integrations (Claude Code, mcp-inspector, mcporter).
- The MCP server runs until the client closes stdio. No
  heartbeat or long-lived connection management needed.
- On Action error, the tool call returns isError=true with the
  error string. Stdout/stderr from the Action body flows into
  the tool result's content, not back to the spawning agent's
  stdout.

Usage:

demo [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...]

COMMANDS

hello

print a greeting

--lang="": language: en or es (default: "en")

--loud: shout the greeting