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.
| Tool | Use it to | Plan |
|---|---|---|
| API v1 + scoped tokens | Call Jarwis from your own code or CI | All |
jarwis CLI | Create clusters, run backups and watch jobs from a terminal or pipeline | All |
| Terraform provider | Keep clusters, backup schedules, alert channels and users in version control | All |
| MCP server | Let Claude, Cursor or another AI client read your clusters and propose changes | Pro |
| Runbook autopilot | Get a ready-made, approvable fix plan on an alarm | Pro |
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/*.
| Setting | Meaning |
|---|---|
| Scope | read (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 restriction | Optional. Limit the token to specific clusters; any other cluster answers 404, and organization-wide routes answer 403 |
| Rate limit | Requests per minute, 10–1200 (default 120). Above it the API answers 429 with a Retry-After header |
| Expiry | Optional. 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/meshows 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.
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
loginchecks the token and saves it in a private config file (readable only by you). In CI, skiploginand setJARWIS_URLandJARWIS_TOKENinstead.JARWIS_CONFIGpoints at a different config file.- Prefer
--token-stdinor the environment variable over--token, so the token stays out of your shell history.
| Command | Needs |
|---|---|
cluster list / get ID / topology ID | read |
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 ID | read |
alarm list / alarm ack ID | read / operate |
cluster export (ID… | --all) --hcl | read |
--waitfollows the job and prints progress to stderr, so standard output stays clean for scripts.- Add
-o jsonto any command for JSON you can pipe tojq. - Exit codes:
0success;1API or network error, or a waited job that ended failed;2usage 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.
| Type | Name | Manages |
|---|---|---|
| Resource | jarwis_cluster | A cluster: defines it, installs it and waits for the install job |
| Resource | jarwis_backup_schedule | A backup schedule on a cluster |
| Resource | jarwis_alert_channel | A notification channel (admin token) |
| Resource | jarwis_user | A console user (admin token) |
| Data source | jarwis_cluster | Look 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.
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.
| Kind | Tools |
|---|---|
| Read | list_clusters, get_cluster_topology, list_alarms, list_backups, qan_top_queries, config_drift, capacity, available_updates, list_approvals, get_approval |
| Dry run | failover_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
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.You review
Open Approvals in the sidebar. The plan stays valid for 30 minutes.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.
| Procedure | What it does |
|---|---|
daily_review | Read-only health report: needs action / watch / OK |
failover_drill | Rehearses a failover without changing anything |
switchover_procedure | Planned primary switch with a maintenance window |
upgrade_procedure | Rolling update, with a backup first if none is recent |
pitr_procedure | Point-in-time restore, with an undo backup first |
replica_rebuild_procedure | Re-seed a replica from the primary |
galera_recovery_procedure | Recover 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.
| Alarm | Plan |
|---|---|
| Replication lag or replication stopped | Repair 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 lag | Log cleanup: purge old MySQL binary logs, keeping the last 72 hours (other engines get advice only) |
| Backup failed | Retry the backup |
| Galera quorum lost, split brain, node down | Rejoin the node, or run Galera recovery if quorum is gone |
| Too many connections | Connection 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.