CLI¶
sluice serve and sluice mcp start a server. The other commands run once and exit.
Every command accepts --help. A bool flag takes no value. The binary also has the standard help and completion commands.
--config reads only the file you name. A missing file is not an error: the defaults apply.
Exit codes¶
| Code | Command | Meaning |
|---|---|---|
| 0 | all | Success. |
| 1 | all | Wrong flags, a file that cannot be read, or a failed start. |
| 1 | datasource check | A policy file is not valid, or the name is unknown. |
| 2 | serve | A listener failed, for example the port is in use. |
| 2 | datasource check | The directory holds no DataSource object. |
| 3 | config validate, policy validate, policy explain, synth build | A policy or the server config is not valid. |
| 3 | policy test | A policy file is not valid or does not compile, a case failed, or no case ran. |
| 1 | audit verify | The chain is keyed and --key-ref is missing. |
| 1 | synth build, synth report | The name is unknown or not a synthetic data source, or there is no report. |
| 4 | synth build | The build failed: a check such as size or strictTags, or an error while reading the source. |
| 4 | audit verify | The hash chain is broken, a line is not JSON, the anchor or the key differs, or the directory has no record. |
apikey hash¶
Compute the hash of an API key.
sluice apikey hash [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--id | string | public key identifier | |
--material | string | key material presented by the client | |
--pepper | string | server pepper, raw value or secret:// URI |
All three flags are required. See API keys.
audit verify¶
Validate the audit-log hash chain under <audit-dir>.
sluice audit verify <audit-dir> [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--anchor | string | expected prior_hash of the first record: the hex SHA-256 of the genesis | |
--json | bool | print the report as JSON | |
--key-ref | string | secret reference of the chain key (audit.chainKeyRef) |
See Audit log.
budget show¶
Show a subject's budget usage for a day (default today, UTC).
sluice budget show <subject> [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--day | string | UTC day (YYYY-MM-DD); default today | |
--json | bool | print JSON | |
--state-dir | string | ./state | budget state directory |
The command only reads budget.db in the state directory. A missing file is an error. A running server writes the numbers of today every budget.flushInterval.
config validate¶
Validate the server config and the policy directory.
sluice config validate <policy-dir> [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--config | string | path to the server config (optional) | |
--strict | bool | reject unknown fields in policies and unknown keys in the server config |
The policy directory is optional. sluice serve runs the same checks at start.
datasource check¶
Validate configured data sources.
sluice datasource check [name] [flags]
Short form: sluice ds check
| Flag | Type | Default | Meaning |
|---|---|---|---|
--dir | string | ./policies.d | directory containing DataSource objects |
--json | bool | print the report as JSON |
The command does not connect to the data sources.
mcp¶
Run the MCP server for AI agents (stdio by default).
sluice mcp [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--allow-anonymous | bool | run without a credential (queries default-denied unless a policy allows the anonymous subject) | |
--api-key | string | static API key to authenticate as (stdio) | |
--config | string | server config (SLUICE_* env also applies) | |
--jwt | string | static JWT bearer token to authenticate as (stdio) | |
--policies-dir | string | policy directory (overrides policies.directory) | |
--transport | string | stdio | transport: stdio or streamable_http (also http, streamable-http, streamablehttp) |
Without --jwt, the command reads the token from SLUICE_MCP_TOKEN. The command does not start when an ApprovalPolicy is loaded. See MCP tools.
policy explain¶
Explain the effective policy for a subject and target.
sluice policy explain [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--claims | strings | extra claims as key=value (comma-separated) | |
--email | string | email of the subject | |
--groups | strings | subject groups (comma-separated) | |
--issuer | string | issuer (iss claim) | |
--json | bool | print the result as JSON | |
--policies-dir | string | ./policies.d | directory containing policy files |
--sql | string | SQL statement to explain. The command does not run it | |
--table | string | target table as catalog.schema.table | |
--user | string | subject id (required) |
You need --user and at least one of --table and --sql. This call asks which policies apply when alice reads one table:
sluice policy explain --policies-dir policies.d \
--user alice --groups analysts --table shop.main.customers
subject : alice
resource: shop.main.customers
decision: allow
Kind Name Priority Effect
---- ---- -------- ------
SqlAccessPolicy allow-analysts 100 applied
RowFilterPolicy filter-tenant 80 applied
ColumnMaskPolicy mask-email 50 applied
row filters: shop.main.customers
column mask: shop.main.customers.email - null (via mask-email)
policy test¶
Run declarative policy test suites against <policy-dir>.
sluice policy test <policy-dir> [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--json | bool | print the report as JSON | |
--strict | bool | reject unknown YAML fields in policies | |
--tests | string | <policy-dir>/tests | suite file or directory |
See Testing policies.
policy validate¶
Validate every policy file under <policy-dir>.
sluice policy validate <policy-dir> [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--strict | bool | reject unknown YAML fields in policies |
A directory that does not exist counts as empty, and the command prints OK. A policy that does not compile gives exit status 3:
policy: snapshot invalid: QueryRewritePolicy/limit-rows: spec.rewrite.limit.max: must be in [1, 2147483647], got 0
1 policy compile error(s)
[exit status 3]
schema export¶
Export the JSON Schema of a policy kind.
sluice schema export [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--kind | string | policy kind to export, for example SqlAccessPolicy |
Without --kind the output is one schema with a oneOf over all kinds.
serve¶
Start the Sluice server.
sluice serve [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--config | string | path to the server config (defaults apply when omitted) | |
--policies-dir | string | override policies.directory from the server config |
Starts the REST API. The MCP server and the admin API start when the server config enables them. SIGINT and SIGTERM stop the server. SIGHUP reloads the policies. A binary built with -tags=pure_parser does not start.
synth build¶
Build a snapshot of a synthetic data source.
sluice synth build <name> [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--config | string | path to the server config (defaults apply when omitted) | |
--json | bool | print the report as JSON | |
--out | string | override synthetic.dir from the server config | |
--policies-dir | string | override policies.directory from the server config |
The command reads the source data. It does not use policies. It writes no audit record to the audit log. It prints the record as one JSON line on stderr and stores it in the report.
synth report¶
Print the report of a synthetic snapshot.
sluice synth report <name> [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--build | string | build id to show instead of the current build | |
--config | string | path to the server config (defaults apply when omitted) | |
--json | bool | print the report as JSON | |
--out | string | override synthetic.dir from the server config |
Without --build the command prints the report of the current build. --json prints the report file.
version¶
Print the build version.
sluice version [flags]
| Flag | Type | Default | Meaning |
|---|---|---|---|
--json | bool | print the version data as JSON |