Skip to content

CLI Reference

Matthew Vlasov edited this page Nov 23, 2026 · 2 revisions

This page documents every subcommand and option of the nodepilot binary, with examples.

nodepilot [--data-dir <DIR>] <COMMAND>

Commands:
  serve   Run the web panel (UI + REST API + MCP over HTTP)
  mcp     Run an MCP server on stdio (for Claude, Cursor, etc.) using the same database
  user    Manage panel users: create, reset-2fa, passwd
  token   API tokens for CLI, MCP and agents: create
  help    Print help for a command

Common options

Option Env variable Default Meaning
--data-dir <DIR> NODEPILOT_DATA data Data directory with the database and master key. Global: accepted before or after the subcommand
-h, --help Print help (also nodepilot help <command>)
-V, --version Print the version, e.g. nodepilot 0.1.0

Every command opens the data directory, applies pending database migrations and loads the master key before doing anything else. That has some consequences:

  • Point every command at the right data directory. With the systemd setup that is /var/lib/nodepilot. The CLI does not read /etc/nodepilot/nodepilot.env, and the relative default data creates a new, empty database in the current directory.
  • Run commands as the service user (sudo -u nodepilot ...) so that any files SQLite creates stay owned by nodepilot.
  • The master key must be reachable. If you sealed it in the TPM, see Troubleshooting.
  • You can run user and token commands while the panel is running. They share the same SQLite database.

On a systemd install, a convenient shell alias:

alias np='sudo -u nodepilot /usr/local/bin/nodepilot --data-dir /var/lib/nodepilot'

Logs go to stderr. Set the level with RUST_LOG (default info,sqlx=warn,russh=warn).

serve

Runs the panel: web UI, REST API, WebSocket terminal and MCP over HTTP (POST /api/mcp). It also starts the background jobs: stats polling, the backup scheduler, the terminal session reaper, the update checker and audit log cleanup.

Option Env variable Default Meaning
--listen <ADDR> NODEPILOT_LISTEN 127.0.0.1:7780 IP:port to listen on
--stats-interval <SECS> NODEPILOT_STATS_INTERVAL 30 Stats polling interval in seconds (minimum 5)
--metrics-retention-days <DAYS> NODEPILOT_METRICS_RETENTION_DAYS 7 Days of metric history to keep
--secure-cookies NODEPILOT_SECURE_COOKIES off Mark the session cookie Secure (env value must be true or false)
--cors-origins <LIST> NODEPILOT_CORS_ORIGINS none Comma-separated origins allowed to call the API cross-origin with a Bearer token
--trusted-proxies <LIST> NODEPILOT_TRUSTED_PROXIES none Reverse proxies on other hosts (IPs or CIDRs) whose X-Forwarded-For is trusted; loopback is always trusted

Details for each option are in Configuration.

# Local test run
nodepilot serve --data-dir ./np-data

# Listen on all interfaces, poll every 15 s, keep 30 days of history
nodepilot serve --data-dir /srv/nodepilot --listen 0.0.0.0:7780 \
  --stats-interval 15 --metrics-retention-days 30

# Behind HTTPS, with a separate web client allowed
NODEPILOT_SECURE_COOKIES=true \
NODEPILOT_CORS_ORIGINS=https://app.example.com \
nodepilot serve --data-dir /var/lib/nodepilot

If there are no users yet, serve logs no users yet — open http://<listen> to create the administrator account. If the port is taken, it exits with an error (see Troubleshooting).

mcp

Runs an MCP server over stdio against the same database, for an AI client running on the panel host. Stdout carries the MCP protocol; logs go to stderr.

Option Env variable Default Meaning
--token <TOKEN> NODEPILOT_TOKEN none Limit the agent to the permissions of this API token. Without it, the agent has full access, acting as the first user created

At least one user must exist; otherwise it fails with no users yet: open the panel and create the administrator first. An unknown or expired token fails with invalid API token.

