CLI & MCP
Learn what the jazz-tools command line does, and how agents use your app's data through its MCP server.jazz-tools is the command line that comes with Jazz. Run it with npx jazz-tools <command>:
| Command | What it does |
|---|---|
generate | Loads schema.ts and migrations/, and writes jazz.app.json, jazz.permissions.json and jazz.generated.ts (see Defining Tables). With --check it writes nothing and fails when any of them is missing or stale, for CI. An app whose Cargo.toml (beside schema.ts) is a crate depending on jazz-app-support gets src/jazz_app.rs instead of, or besides, jazz.generated.ts; --lang ts / --lang rust chooses explicitly |
migrations create --name <name> | Records a schema change: snapshots the previous version and writes a migration into migrations/ for you to review (see Migrations) |
migrations graph <appId> | Draws the graph of schema versions and migrations your server knows |
schema compile | Prints the compiled schema jazz.generated.ts embeds, as JSON |
inspect <command> | Reads and changes your app's data through its backend, as the Inspector does |
inspect mcp | Serves the same operations as an MCP server, for coding agents |
The commands look for schema.ts in the current directory, then in ./src and ./src/lib.
Pass --schema-dir <path> to point them elsewhere.
Projects in other languages, such as a Rust backend client, generate their bindings with
npx jazz-tools generate too, from a schema.ts beside their own manifest (Cargo.toml, go.mod,
Package.swift, build.gradle.kts); no package.json is needed. schema.ts is the only source:
jazz.app.json and jazz.permissions.json are generated, so don't edit them. In an app with
jazz.app.json but no schema.ts (an alpha.65 Rust, Go, Swift or Kotlin app), generate and
migrations create refuse: write schema.ts from the JSON files as
Upgrading from alpha.65 describes,
keeping the schema hashes and bundle id, then run npx jazz-tools generate.
The standalone jazz-tools binary can't read TypeScript, so it writes nothing: its generate and
migrations create refuse and point to npx jazz-tools …. Its generate --check still works: it
checks the bindings, and the $generated checksum of the committed JSON files, against those files.
Whether the JSON is up to date with schema.ts only npx jazz-tools generate --check can tell,
since it runs the TypeScript.
npx jazz-tools --help and npx jazz-tools inspect --help list every option.
jazz-tools inspect
inspect talks to your app's backend, through the same API as the Inspector page, so it sees
exactly what your inspect hook allows. See Who may inspect.
Every command prints one JSON document; a failure prints { "error": <code>, "message": … } and
exits with 1, so agents can use it directly.
Name the app with --app <url>: its URL, or the URL Jazz is served at if you changed basePath.
Without --app it uses $JAZZ_APP_URL, else http://localhost:3000, and assumes Jazz under /jazz.
Signing in
In local development (NODE_ENV=development, the CLI on the same machine) no sign-in is needed.
Elsewhere, ask a person for a token:
Terminalnpx jazz-tools inspect login --app https://my-app.com
This prints a line with an approval URL and opens it in the browser. A person whom your inspect
hook lets in approves it there, and the browser hands the token to the waiting command, which keeps
it in ~/.config/jazz/inspect-tokens.json, per app URL. The token is read-only, unless you ask for
more:
| Option | Default | What it does |
|---|---|---|
--write | read-only | Ask to write too |
--ttl <duration> | 1h | How long the token lasts: at least a minute, at most the app's maxTokenTtlSeconds (a day by default) |
--tables a,b | every table | Limit the token to these tables |
--label <text> | jazz-tools inspect | Shown to the person who approves |
--no-browser | Only print the URL |
When the browser runs on another machine, the approval page shows the token instead: store it with
npx jazz-tools inspect login --token <token>. A JAZZ_INSPECT_TOKEN environment variable wins over
a stored token. logout forgets the app's token. Without a token, commands fail with
unauthorized and say to run login.
whoami shows what the backend says about you:
byandvia: who you are, and how you got in (hook,tokenordev);write,tablesandexpiresAt: what a token allows, and until when;label: a token's label, what was asked for;maxTokenTtlSeconds: the longest token this app issues;appId: the app's id, from its store;clientAppId: the id browsers use in their sync URLs (/jazz/apps/<clientAppId>/…). It's derived from the URL they sync with, and the backend maps it toappId, so the two can differ;inspectorUrl: where the Inspector page is.
The CLI sends a token over plain http:// only to this machine (localhost or a loopback address);
anywhere else needs https://.
Reading and writing
| Command | What it does |
|---|---|
schema | Tables, columns, history tables and permissions |
query '<json>' | Runs a query, e.g. '{"table":"todos","where":{"done":false},"limit":20}' |
get <table> <id> [--column <c> [--from <n> --to <n>]] | One row, with who created and last changed it; with --column, one value or part of it |
history <table> <id> | Every version of a row, with who wrote each |
insert <table> '<values>' [--id <id>] | Inserts a row |
update <table> <id> '<values>' | Changes a row's columns |
delete <table> <id> | Deletes a row |
explain '<query json>' --as <user> | Which read policy allowed or denied each row for that user |
sessions | Sync sessions connected to the backend instance that answers |
link ['<query json>'] [--table <t>] [--row <id>] | An Inspector URL that opens on exactly this, with no credential in it |
Writes need a token that allows them, and change real data.
Large values
A value whose JSON would be over 32 KB is summarized in rows, so the row is still listed:
{ "$large": { "kind": "bytes" | "text" | "json", "size": …, "preview": "…" } }. size counts
bytes, UTF-16 units or JSON characters, and preview is the first 200 characters (of the base64,
for bytes). Fetch the value with
get <table> <id> --column <column>, which answers { value, size }. For a bytes or text column,
add --from and --to (exclusive, required with --from) to read only that part from the store;
the answer is { value, from, to }. A part is at most 512 KB of bytes or 256K characters, and a
value larger than one answer is refused with "ask for it in parts with from and to". A range past
the end is refused too: the row's $large.size says where the end is.
Queries
query, explain, link and the MCP tools take a query as JSON:
| Key | What it does |
|---|---|
table | A table, or history.<table> for its rows' versions |
where | Column → value (equals), or column → { <operator>: <operand> }; several columns must all match |
select | Columns to answer with: every column by default ("*"), plus $createdBy, $createdAt, $updatedBy, $updatedAt |
orderBy | Sort keys, first one first: [["title", "asc"], ["$createdAt", "desc"]] |
limit | Rows to answer with: 100 by default, at most 1000. The answer says truncated when more matched |
offset | Rows to skip, for paging |
The operators are eq, ne, gt, gte, lt, lte, contains, in and notIn (with an
array), and isNull (with a boolean); which ones apply depends on the column's type. Values are
JSON: timestamps as ISO strings, 64-bit integers as strings, and bytes as { "$bytes": "<base64>" }.
Any other key is refused. A token can't filter or sort by a column that is redacted for agents.
Add --as <user> (your backend's user ID) to query, get, insert, update, delete,
explain and link to run under that user's permissions, seeing and writing what they could.
Without it, commands use the backend's authority and see every row. If your policies read
session.claims, pass the user's claims too with --claims '{"role":"manager"}' (a JSON object;
only with --as). Without them, policies see no claims, and answers carry a warning when that
may matter.
explain needs --as. Its answer lists the arms of the table's read policy (clauses, numbered
from 0, each with its text, such as owner = session.user) and, for each row, whether it's
allowed and by which clauses. A token limited to some tables gets neither the clauses' text nor by; for a table with redacted
columns, by is left out. A table with branches, and a history.<table> query, can't be explained yet.
The MCP server
jazz-tools inspect mcp serves the same operations as MCP tools over stdio. Add it to your agent,
for example to Claude Code:
Terminalclaude mcp add jazz -- npx jazz-tools inspect mcp --app https://my-app.com
| Tool | Arguments | What it does |
|---|---|---|
whoami | Who the backend says the agent is, what it may do, the Inspector URL | |
request_access | write, ttlSeconds, tables, reason | Asks a person to approve a token; returns the URL to give them |
schema | Tables, columns, history tables and permissions | |
query | query, as, claims | Runs a query |
get | table, id, as, claims, column, from, to | One row, or one value (or part of it) |
history | table, id | Every version of a row |
write | ops, as, claims | Inserts, updates and deletes rows in one transaction |
explain | query, as, claims | Which read policy allowed or denied each row |
sessions | Connected sync sessions | |
inspector_link | query, table, row, as, claims | An Inspector URL to show a person what the agent means |
write takes ops, 1 to 1000 writes applied in one transaction, each one of:
{ "kind": "insert", "table": "todos", "values": { … }, "id": "…" }(idis optional);{ "kind": "update", "table": "todos", "id": "…", "values": { … } };{ "kind": "delete", "table": "todos", "id": "…" }.
request_access's ttlSeconds follows the same limits as login --ttl: at least a minute, at most
maxTokenTtlSeconds.
In MCP tools, as is a user ID ("alice") or { "userId": "alice", "claims": { … } }. Claims can
also go in claims next to a plain as, but not in both places; any other shape is refused.
An agent starts with whoami. If that fails with unauthorized, it calls request_access and gives
the URL to a person. Once they approve in their browser, the token goes to the MCP server, which
keeps it like login does, and the agent calls whoami again. The server shares the token store
with the CLI, so a token approved for one works for the other. Query answers carry an
inspectorUrl the agent can link to show you exactly those rows.
Audit
Every call through the CLI, the MCP server or the Inspector page is audited, allowed or refused. By default your backend logs one line per call, for example:
jazz inspect: alice@example.com (token "fix the import") query todos as user_123 20 row(s)
It names who called, how they got in with a token's label, the operation and table, the user it ran
as, and how many rows it touched or why it was refused. Pass inspector: { audit } to createJazz
to send these events to your own log instead (see the Inspector).