User Guide · Operate · Automation

Automation

Everything you can do in the console can also be done from scripts, pipelines and AI assistants. Jarwis ships four ways to automate, all built on the same public API v1 and the same permission model, so a token can never do more than you allowed it to do.

ToolUse it toPlan
API v1 + scoped tokensCall Jarwis from your own code or CIAll
jarwis CLICreate clusters, run backups and watch jobs from a terminal or pipelineAll
Terraform providerKeep clusters, backup schedules, alert channels and users in version controlAll
MCP serverLet Claude, Cursor or another AI client read your clusters and propose changesPro
Runbook autopilotGet a ready-made, approvable fix plan on an alarmPro

API v1 and scoped tokens

Create a token under Settings → Security → API keys. Unlike a personal sign-in key, a scoped token is built for automation and is valid only for /api/v1/*.

SettingMeaning
Scoperead (list and inspect) < operate (run backups, install clusters, acknowledge alarms) < admin (also manage users and alert channels). Each scope includes the ones before it
Cluster restrictionOptional. Limit the token to specific clusters; any other cluster answers 404, and organization-wide routes answer 403
Rate limitRequests per minute, 10–1200 (default 120). Above it the API answers 429 with a Retry-After header
ExpiryOptional. A revoked or expired token is rejected with 401 immediately
  • The full API description is served at /api/v1/openapi.json (no sign-in needed).
  • Send the token as Authorization: Bearer <token>. GET /api/v1/me shows what a token may do.
  • Every call is recorded in the audit log against the token that made it.
  • The token is shown once, when you create it. Store it in your CI secret store, never in a repository.
Good practice Create one token per pipeline, with the lowest scope that works and, where possible, a cluster restriction. Revoke it when the pipeline is retired.

The jarwis command-line client

A single static binary (about 6 MB, Linux, macOS and Windows) that talks only to API v1, so a scoped token is all it needs.

jarwis login --url https://your-controller --token-stdin < token.txt
jarwis whoami
jarwis cluster list
jarwis backup run --cluster 7 --wait
  • login checks the token and saves it in a private config file (readable only by you). In CI, skip login and set JARWIS_URL and JARWIS_TOKEN instead. JARWIS_CONFIG points at a different config file.
  • Prefer --token-stdin or the environment variable over --token, so the token stays out of your shell history.
CommandNeeds
cluster list / get ID / topology IDread
cluster create --name … --type … --topology … --member NODE:ROLE… [--install --wait] (or --file body.json)operate
cluster install ID [--wait]operate
backup list [--cluster ID] / backup run --cluster ID [--wait]read / operate
job list / job get ID [--log] / job wait IDread
alarm list / alarm ack IDread / operate
cluster export (ID… | --all) --hclread
  • --wait follows the job and prints progress to stderr, so standard output stays clean for scripts.
  • Add -o json to any command for JSON you can pipe to jq.
  • Exit codes: 0 success; 1 API or network error, or a waited job that ended failed; 2 usage error. A pipeline step therefore fails exactly when the operation failed.

Terraform provider

The jarwis provider describes your estate as code. It uses API v1 with a scoped token.

TypeNameManages
Resourcejarwis_clusterA cluster: defines it, installs it and waits for the install job
Resourcejarwis_backup_scheduleA backup schedule on a cluster
Resourcejarwis_alert_channelA notification channel (admin token)
Resourcejarwis_userA console user (admin token)
Data sourcejarwis_clusterLook up a cluster by id or name
  • The API has no in-place cluster update, so changing a cluster's name, type, topology or members replaces it. Protect real clusters with lifecycle { prevent_destroy = true }.
  • Destroying a cluster runs an uninstall job; data directories stay on the nodes unless you set purge_data_on_destroy.
  • Passwords and channel configs are write-only: Terraform sends them but never reads them back, so it cannot detect drift on them.

Adopt clusters you already have

You do not have to rebuild anything. Let the CLI write the Terraform for what exists:

jarwis cluster export --all --hcl > jarwis.tf
terraform plan     # shows only imports: nothing to add, change or destroy
terraform apply

The export contains import blocks (Terraform 1.5 or later), the matching cluster and backup-schedule resources, and prevent_destroy. Secrets are never exported; add them yourself through variables.

MCP server for AI assistants

Jarwis has a built-in Model Context Protocol server at /mcp. An AI client such as Claude Code, Claude Desktop or Cursor can look at your clusters and propose changes. It can never run a change on its own.

Plan The MCP server is a Pro feature. Clients can still connect on Lite, but tools answer with a plan error.

1. Create a key

Under Settings → Security → API keys, create a personal key. A viewer key can only read; an admin key can also create action plans. (Scoped API v1 tokens are not accepted on /mcp; use a personal key here.)

2. Connect your client

claude mcp add --transport http jarwis https://your-controller/mcp \
  --header "Authorization: Bearer <key>"

Cursor and other clients that speak streamable HTTP take the same URL and header in their MCP settings ("type": "http"). Claude Desktop connects through the mcp-remote bridge. Keep the key in the client's secret store or an environment variable.

What the assistant can do

The server exposes 20 tools: 10 read tools, one dry run, eight action tools that only create plans, and approve_action.

KindTools
Readlist_clusters, get_cluster_topology, list_alarms, list_backups, qan_top_queries, config_drift, capacity, available_updates, list_approvals, get_approval
Dry runfailover_dry_run — shows what a failover would do, changes nothing
Propose (creates a plan)trigger_backup, restore_backup, pitr_restore, switchover, rebuild_replica, galera_recovery, rolling_update, maintenance_window
Approve (opt-in)approve_action — only when an admin has enabled operator approval (see below)

Nothing runs until a person approves

  1. The assistant proposes

    It calls an action tool. Jarwis checks the cluster and your permissions, then stores a pending plan with a plain-language summary and the exact steps. Nothing has run.
  2. You review

    Open Approvals in the sidebar. The plan stays valid for 30 minutes.
  3. You approve or reject

    Click Approve & run or Reject. This needs a signed-in console session; an API key cannot approve its own plan. The plan runs as you, with your role, and the result is saved on the plan.
  • The command freeze (Settings → Security) stops new plans and approvals while it is on.
  • Every action call and every approval is written to the audit log.
  • Optionally, admins can allow operator-scope tokens to approve plans from MCP (Let operator tokens approve MCP plans in the sign-in policy). It is off by default.

Guided procedures

Seven ready-made procedures appear as slash commands or in the prompt picker of your client. Each one reads first, stops if a check fails, ends with a plan for approval, and verifies afterwards.

ProcedureWhat it does
daily_reviewRead-only health report: needs action / watch / OK
failover_drillRehearses a failover without changing anything
switchover_procedurePlanned primary switch with a maintenance window
upgrade_procedureRolling update, with a backup first if none is recent
pitr_procedurePoint-in-time restore, with an undo backup first
replica_rebuild_procedureRe-seed a replica from the primary
galera_recovery_procedureRecover a Galera cluster that lost quorum

Runbook autopilot

When an alarm fires, the alarm card can show a remediation plan instead of just a symptom. The plan is built by fixed rules (no AI guesswork), and it goes through the same Approvals queue as MCP plans: you review it and approve it, or nothing happens.

AlarmPlan
Replication lag or replication stoppedRepair replication (restart the stopped IO/SQL thread). If a needed binary log was already purged, the plan is blocked and recommends a rebuild
Disk almost full, disk forecast, log archive lagLog cleanup: purge old MySQL binary logs, keeping the last 72 hours (other engines get advice only)
Backup failedRetry the backup
Galera quorum lost, split brain, node downRejoin the node, or run Galera recovery if quorum is gone
Too many connectionsConnection advice only; nothing to approve
  • Autopilot is a Pro feature. Preparing a plan needs an admin; each alarm has at most one pending plan. Approve it from the alarm card or on the Approvals screen.
  • After a plan runs, Jarwis checks that the alarm cleared and writes the outcome on the alarm. If it is still open 30 minutes later, the alarm card says so, so you can escalate.
  • Destructive steps such as detaching a replica are deliberately never offered.

See also Alerting, AI assistant and Settings & license.