import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
# Mokei CLI
## Installation
```sh
npm install -g mokei
```
```sh
pnpm add -g mokei
```
## Commands
### `mokei chat`
Interactive chat with a model provider. One command handles every provider -- if
`--provider` is omitted, an interactive selection prompt appears.
Usage: `mokei chat --provider ollama --model "llama3.1:8b"`
#### Flags
- `-p, --provider `: model provider (`ollama`, `openai`, `anthropic` or `llama`)
- `-k, --api-key `: provider API key. Prefer the `OPENAI_API_KEY` /
`ANTHROPIC_API_KEY` environment variables -- a key passed on the command line leaks via
`ps` and shell history
- `-u, --api-url `: provider API URL, overriding the default endpoint
- `-m, --model `: model name, or a GGUF file path for the `llama` provider
- `-t, --timeout `: agent turn timeout in seconds (default: `300`)
Inside the session, `/context add [--protocol ] [args...]` attaches
an MCP server. `--protocol` accepts `2026-07-28`, `2025-11-25` or `auto`, and defaults to
`auto`. Type `/` to list the other slash commands.
### `mokei inspect [args...]`
Spawns a local MCP server and asks it to describe itself. On `2026-07-28` that is a
`server/discover` request. On `2025-11-25` it is the `initialize` handshake.
Usage: `mokei inspect npx -y @modelcontextprotocol/server-filesystem ./`
#### Arguments
- `command`: the command to execute to start the MCP server (required)
- `args...`: arguments passed to the command, forwarded as-is
#### Flags
- `-p, --protocol `: protocol revision to speak -- `2026-07-28`, `2025-11-25` or
`auto` (default: `auto`). Must come before the server command. Everything after the
command belongs to the server
### `mokei monitor`
Start a local HTTP server serving the monitor UI, which tracks MCP client-server
interactions routed through `mokei proxy`.
Usage: `mokei monitor --port 4000`
#### Flags
- `-s, --socket-path `: path to the socket used by the host daemon (optional)
- `-p, --port `: port the HTTP server should listen on (optional)
### `mokei proxy [args...]`
Proxy an MCP server so its traffic can be inspected in the monitor.
Usage: `mokei proxy npx -y @modelcontextprotocol/server-filesystem ./`
#### Arguments
- `command`: the command to execute to start the MCP server (required)
- `args...`: arguments passed to the command, forwarded as-is
#### Flags
- `-s, --socket-path `: path to the socket used by the host daemon (optional)
### `mokei daemon`
Manage the per-user host daemon. Restart it to apply changes to `flows.json`.
Usage: `mokei daemon start`
#### Subcommands
- `start`: start the daemon and wait for the flow service
- `stop`: stop the daemon, letting in-flight work drain
- `status`: show whether the daemon is running
- `restart`: stop then start the daemon, applying configuration changes
- `logs`: print the daemon log
#### Flags
For `start`, `stop`, `status` and `restart`:
- `-s, --socket-path `: unix socket path (optional)
- `--json`: print the result as JSON
For `logs`:
- `-n, --lines `: number of lines to show (default: `50`)
- `-f, --follow`: follow the log until interrupted
### `mokei flows`
Inspect configured flows, validate definitions and serve the flow MCP server.
Usage: `mokei flows list --json`
#### Subcommands
- `list`: list configured flows
- `check `: validate a flow definition JSON file
- `mcp`: serve the flow MCP server over stdio, with diagnostics sent to stderr
Usage: `mokei flows check ./flows/example.json`
Usage: `mokei flows mcp --socket-path /tmp/mokei.sock`
#### Arguments
- `file`: path to a flow definition JSON file (required for `check`)
#### Flags
- `-s, --socket-path `: unix socket path (optional, all subcommands)
- `--json`: print the result as JSON (`list` and `check` only)
### `mokei runs`
Start, inspect and cancel flow runs. Trace inspection shows spans with durations, then logs.
Usage: `mokei runs start example --input '{"name":"Ada"}' --wait`
#### Subcommands
- `start [flow]`: start a configured flow, or an inline definition with `--file`
- `get `: show run status, pending items and result
- `list`: list runs
- `cancel `: cancel a run
- `trace `: show the run trace
#### Arguments
- `flow`: ID of a configured flow (optional when using `--file`)
- `runID`: run ID (required for `get`, `cancel` and `trace`)
#### Flags
For all subcommands:
- `-s, --socket-path `: unix socket path (optional)
- `--json`: print the result as JSON
For `start`:
- `--file `: start an inline flow definition instead of a flow ID
- `--input `: run input as a JSON object, or `@path` to a JSON file
- `--label `: label for the run
- `--wait`: watch until the run ends, answering pending items when interactive
For `list`:
- `--state `: filter by `awaiting_approval`, `denied`, `working`,
`input_required`, `completed`, `failed` or `cancelled`
- `--limit `: maximum number of runs
### `mokei inbox`
List and settle pending input and approval items. Declining an approval item denies its run.
Usage: `mokei inbox list --json`
#### Subcommands
- `list`: list pending items
- `show `: show the input request or planned tools
- `answer `: answer an input item or approve an approval item
- `decline `: decline an item
- `cancel `: cancel an item
- `prompt `: open the desktop dialog and report the chosen action
#### Arguments
- `id`: inbox item ID (required for every subcommand except `list`)
#### Flags
For all subcommands:
- `-s, --socket-path `: unix socket path (optional)
- `--json`: print the result as JSON
For `list`:
- `--run `: show only items for this run
For `answer`:
- `--value `: answer an input item with a JSON object, or `@path` to a JSON file
- `--yes`: approve an approval item without asking
For `decline`:
- `--reason `: reason for declining