# Full access (only on a host you control)
sudo -u nodepilot nodepilot mcp --data-dir /var/lib/nodepilot

# Restricted to a token's permissions
sudo -u nodepilot env NODEPILOT_TOKEN=np_... nodepilot mcp --data-dir /var/lib/nodepilot

Example MCP client entry (for a client that launches stdio servers from a JSON config):

{
  "mcpServers": {
    "nodepilot": {
      "command": "/usr/local/bin/nodepilot",
      "args": ["mcp", "--data-dir", "/var/lib/nodepilot", "--token", "np_..."]
    }
  }
}

The client process must be able to read the data directory and the master key. For remote agents, use HTTP instead (POST https://<panel>/api/mcp with a Bearer token). See MCP and AI Agents.

user

Manage panel users. Every user has full access in the web UI; API tokens are how access is restricted.

user create

nodepilot user create <USERNAME> --password <PASSWORD>
Argument / option Env variable Meaning
<USERNAME> Login name. Leading and trailing spaces are trimmed; must not be empty. Must be unique
--password <PASSWORD> NODEPILOT_PASSWORD At least 8 characters. Required

Prints created user <name>. Works whether or not other users exist, so it can also create the first administrator instead of the web setup form.

sudo -u nodepilot nodepilot --data-dir /var/lib/nodepilot user create alice --password 'correct horse battery'

# Keep the password out of shell history and the process list
read -rs NODEPILOT_PASSWORD; export NODEPILOT_PASSWORD
nodepilot --data-dir ./np-data user create alice

With sudo, note that it does not pass your environment through by default. Run the read/export as the target user, or use the --password form.

user passwd

nodepilot user passwd <USERNAME> --password <PASSWORD>
Argument / option Env variable Meaning
<USERNAME> Existing user
--password <PASSWORD> NODEPILOT_PASSWORD New password, at least 8 characters. Required

Sets the password and ends all of the user's sessions. API tokens stay valid. Prints password updated for <name>.

sudo -u nodepilot nodepilot --data-dir /var/lib/nodepilot user passwd admin --password 'new-long-password'

user reset-2fa

nodepilot user reset-2fa <USERNAME>

Turns off two-factor authentication for the user (secret, pending setup and recovery codes are removed) and ends all of their sessions. Use it when someone has lost both their authenticator and their recovery codes. Prints two-factor authentication disabled for <name>. The reset is recorded in the audit log as a critical event (auth:2fa-reset-cli).

sudo -u nodepilot nodepilot --data-dir /var/lib/nodepilot user reset-2fa admin

reset2fa is accepted as an alias.

A missing user gives Error: user not found.

token

token create

Issues an API token for a user and prints it to stdout. The token is shown only once; only its hash is stored.

nodepilot token create --user <USER> --name <NAME> [--read-only] [--expires-in-days <DAYS>]
Option Default Meaning
--user <USER> required Username the token belongs to
--name <NAME> required Label shown in the panel's token list
--read-only off (full access) Read access to every area except command execution (exec) and administration (admin)
--expires-in-days <DAYS> 0 Lifetime in days; 0 means the token never expires

Tokens look like np_ followed by 64 hex characters. Use them as Authorization: Bearer np_.... Tokens with custom per-area permissions are created in the panel (API section) or through POST /api/tokens; see API.

# Full-access token for an AI agent
sudo -u nodepilot nodepilot --data-dir /var/lib/nodepilot token create --user admin --name claude

# Read-only token for monitoring that expires in 90 days
sudo -u nodepilot nodepilot --data-dir /var/lib/nodepilot token create \
  --user admin --name grafana --read-only --expires-in-days 90

# Store it straight into a file
nodepilot --data-dir ./np-data token create --user admin --name ci > ci.token

An unknown user gives user <name> not found.

Exit status

Commands exit with status 0 on success. On failure they print Error: <message> (with a Caused by: chain) to stderr and exit non-zero.

Clone this wiki locally