# Ops tools (sa-doctor / sa-cli / sa-mcp) :id=top

------

> _Doc Ver:_ 1.1  
_App Ver:_ 2.6.6.53  
_Date:_ 09/10/2026

------

SA1 field ops trio. They ship in the package `bin/` directory. They are **not** daemons and **not** SA2 `sa_doctor` / `sa_tui` / `sa_mcp` / `sax`. Remote use is HTTP only (80 / 8080 / 81). **Do not** open TCP 7090 from a laptop (the command port is loopback-only).

Stack diagram: [Architecture](architecture.md). Same pass criteria as [Start, check, upgrade](operate.md): exactly one `sa-di` and one `sa-web`, no SA2 processes, non-empty `*IDN?`, `/login` reachable.

Each program’s **`--help` and dedicated Handbook page must be complete** (flags, commands, tools, exit codes, JSON, examples — nothing omitted):

| Program | Own help | Page |
|---------|----------|------|
| `sa-doctor` | `sa-doctor --help` | [sa-doctor](sa-doctor.md) |
| `sa-cli` | `sa-cli --help`, `sa-cli help <cmd>` | [sa-cli](sa-cli.md) |
| `sa-mcp` | `sa-mcp --help` (exits immediately; do not put in mcp.json args) | [sa-mcp](sa-mcp.md) |

HTTP JSON: [API §8](api.md). Binary `--help` is Chinese; English pages match it.

------

## 1. sa-doctor (read-only checkup) :id=doctor

Full page: [sa-doctor](sa-doctor.md).

```bash
sa-doctor --help
sa-doctor
sa-doctor --json
sa-doctor --url http://192.168.3.6 --user admin --password "$SA1_PASSWORD"
```

Exit codes: `0` pass, `1` fail, `2` warn (for example `*VER?` still lags `version.json` — `systemctl restart sa-di`), `3` usage. Without a password, remote checks are public only. `--json` is the slim checks report; full health JSON is `sa-cli health`.

------

## 2. sa-cli (small CLI, not a TUI) :id=cli

Full page: [sa-cli](sa-cli.md).

```bash
sa-cli --help
sa-cli help reload
export SA1_URL=http://127.0.0.1 SA1_USER=admin SA1_PASSWORD=…
sa-cli info
sa-cli health
sa-cli me
sa-cli sensors
sa-cli frq
sa-cli frq --demod
sa-cli save
sa-cli scpi '*IDN?'
sa-cli scpi ':DATA:PVJ?'
sa-cli reload --yes
sa-cli time 1710000000 --yes
sa-cli upgrade --yes
```

Writes need `--write` (`scpi`) or `--yes` (reload / time / upgrade). Upgrade starts `sa1-upgrader` and does not reboot by default. Flags may appear before or after the command.

------

## 3. sa-mcp (stdio MCP) :id=mcp

Full page: [sa-mcp](sa-mcp.md). Separate process — **not** inside sa-web, no listen port. No args waits on stdin (normal). Do not add `--help` to `args`.

Tools (all of them): `sa1_info` `sa1_health` `sa1_me` `sa1_scpi` `sa1_sensors` `sa1_frq` `sa1_save` `sa1_reload` `sa1_set_time` `sa1_upgrade`. Destructive calls need `confirm: true`. RBAC stays on sa-web.

```json
{
  "mcpServers": {
    "sa1": {
      "command": "/var/sa/bin/sa-mcp",
      "args": ["--url", "http://127.0.0.1"],
      "env": {
        "SA1_USER": "admin",
        "SA1_PASSWORD": "temppwd"
      }
    }
  }
}
```

------

## 4. HTTP ops surface (sa-web) :id=api

Field-level JSON: [API §8](api.md).

| Method | Path | Who | What |
|--------|------|-----|------|
| GET | `/api/info` | public | app name, IDN, dotted version |
| GET | `/api/me` | signed in | role and `can_operate` |
| GET | `/api/ops/health` | signed in | processes, mutex, 7090, disk, init, version match |
| POST | `/api/ops/action` | operator + `confirm:true` | `op`: `reload` / `time` / `upgrade` |
| POST | `/api/auth/login` | JSON | returns `token`; `Authorization: Bearer` works |

Do not embed MCP or an LLM in sa-web. Do not open 7090 on the LAN.

Precise wavelength: `sa-cli scpi ':DATA:PVJ?'` or MCP `sa1_scpi` `:DATA:PVJ?`. Writes (`:SYS:RELOAD` / `sa1_reload`) need confirm. Do not use `:DATA:PV?`. [Precise wavelength](precise_wl.md) “Command line”.

------

## 5. SA2 :id=mutex

SA1 and SA2 are mutually exclusive (UDP **8190** and 7090 / 7094 / 80 / 8080 / 81). `sa-doctor` fails if it sees `sa_daq` / `sa_daq_c` / `sa_web` / `sa_broker` / `sa_run` / `sa_control`. Do not point SA2 `sa_doctor` at SA1. Install/upgrade mutex is still [cspkg](cspkg.md).

------

### [Top](#top)
