@struct-ai/cli
v6.0.0
Published
Struct AI CLI
Readme
Struct CLI
Set up Struct from your terminal or coding agent: create or sign in to a workspace, instrument your application, verify telemetry, configure monitors and connect your stack.
Start with Set up with an agent or the Quickstart. Instrument with Struct covers SDK and OpenTelemetry configuration. The CLI reference groups commands by task.
Inspect build agent
Inspect must first be enabled for your workspace (inspect_not_enabled otherwise).
An admin can then configure it using its workspace subdomain and a write-capable API key:
struct build-agent keys set inspect
struct build-agent settings set --provider inspect --inspect-workspace acme
struct build-agent settings showThe key command accepts INSPECT_API_KEY, --stdin, or a hidden prompt; keys are never
printed. settings set --provider inspect also sends INSPECT_API_KEY when it is set.
struct build-agent keys remove inspect removes the key; removing the selected provider's
credentials switches Fix to Struct in the same write.
Install
Requires Node.js 18 or newer.
npm install -g @struct-ai/cliOr run it without installing:
npx @struct-ai/cli <command>The init flow requires CLI 2.5.0 or newer, telemetry queries require CLI 5.0.0 or newer (telemetry span and log as raw select: ["*"] queries, CLI 6.0.0), and both need the corresponding server capabilities. Check npm view @struct-ai/cli version if the installed package lacks them; a source-code merge is not publication.
Commands
struct login
Signs you in and saves a login for one workspace. The CLI prints the sign-in link first
and then waits until you approve, like gh auth login:
- On your own computer it opens the link in your browser. After you approve, the browser returns to a temporary local address on this computer and the CLI finishes.
- Over SSH, on Linux without a display, or when no browser opens it shows a link and
a short code instead. Open the link on any device, check that the code matches, and
approve. Use
--deviceto choose this yourself.
Device login needs a Struct server that supports it. If yours does not, the CLI prints
the browser link instead (and --device fails): open it in a browser that can reach
this machine, because approving it returns to a temporary local address here.
| Option | What it does |
| --------------------- | -------------------------------------------------------------------- |
| --org <workspace> | The workspace to approve (name or id). Pick it on the approval page. |
| --device | Sign in with a code on any device. |
| --no-browser | Print the link without opening a browser. |
| --with-token | Save a token read from stdin instead of signing in. |
| --timeout <seconds> | How long to wait for approval (default 900, which is 15 minutes). |
| --admin | Also ask for the admin permission (workspace admin commands). |
Access tokens last one hour; after 90 days without a renewal you sign in again. If you
are already logged in to that workspace, the CLI asks whether to sign in again; without a
terminal it does not ask (exit 2): run struct logout first. A browser login that can
only read is the exception: struct login (or struct login --org <workspace>) replaces it without asking, also without a
terminal (the new login is saved before the old one is revoked). That replacement must be
for the same workspace: approving another one saves nothing (workspace_mismatch); use
struct login --org <workspace> to add another workspace.
--with-token does not replace a browser login: if the workspace already has one saved,
it exits 1 (oauth_login_exists) and changes nothing. Keep using that login for its
own tokens, or run struct logout --org <workspace> first to revoke it, then retry with an
independently issued token (logout also ends tokens issued to that login).
With --org, if you approve a different workspace the CLI saves nothing, revokes the
new login and exits 1; the browser page says which workspace to choose instead. The
approval page does not preselect the workspace yet, so choose it there.
--admin asks for one more permission, shown as its own line on the approval page:
managing the workspace's ingest keys, API keys and GitHub deploy webhook
(struct keys, struct github deploy-webhook) and its members: invitations, role changes
and removals (struct members invite|invites|set-role|remove). It covers only what lets
someone or something into Struct; everything else, including Fix agent secrets and other tools' keys,
works with an ordinary login. It works only while you are a workspace admin. Running struct login --admin on a login
without it signs in again and replaces that login.
No login, with or without --admin, can change the plan, buy credits, set up auto top-up
or read billing details. Do those in the Struct web app.
struct init (for agents)
Creates a Struct workspace without an account, for a person to claim. An AI agent can run it on its own:
struct init --name "Acme" --jsonThe CLI prints a claim link and a short code (with --json, only as a
{"status":"waiting_for_human","method":"claim",...} line on stdout, never on stderr) and waits. Give them to a
person: they open the link, sign in or create an account, and claim the workspace. They
become its admin, and the CLI is then logged in as them, with the admin permission, so
the agent can keep setting Struct up (for example struct connect github). When you run it
yourself at a terminal, the claim page opens in your browser (--no-browser to skip). A
code that expires before --timeout (default 900 seconds) is replaced by a new one.
- Until the claim, the temporary key can manage ingest/deployment keys, query telemetry and configure native monitors once activated. AI and outbound notifications stay off. There may be ten non-deleted monitors including disabled monitors; deletion frees a slot. While paused, configuration and firing history remain readable; queries and setup changes wait for claim.
--no-waitcreates the workspace and exits; runstruct initagain when a person is ready to claim it. It resumes the same workspace;--newcreates another.- On a computer that is already logged in to Struct, add
--newto create a workspace anyway. struct init --statuschecks once whether the workspace was claimed, and logs in if so.--email <address>lets only a person with that verified email claim it. Struct does not send an email.
struct whoami
Shows the user, workspace and role of the current login.
struct orgs list and struct orgs switch <workspace>
You can be logged in to several workspaces. Each login belongs to one workspace on one
Struct server and is approved separately. orgs list shows the workspaces you have a
login for (the current one is marked *). orgs switch selects one; if you have no
login for it yet, it starts struct login --org <workspace>.
struct logout
Revokes the current workspace's login on Struct, then removes it from this computer.
Your other workspaces and coding agents that signed in themselves stay signed in.
Logout also revokes old struct connect grants saved on this computer; use
struct mcp install to switch those agents to their own sign-in.
--org <workspace>logs out of another saved workspace;--alllogs out of every workspace on this server (it cannot be combined with--org). A workspace with no saved login, or a name that matches several, is a usage error (exit2).- If Struct cannot revoke the login (for example, it cannot be reached), the login is
still removed from this computer, but the command exits
1and says so. Disconnect the Struct CLI in Struct settings to end it. - A token you added with
--with-tokenis only removed from this computer; revoke it where you created it.
struct mcp install --client <claude|cursor|codex> and struct mcp url
Connects your coding agent to Struct's MCP server. The configuration contains only the server URL: your agent signs in to Struct itself the first time it connects, so no token is printed or stored in its settings.
| Client | What struct mcp install does |
| -------- | -------------------------------------------------------------------------------------------------------------------- |
| claude | Runs claude mcp add --transport http --scope user struct <url> (Claude Code, for all your projects). |
| codex | Adds a [mcp_servers.struct] table to ~/.codex/config.toml (or $CODEX_HOME/config.toml), keeping your settings. |
| cursor | Adds a struct entry to ~/.cursor/mcp.json, keeping your other servers. |
If claude is not installed, the CLI prints the command to run instead. Afterwards, sign
in to Struct from your agent: in Claude Code, run /mcp; for Codex, run
codex mcp login struct (the --json result names this nextStep). Installing never
waits for a browser. Running the install again changes nothing when the entry is already
there, and a config file the CLI cannot read safely (for example, invalid TOML or JSON)
is left untouched. Add --print to
only print the command (or, for Cursor, an install link, and for Codex, the configuration
to add) without changing anything. struct mcp url prints the URL for any other MCP
client.
struct connect without a provider (or with --agent) from earlier versions still works
but is deprecated: it prints the same URL-only setup and the new command to use.
struct connect <provider>
Connects an observability tool with its API key: Datadog, Grafana, Loki, Prometheus,
Axiom, Better Stack, Mezmo, SumoLogic and Render, AWS CloudWatch with an IAM role, Azure
Monitor with a service principal, Google Cloud with a service account key, a Kubernetes
cluster with a ServiceAccount token or kubeconfig, or a PostgreSQL, PlanetScale or BigQuery
database. Struct checks the key, role, principal, cluster access or database with the tool,
saves it, then tests the saved connection. --test-only runs the same checks and saves nothing.
DATADOG_API_KEY=… DATADOG_APP_KEY=… struct connect datadog --site us5 --name "Prod Datadog"
GRAFANA_TOKEN=… struct connect grafana --url https://acme.grafana.net --org-id 1
LOKI_TOKEN=… struct connect loki --deployment grafana-cloud --url https://logs.grafana.net --instance-id 123
PROMETHEUS_PASSWORD=… struct connect prometheus --url https://prom.example --auth basic --username reader
BETTERSTACK_TOKEN=… BETTERSTACK_SQL_PASSWORD=… struct connect betterstack --sql-host eu-nbg-2-connect.betterstackdata.com --sql-user reader- Each tool's flags and environment variables are listed by
struct connections catalog <provider>. - Secrets come from their environment variable, from a variable you name with
--<secret-flag>-env NAME(for example--connection-string-env PG_URL), from stdin (--api-key-stdinand the like, or--stdinfor the only one missing) or from a hidden prompt in a terminal. A secret given as a flag works, with a warning that it may be saved in your shell history. Secrets are never printed. - Without a terminal nothing is asked: a missing value exits
2(missing_fields) and names its flag and variable. --nameand--instructions(when agents should use it) are optional; by default the connection is named after the tool.- Connecting the same account again updates its connection instead of adding another
(
"created": false). URL-based accounts also include their organization, tenant or authentication identity; key-based accounts include their site, region or organization. - The result's
connection.healthsays whether the access Struct needs is there; the exit code is0either way. Refusals keep a stablecode, for examplecredentials_rejected,invalid_fields,unsafe_provider_urlorconnections_restricted_to_admins.
AWS. Struct assumes an IAM role in your account, trusted with an External ID Struct makes for your workspace. Print the setup commands, run them in AWS CloudShell (the CLI never runs anything in your AWS account), then connect with the command they end with:
struct connect aws --print-commands [--region eu-west-1]
struct connect aws --role-arn arn:aws:iam::123456789012:role/StructCloudWatchRole --region eu-west-1 --external-id struct-…--region defaults to AWS_REGION when it is set, as for the connect.
New connections require an External ID Struct made for your workspace (external_id_not_issued
otherwise), and each connection needs its own. Reconnecting the same role may keep its saved
External ID. A new role that AWS still refuses is tried again for up to 90 seconds
(permissions_propagating after that).
Azure. Struct reads with an app registration (service principal) and its client secret.
Print the role assignments it needs, run them with the Azure CLI (the CLI never runs anything in
your Azure account), then connect. Prefer AZURE_CLIENT_SECRET or --stdin for the secret;
--client-secret also works, with a warning that it may be saved in your shell history:
struct connect azure --print-commands --client-id <client-id> --subscription-id <subscription-id> [--resource-group rg-alerts]
AZURE_CLIENT_SECRET=… struct connect azure --tenant-id <tenant-id> --client-id <client-id> \
--subscription-id <subscription-id> --region eastus --workspace-id <workspace-id>Struct runs one Log Analytics query with it before saving. A query Azure still denies right
after the roles were assigned is tried again for up to 5 minutes (permissions_propagating
after that). Connecting the same app registration and workspace again replaces its secret
("created": false).
Google Cloud. Struct reads your project with a service account key. Print the setup
commands for the project (they create the struct-agent service account, enable the APIs
Struct calls, grant its roles and write its key to struct-agent-key.json; the CLI never
runs them), run them, then connect with the key file:
struct connect gcp --project my-project --print-commands
struct connect gcp --project my-project --key-file struct-agent-key.json --name "Prod GCP"--project defaults to GOOGLE_CLOUD_PROJECT. The key also comes from
GCP_SERVICE_ACCOUNT_KEY (the file's contents), --stdin, or last the file
GOOGLE_APPLICATION_CREDENTIALS names; the CLI sends the file's contents, never its path. A
file that is not a service account key is refused (invalid_service_account_key) without
repeating it. Roles Google Cloud has not applied yet are tried again for up to 90 seconds.
When the existing connection has its own unshared stored key, the same service account and project
update it in place. Older connections without their own key create another connection on reconnect.
Replace a key later with struct connections rotate <id> --key-file new.json.
Kubernetes. Print the commands that create a read-only ServiceAccount, its ClusterRole and a
token (run them with kubectl; the CLI never runs anything in your cluster), then connect with the
token in K8S_TOKEN (or piped with --stdin), never as a flag:
struct connect kubernetes --print-commands [--namespace struct]
K8S_TOKEN=… struct connect kubernetes --api-server https://kube.example.com:6443 --ca-cert-file ca.pem --namespace struct
struct connect kubernetes --kubeconfig ./kubeconfig [--context prod]Struct lists namespaces and checks that the credentials can read pods, pod logs and events
before it saves anything (missing_access names what is missing). --ca-cert-file and
--kubeconfig read files; only their contents are sent. Only the chosen kubeconfig context is
stored, and kubeconfigs with exec plugins, auth-provider stanzas or
insecure-skip-tls-verify: true are refused: Struct always verifies the API server's certificate
(certificate_not_trusted asks for the CA).
Databases. Struct connects to the database with the values first and saves nothing if that
fails (exit 1 with credentials_rejected, missing_access or connection_failed). Prefer
environment variables for passwords; a secret given as a flag works with a warning. A whole
PostgreSQL connection string comes from the variable you name with --connection-string-env:
PGPASSWORD=… struct connect postgres --host db.example.com --database app --user struct_reader \
--sslmode verify-full --name "Orders DB" --instructions "Orders and refunds"
struct connect postgres --connection-string-env PG_URL
PLANETSCALE_PASSWORD=… struct connect planetscale --engine postgres --host aws.connect.psdb.cloud \
--database app --user reader
struct connect bigquery --project my-project --key-file sa.json --dataset analyticsPostgreSQL takes
--port(default5432) and--sslmode(defaultrequire); Struct builds the connection string from the fields. A connection string namingsslrootcert(exceptsslrootcert=system),sslcert,sslkey,sslcrl,sslcrldirorpassfileis refused.BigQuery needs the Pro plan (
plan_required). Its key also comes fromGOOGLE_APPLICATION_CREDENTIALS(the file it names) orBIGQUERY_CREDENTIALS_JSON(the file's contents).Each connect adds a connection, so the same database can be connected twice with different instructions.
Snowflake: Struct makes the key pair and keeps its private key. First print the setup SQL (it holds only the public key) and the key pair id, run the SQL in Snowsight as an admin, then connect with the id within 24 hours:
struct connect snowflake --print-commands --account myorg-acct [--user STRUCT_READER] [--warehouse COMPUTE_WH] struct connect snowflake --account myorg-acct --user 'STRUCT_READER' --key-pair sfk_… --name "Warehouse"To replace the key,
struct connections rotate <id> --print-commandsprints theALTER USERstatement that adds a new key next to the one in use; run it, thenstruct connections rotate <id> --key-pair sfk_…. Struct tests the new key, swaps it in and says whichUNSETremoves the old one. A key pair saves one connection only.SSH tunnel (PostgreSQL, PlanetScale Postgres): add
--ssh-host <bastion> --ssh-user <user>with the password inSSH_PASSWORD, or reach a bastion behind an EC2 Instance Connect Endpoint with--ssh-endpoint-id,--ssh-instance-idand--ssh-aws-connection <aws connection id>(--ssh-auth ec2_instance_connectlogs in with a key Struct pushes instead of a password). Struct trusts the bastion only with--trust-host-key SHA256:…. Without it, or when the bastion shows another key, it stops before sending any credential to the bastion and exits3(ssh_host_key_neededorssh_host_key_changed); the error'ssshHostKeyFingerprintis the key it read. See the fingerprint first, and check it with the bastion's owner:struct connections ssh-host-key --ssh-host bastion.example.com [--ssh-port 22]
Connecting needs permission to change connections (an admin, or any member while connections are not restricted to admins).
struct automonitors
Sets up Auto Monitors. Changing settings needs the configure permission level (the
permission field of struct whoami --json shows yours); every member can read them.
| Command | What it does |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| settings get | Shows whether Auto Monitors is on, how deploys are reported, the alert channels and the providers. |
| settings set --alert-channel <channel> | Sends alerts to a Slack channel (id, #name or link) and makes it the default channel. |
| settings set --environment <name> | Sets the deployment environment treated as production. |
| channels list | Lists the alert channels. |
| channels add <channel> [--default] [--description <text>] | Sends alerts to another channel. Struct's bot joins public channels itself; invite it to private ones first. |
| channels remove <channel> | Stops alerts to a channel. A channel outside the alert list changes nothing (exit 0); an unresolvable name or link fails. |
| enable | Turns Auto Monitors on. Safe to repeat. The result lists anything still missing. |
| disable --yes | Turns Auto Monitors off. Without a terminal, or with --json, --yes is required. |
| providers enable\|disable <provider> | Opts a connected provider in or out. Other providers' settings stay as they are. |
| settings set aws --log-groups <g1,g2> | Sets the CloudWatch access-log groups AWS baselines read from (an empty value clears them). |
| settings set azure --resource-group <name> | Sets the resource group for Struct's Azure alert rules (an empty value clears it). |
| settings set azure --action-group-id <id> | Sets the action group (ARM ID) wired to your alert channel; the routing check needs it. |
| settings set azure --app-insights-resource-id <id> | Advanced: scopes rules to an Application Insights component (ARM ID). |
| settings set gcp --log-filter '<filter>' | Sets a Cloud Logging filter fragment ANDed into the Google Cloud telemetry overview log read (an empty value clears it); condition probes and charts do not apply it yet. |
| check <provider> | Checks the provider's access now: connection, configuration, reads and writes, with a grant command for what is missing. |
struct deploys
Lists recorded deployments and configures how deploys reach Auto Monitors.
| Command | What it does |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| list [--repo owner/name] [--env name] [--status status] [--since time] [--until time] [--limit n] [--page n] | Reads recorded deployments with a workspace read login. Defaults to the last seven days and 25 per page. |
| setup github [--environment <name>] | Uses deployment events from the Struct GitHub App. |
| setup workflow [--workflow <path>] [--environment <name>] | Counts successful runs of a GitHub Actions workflow as deploys. Defaults to the saved workflow, or Struct's recommendation. Struct creates the repository webhook when the GitHub App may. |
| setup webhook [--environment <name>] | You report deploys with POST /api/deployments and a deploy key that an org admin creates. |
| show | Shows the deploy signal and whether Struct is ready for it, or what is missing. |
| workflows list | Lists the default repository's workflows, with Struct's recommendation and the saved one (selected). github_unavailable when GitHub cannot be read, github_not_connected without it. |
| environments list [--query <text>] [--limit <n>] | Lists GitHub environment names. The limit defaults to 20 and accepts 1–50. |
The CLI never shows the webhook URL or signing secret. If Struct cannot create the webhook itself, an org admin finishes the setup in the Struct web app, where they are shown.
struct connections catalog|list|show|test
struct connections catalog [<provider>]lists what you can connect. With a provider (for exampledatadogorpostgres) it shows how to connect it: the fields, the environment variable and flag for each, whether it needs a browser, the access it needs in that tool and the commands that grant it.struct connections list [--type <type>]lists your workspace's connections with their health:ok;needs_reauth(Struct has no usable stored credential: it was removed, or an OAuth refresh was refused; reconnect);missing_permissions(the credential works but lacks access);error(the last test failed, including the tool rejecting the key or password: check it; the detail gives the tool's reason); orunknown(not tested since the connection or its credential last changed).--typetakes a kind (oauth_app,observability,data,custom_mcp) or a provider.struct connections show <id>shows one connection's settings (for a database, its saved host, database and user, never the secret), health and missing access.--grant-commandprints only the command or steps that grant the missing access, for piping.struct connections update <id> [--name <name>] [--instructions <text>] [--role-arn <arn>] [--region <region>] [--workspace-id <id>] [--namespace <name>] [--field <key=value>]changes a connection; changed AWS and Azure settings, a changed Kubernetes default namespace, and a database's settings that keep its password where it was (PostgreSQL--field sslmode=verify-full; BigQuery--field dataset_id=…or--field location=…) are tested before they are saved. Anything else about a database is a rotation.struct connections rotate <id>replaces a connection's stored secret, tested with the provider before it is saved; the connection keeps its id, name, Auto Monitors settings and selected sources. Azure: the new client secret (preferAZURE_CLIENT_SECRETor--stdin;--field client_secret=…works with a warning), optionally with--workspace-id <id>or--region <region>. Google Cloud:--key-file new.json, tested with the saved project; delete the old key in Google Cloud after. Kubernetes: a new token (K8S_TOKENor--stdin) and/or CA certificate (--ca-cert-file), or a new kubeconfig (--kubeconfig <file> [--context <name>]) for the same API server (cluster_changedotherwise). A database: its new password (PGPASSWORD,PLANETSCALE_PASSWORD,SSH_PASSWORD; each optional, at least one) or key file (BigQuery--key-file), with any setting that moves it. A new host, user or bastion (and for PostgreSQL a new database) needs the password again (secret_required); a new bastion also needs--trust-host-key;--ssh-via noneremoves the SSH tunnel (also with--engine vitess, which takes no tunnel). A secret the changed connection would not use is refused (invalid_fields), and switching to a connection string needs the whole string with--connection-method connection_string --connection-string-env PG_URL:PGPASSWORD=… struct connections rotate <id> [--host db2.example.com] PGPASSWORD=… SSH_PASSWORD=… struct connections rotate <id> --ssh-host new-bastion.example.com --trust-host-key SHA256:…struct connections remove <id> --yesremoves an AWS, Azure, Google Cloud, Kubernetes, PostgreSQL, PlanetScale, BigQuery or custom MCP connection. An AWS one is refused (connection_in_use) while an SSH tunnel uses its role. For Azure, Google Cloud and Kubernetes the stored credential stays for now (the message says so): delete the client secret, key or ServiceAccount token Secret in the provider to revoke it. A database's stored password or key is deleted with it, unless another connection uses it; revoke the database user too if Struct no longer needs it.struct connections ssh-host-key --ssh-host <host> [--ssh-port <port>](or--ssh-endpoint-id,--ssh-instance-idand--ssh-aws-connection <id>, optionally--ssh-region, for a bastion behind an EC2 Instance Connect Endpoint) reads an SSH bastion's host key without logging in and prints its fingerprint, to check before--trust-host-key.struct connections grant-command <id>prints the command that grants what the connection needs (for what the last check found missing, or the full upgrade).struct connections test <id>tests a saved connection with its stored credential and records the result as its health. Without an id it tests every connection that can be tested.--provider <provider>tests new values without saving anything; it reads each field from the environment variable the catalog names, from--field key=value, or from a file with--field-file key=path:DATADOG_API_KEY=… DATADOG_APP_KEY=… struct connections test --provider datadog --json K8S_TOKEN=… struct connections test --provider kubernetes --field api_server_url=https://kube.example.com --field-file ca_cert_pem=ca.pemThe result's
okandhealthsay whether the test passed; the exit code is0either way. Secrets passed with--fieldmay be saved in your shell history, so the CLI warns about them; they are never printed.
Testing new values needs permission to change connections (an admin, or any member while connections are not restricted to admins).
struct connections metric-polling status|enable|disable|budget|scope
Struct can pull infrastructure metrics from your AWS, Azure and Google Cloud connections itself, with nothing installed: it reads a listed set of metrics with the connection's read-only credentials and stores them as your workspace's own metrics. It runs when observability is on for the workspace and the connection's polling is on (it is on unless you turn it off).
Your cloud provider bills these reads to your own cloud account, not to Struct.
struct connections metric-polling statussays whether polling is running and, for each cloud connection, whether it is on, what today's reads have cost in the cloud's own billing unit, and the daily budget. For each scope (an AWS account and region, an Azure subscription or a Google Cloud project) it shows how far Struct has read, its last successful pull, the last error, and any reads the daily budget left out. A scope that two of your connections reach is read once, through one of them, and is listed under that one only.--metricslists the metrics that are pulled.struct connections metric-polling enable <connection-id>anddisable <connection-id>turn it on or off for one connection. Turning it off stops the reads at the next cycle; turning it on again starts from the present.struct connections metric-polling budget set <cloud> <daily-units>sets your workspace's own daily budget for one cloud (aws,azureorgcp), in that cloud's billing unit, from 1 to ten times Struct's default.budget reset <cloud>goes back to Struct's default. It counts from the next read. Lowered below what was already used today, nothing more is read on that cloud until 00:00 UTC, and nothing used is handed back.statusshows each budget as set or default, including one set for a cloud you have not connected yet.struct connections metric-polling scope disable <cloud> <scope-id> [region]turns one cloud scope off for the whole workspace, whichever connection reaches it: an AWS account and region (the region is required), an Azure subscription or a Google Cloud project. Its reads stop at the next cycle, and monitors no longer wait for it.scope enableturns it on again; it is read from the present, with nothing filled in for the time it was off.
Changing these settings needs a login that can make changes and permission to change connections.
struct scrape-endpoints presets|list|test|add|enable|disable|remove
Struct can also scrape a Prometheus metrics endpoint for you: a managed service's (Supabase,
Temporal Cloud, Redpanda Cloud, ClickHouse Cloud) or any public one. A scrape endpoint is not a
connection: agents do not query it, and it does not appear in struct connections list.
struct scrape-endpoints presets
STRUCT_SCRAPE_SECRET=sb_secret_… struct scrape-endpoints test supabase --param project_ref=abcd1234
STRUCT_SCRAPE_SECRET=sb_secret_… struct scrape-endpoints add supabase --param project_ref=abcd1234
struct scrape-endpoints add temporal_cloud --secret-env TEMPORAL_CLOUD_API_KEY
struct scrape-endpoints add generic --url https://metrics.example.com/metrics --name billing-api
struct scrape-endpoints listpresetslists the services whose URL and sign-in Struct already knows, and what each still needs:--param name=value,--url,--namefor a generic endpoint (the others are named after their service, such assupabase-abcd1234), and--usernamefor basic credentials whose user the service does not fix. A generic endpoint signs in with nothing unless you pass--auth basic(with--username) or--auth bearer. A--urlcarries no query string: the server refuses one (invalid_endpoint), because a stored URL is shown bylistand a token in it would be too. A credential goes in the sign-in.test [preset]scrapes once with the values you give and shows what came back: the first 20 metrics by the name they are stored under (all of the first 100 with--json). Nothing is saved. The result'soksays whether the scrape worked, meaning the endpoint answered and all of its answer can be stored; otherwiseerrorsays why. The exit code is0either way.add [preset]scrapes once and stores the endpoint only if that worked (otherwise exit1,scrape_failed).--no-teststores it unchecked;--disabledstores it switched off. With--jsonthe result is{"endpoint": …, "test": …}.listshows each endpoint, when it was last scraped, how many samples came back and its last error.enable <id>anddisable <id>turn one on or off.remove <id> --yesdeletes it and its stored credentials.
The secret (a basic-auth password or a bearer token) is never a flag value. It comes from
STRUCT_SCRAPE_SECRET, a variable you name (--secret-env NAME), a file (--secret-file <path>,
at most 1 MiB), stdin (--secret-stdin) or, in a terminal, a hidden prompt. Without a terminal a
missing secret is an error (exit 2, missing_secret); a file that can't be read or is too large
is file_unreadable or file_too_large (exit 2). Struct stores it encrypted and never returns
it, and the CLI never prints it. An endpoint's name becomes service.name on every series, and
up is 1 after a scrape that worked and 0 after one that failed; an endpoint's own up, if it
has one, is stored as exported_up. To change an endpoint's URL, name or secret, remove it and
add it again. A scrape that was missed cannot be read later.
presets and list only read. test, add, enable, disable and remove need a login that
can make changes and permission to change connections (an admin, or any member while
connections are not restricted to admins); test too, because Struct calls the URL with the
credentials you give.
struct connect github|slack|sentry|linear|jira|asana|notion
Connects an app that you approve in a browser. The CLI prints the link (and opens it when this machine has a browser), then waits. Open it in a browser signed in to Struct as the same user this CLI is logged in as: the link works once, in that one browser, for 10 minutes. Approve Struct on the app's page, and the terminal prints the result.
$ struct connect slack --json
{"status":"waiting_for_human","provider":"slack","url":"https://app.struct.ai/connect/session?token=...","expiresAt":"...","sessionId":"..."}
{"status":"connected","provider":"slack","connection":{"id":"...","provider":"slack","account":"Acme","accountId":"T0123"}}- An app that is already connected says so; GitHub still applies
--repoif supplied.--reauthreconnects it (for example to approve new permissions); a reconnect keeps the same organization, site or workspace. - When your login reaches several, choose one in the browser, or name it here:
--org(GitHub account or organization, Sentry organization),--site(Jira site name or URL) or--workspace(Asana). With several and no flag,--jsonprints a secondwaiting_for_humanline with"step":"choose"and the options. Cancelling the choice in the browser ends the command withcancelled. struct connect github --repo owner/namealso sets the default repository.--no-browseronly prints the link;--timeout <seconds>(default 600) limits the wait.- Linear, Jira and Asana are part of the Pro plan (
plan_requiredotherwise). - Connecting needs permission to change connections (an admin, or any member while connections are not restricted to admins). The CLI never sees the app's tokens.
struct notion pages|configure
Notion is in private preview and read-only. Check availability with
struct connections catalog notion. Connect with struct connect notion --no-browser
to print the approval link without opening a browser. The result includes
configurationRequired: authorization alone does not grant agents any page access.
A null value means authorization succeeded but the settings could not be checked.
struct connections list --type notion
struct notion pages <connection-id> --scope workspace
struct notion pages <connection-id> --scope workspace --query "Runbooks"
struct notion configure <connection-id> --root <page-id> --mode read
struct connections show <connection-id>
struct connections tools <connection-id>
struct connections test <connection-id>pages defaults to the connection's configured roots. --scope workspace explores
candidates for changing those roots; it does not grant access. Workspace browsing
also accepts --section workspace|shared|private|favorite|recent. Follow returned
browseCommand values (--at <location>) to expand pages, folders, databases or views,
and nextCommand for another batch, including empty batches. Navigation-only items
cannot be roots. Search and some provider lists are capped; output includes notices.
Page browsing and tool inspection require permission to configure connections.
configure --root replaces the entire root set; repeat it for each page or database.
Omitting it preserves roots. --mode read|write|read-write|none|custom sets optional
tool access. Notion has no supported writes: Write and None retain required tools only.
--allow <tool-id> and --deny <tool-id> are repeatable and enter Custom while
preserving choices for available tools and existing Custom overrides. A temporarily
unavailable tool cannot acquire a new override; when it recovers, Custom allows
it by default unless it already had an explicit denial. Custom allows new supported reads; required tools cannot
be disabled. Tool output shows saved selection, independently of connection readiness.
Roots and tools save together with revision checks. --expected-revision <n> also
checks the version you inspected; conflicts and uncertain saves are never retried.
Read settings again before another change. Disconnect with struct connections remove.
struct connect custom-mcp
Connects a remote HTTP MCP server your agents should use. Struct lists the server's tools
first and saves nothing when that fails. Only public http(s) URLs are accepted.
$ MCP_AUTH_VALUE=… struct connect custom-mcp --url https://mcp.acme.example/mcp --auth bearer --name "Acme docs"
$ MCP_AUTH_VALUE=… struct connect custom-mcp --url … --auth custom_header --auth-header-name X-Api-Key
$ struct connect custom-mcp --url https://mcp.acme.example/mcp --auth oauth --name "Acme docs"
$ struct connect custom-mcp --url … --auth oauth --test-only # authorizes, lists the tools, saves nothing--authisnone(the default),bearer,custom_headeroroauth. A token or header value comes fromMCP_AUTH_VALUE,--stdinor a hidden prompt, and is never printed.--auth oauthstarts the server's own sign-in: the CLI prints the link (and opens it when it can), then waits up to 10 minutes for you to finish the MCP server's sign-in in a browser. The CLI login that started it must poll and save it.--jsonprints awaiting_for_humanline first. A declined sign-in ends withoauth_failed; an expired one withoauth_session_expired; one not finished in 10 minutes withtimeout.Change it with the
connectionscommands:| Command | What it does | | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------- | |
struct connections update <id> --name … --instructions …| Renames it or changes its instructions (an OAuth server keeps its tokens). | |struct connections disable <id>/enable <id>| Agent runs stop using it, or use it again. Its settings and secret are kept. | |MCP_AUTH_VALUE=… struct connections rotate <id> [--url …]| A new token or header value, with a new URL,--author header name if needed; tested first. | |struct connections rotate <id> --auth none(or--url …) | Settings only, for a server without authentication: no secret is asked for. | |struct connections remove <id> --yes| Removes it and deletes its stored token, header value or OAuth tokens. |A rotation that leaves the server on
bearerorcustom_headerneeds the token or header value again, also with a new URL or header name: Struct never sends the saved one somewhere new. It comes fromMCP_AUTH_VALUE,--stdinor a hidden prompt in a terminal; without any of them the CLI sends nothing and exits2withmissing_fields.--auth none, or a new--urlfor a server without authentication, needs no secret.--field url=…and--field auth_type=…work as their flags do, also for a settings-only rotation (--fieldwins over the flag). An OAuth server can't be rotated: the CLI says so (rotate_not_supported) before it asks for anything. Remove it and connect it again with--auth oauth. If someone else changed the server after you started the rotation, nothing is saved (connection_changed): look at it again, then rotate again.
struct github, struct sentry and struct slack channels
| Command | What it does |
| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| struct github repos | Lists the repositories the Struct GitHub App can access; * marks the default. |
| struct github set-repo <owner/name> | Sets the default repository. It must be one the app can access (repository_not_found otherwise). |
| struct sentry orgs | Lists the organizations the connected Sentry user belongs to; * marks the one Struct reads. |
| struct sentry set-org <slug> | Chooses the organization Struct reads (organization_not_found if the user is not a member). |
| struct slack channels list [--query <text>] [--archived] [--limit n] [--cursor c] | Searches the workspace's channels and says whether Struct's bot is in each. |
| struct slack channels join <channel> | Has Struct's bot join a public channel by id, #name or link. Safe to repeat. Invite it to private channels in Slack. |
Setting a repository, an organization or joining a channel needs permission to change connections; listing is open to every member.
struct triage
Chooses which Slack channels Struct watches and when it investigates on its own. Changes
need the configure permission (struct whoami --json shows yours); every member can read.
| Command | What it does |
| ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| struct triage get slack | Lists the triage channels with their Investigate (Ambient in Struct teammate channels) and Alerts state and keywords. |
| struct triage slack add <channel> [--no-investigate] | Adds a channel by id, #name or Slack link. Struct's bot joins public channels itself; invite it to private channels first. New channels auto-investigate unless you pass --no-investigate. Safe to repeat. |
| struct triage slack set <channel> [--investigate on\|off] [--include k1,k2] [--exclude k1,k2] | Changes only the settings you pass. --include and --exclude replace that channel's keywords; "" clears them. |
| struct triage slack remove <channel> | Takes the channel out of automatic triage: no alerts, no automatic investigations. The bot stays in the channel, so an @Struct mention can still start an investigation. Safe to repeat. |
Each change touches only the one channel, so changes from the CLI and the web app do not overwrite each other.
struct build-agent settings show and struct build-agent settings set
Shows or changes the Fix agent: who writes the fix (struct for the Struct Build Agent,
cursor, devin or inspect), when Struct opens a pull request (manual: when asked, auto:
automatically), and the investigation confidence an automatic pull request needs (4:
Very Likely or higher, 5: Definite). show also lists the sources that open pull
requests automatically, whether Cursor, Devin and Inspect keys are saved (never the keys),
and the Devin organization ID and Inspect workspace.
struct build-agent settings set --provider struct --trigger auto --min-confidence 5Any member can run show; set needs a workspace admin (forbidden otherwise).
Cursor needs a saved Cursor API key, and Devin a Devin API key and organization ID: until
they are saved, set --provider cursor (or devin) exits 1 with
cursor_api_key_required, devin_api_key_required or devin_org_id_required. With
--provider cursor or --provider devin, the key in CURSOR_API_KEY or DEVIN_API_KEY
is sent in the same change:
CURSOR_API_KEY=… struct build-agent settings set --provider cursor
DEVIN_API_KEY=… struct build-agent settings set --provider devin --devin-org-id org-…struct build-agent keys set and struct build-agent keys remove
Save, replace or remove the Cursor or Devin API key without changing the provider
(workspace admins). keys set cursor reads the key from --stdin, else
CURSOR_API_KEY (DEVIN_API_KEY for Devin), else a hidden prompt in a terminal. Keys
are never printed; Struct only reports whether one is saved. Removing the key of the
selected provider switches Fix to the Struct Build Agent, and the CLI says so.
printf %s "$KEY" | struct build-agent keys set devin --stdin
struct build-agent keys remove cursorstruct build-agent repos, scripts and prompt
Set up the repositories the Struct Build Agent works on. Any member can list and show;
changes need a workspace admin. <repo> is owner/name, a configuration name or its id.
struct build-agent repos available --search api # repositories Struct can reach
struct build-agent repos add --repo acme/api --node 22
struct build-agent repos set acme/api --node 24
struct build-agent scripts set acme/api --pre --file setup.sh # prepares the machine
struct build-agent scripts set acme/api --post --file check.sh # checks the change
struct build-agent prompt set acme/api --file prompt.md # at most 1,000 characters
struct build-agent scripts show acme/api --pre > setup.sh
struct build-agent repos remove acme/api --yesrepos add needs a GitHub connection that can reach the repository
(github_not_connected, github_repository_not_accessible); a repository has one
configuration (repository_already_configured). Node.js can be 18, 20, 22 or 24 (default
24). scripts show and prompt show print nothing on stdout and exit 0 when none is set
("set": false with --json). Deletes ask first in a terminal; elsewhere pass --yes.
struct memory struct-md show, generate and edit
STRUCT.md is the business context every Struct agent reads. show prints its body on
stdout (title, version and generation status go to stderr). To edit it safely, take the
body and its version from the same show --json answer, so Struct refuses your edit if
someone saved in between instead of overwriting their change:
struct memory struct-md show --json > struct-md.json
jq -j .body struct-md.json > STRUCT.md
# edit STRUCT.md, then:
struct memory struct-md edit --file STRUCT.md \
--expected-version "$(jq .version struct-md.json)" --reason "Added the billing service"generatehas an agent write STRUCT.md while it is empty (or again after a failed attempt). It needs a workspace admin. Add--waitto wait until it finishes (--timeout <seconds>, default 900, which also bounds each check). Running it while a generation is under way follows that generation.editchanges the title (--title) and/or body (--file <path>, or--file -for stdin; at most 4,000 tokens).--reasonis saved with the new version. The CLI edits the current version; pass--expected-version <n>(theversionfromshow --json) to refuse the edit if someone saved in between (memory_version_conflict). Edits are refused while a generation is running (struct_md_generating). Editing needs a workspace admin.- Memories are available to every workspace. For compatibility with older servers,
a disabled-memory response still exits
1withmemories_not_enabled.
struct automations
Automations run a Struct agent on a schedule and deliver the result to a Slack channel,
email, or both. Any member can use them when the workspace's plan includes them
(otherwise commands exit 1 with plan_required).
| Command | What it does |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| struct automations list | Lists automations with their schedule, next run and delivery. |
| struct automations show <id> | Shows one automation: schedule, cron, timezone, next run, source, delivery and instructions. |
| struct automations runs <id> | Recent runs, newest first: status, start, duration, Slack link and error. --limit <n> (1 to 50). |
| struct automations presets | Lists the ready-made tasks (--preset ids). |
| struct automations create | Creates an automation (flags below). |
| struct automations edit <id> | Changes the flags you pass; everything else stays as it is. |
| struct automations enable\|disable <id> | Turns an automation on or off. |
| struct automations run <id> | Starts a run now, outside the schedule. Each run uses credits. |
| struct automations delete <id> | Deletes an automation; its past runs stop showing in Struct. Asks first; pass --yes without a terminal. |
struct automations create --title "Weekly alerts" --preset alert_digest \
--deliver-slack '#oncall' --weekly mon@09:00 --tz America/New_York
struct automations create --instructions-file task.md --source 'slack:#incidents' \
--deliver-email [email protected],[email protected] --email-subject "Daily digest" --daily 08:30- Instructions:
--instructions-file <path>(-reads stdin) and/or--preset <id>(a preset's task is used when no file is given). Create needs one of them. - Source:
--source slack:<#channel or id>looks only at one Slack channel;--all-sources(the default) looks at every source. - Delivery:
--deliver-slack <#channel or id>(repeat it or give a comma list for several channels) and/or--deliver-email a@x,b@ywith an optional--email-subject. Onedit, targets of a kind you do not name are kept as they are:--deliver-slackreplaces every Slack target,--deliver-emailreplaces every email target with one (keeping the first subject unless you give one),--email-subjectalone changes the subject of every email target (""clears it), and--no-deliver-slack/--no-deliver-emailremove every target of that kind. - Schedule:
--cron "0 9 * * 1",--daily HH:MMor--weekly mon@HH:MM, in--tz(an IANA timezone such asEurope/Berlin; create defaults to this machine's timezone only when--tzis left out, edit leaves it unchanged, and a blank--tzis refused). New or changed cron schedules need at least an hour between occurrences; retries, manual triggers and unchanged legacy schedules are exceptions. Values must be fixed: random values (R) are refused. - Struct checks every change and refuses with a stable
code:invalid_cron,schedule_too_frequent,invalid_timezone,invalid_email,channel_not_found,channel_private(invite the Struct bot to the private channel first),channel_archived,slack_missing_scope,slack_not_connected. Struct joins its Slack bot to public channels itself. - The next run time (
nextRunAt) comes from Struct's scheduler, including the wait after a failed run. A run that cannot post in its Slack channel is skipped without charging credits (delivery_unavailable); after three in a row Struct turns the automation off and emails the person who created it.
struct artifacts list|show|versions|pdf|attachment|visibility
Reads the reports Struct saves, such as investigation write-ups and plans. You see the
same reports as in the Struct web app: your team's reports and your own private ones.
visibility needs a login that allows changes (a read-only login gets
write_login_required); attachment works with any login that can read the report.
| Command | What it does |
| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| struct artifacts list | Lists reports, most recently changed first. |
| struct artifacts show <id> | Prints the report's Markdown on stdout (title, kind, version and link go to stderr). With --json, prints the whole report. |
| struct artifacts versions <id> | Lists the report's saved versions, newest first. --before <n> shows older ones; --limit <n> (1 to 100). |
| struct artifacts pdf <id> | Saves the report as a PDF with its charts; diagrams are left out, with a note in their place. -o <file> (default <id>.pdf, or <id>-v<n>.pdf with --version); --force replaces the file. |
| struct artifacts attachment <id> <version> <attachment-id> | Saves one attachment of that version (attachment ids are in show --version <n> --json). -o <file> (default: the attachment's file name); --force replaces the file. The file is readable only by you. |
| struct artifacts visibility <id> team\|private | Shares a report you own with your team, or makes it private again. Struct changes it only if the latest version is the one you reviewed: --expected-version <n>, or else the latest version when the command runs. A changed report gives artifact_changed. |
list takes --search <words> (words in the latest version; quotes match a phrase and
or matches either word), --kind <investigation|incident|postmortem|plan|build_summary>,
--since <when> (an age such as 7d or 12h, a date such as 2026-10-01, or a time with
a zone), --limit <n> (1 to 100, default 25) and --cursor <cursor> (the nextCursor of
the previous page, with the same filters; the next-page hint on stderr includes them).
show and pdf take --version <n> to read a saved version instead of the latest. pdf
checks the destination before exporting: a missing folder fails with output_dir_missing,
a folder as the destination with output_is_directory, and an existing file without
--force with file_exists. A report that does not exist and one you cannot see both
fail with the error code not_found.
struct skills
Skills are the Markdown instructions Struct's agents follow, the same ones as on the Skills page in the Struct web app. A skill has a title, an optional description (when to use it, which search matches) and a body of plain Markdown. Any member can read every native skill and change a global one, which every agent can use. A skill scoped to one Slack channel's teammate needs Configure permission to create or change, and so does changing a skill's scope. Notion skills are read on demand and edited in Notion; managing external sources needs connection configuration permission.
| Command | What it does |
| ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| struct skills list | Lists skills, newest first: id, created, title and description. --page <n> (from 0), --limit <n> (1 to 200, default 50). |
| struct skills search "<words>" | Searches native and all external sources. Repeat --source struct or --source <source-id> to restrict it. --limit <n> (1 to 20, default 10); query at most 500 characters. |
| struct skills show <id> | Prints the title, description and Markdown. --markdown prints only the Markdown exactly as stored. With --json, prints the whole skill. |
| struct skills create | Creates a skill: --title, optional --description, and --file <path> with the Markdown (--file - reads stdin). Global unless --scope <channel-id> is given. Running it twice makes two skills. |
| struct skills edit <id> | Changes --title, --description (or --clear-description to remove it) and/or the Markdown (--file, which replaces the whole body). --scope <channel-id> moves it to a channel, and --global makes it global; moving a skill between scopes needs Configure permission. |
| struct skills delete <id> | Deletes the skill. Asks first in a terminal; elsewhere pass --yes. |
To change the Markdown safely, take it and the version from the same show --json answer,
so Struct refuses your edit if someone saved in between (skill_version_conflict) instead
of overwriting their change:
struct skills show <id> --json > skill.json
jq -j .markdownBody skill.json > skill.md
# edit skill.md, then:
struct skills edit <id> --file skill.md --expected-version "$(jq .version skill.json)"Without --expected-version, edit uses the version it reads just before saving. A
skill that does not exist fails with skill_not_found.
Version 3 search output: skills search --json returns skills, sources,
partial and nextSourceOffset, replacing the native-only runbooks and totalCount
shape. Results carry a canonical ref, such as struct:<uuid> or
notion:<source-uuid>:<page-uuid>. --source-offset continues through sources,
not pages of hits within a source. Check partial status and source notices even when
matches are returned. skills list remains native-only with its existing pagination.
struct skills sources list
struct notion pages <connection-id> # limited to configured connection scope
struct skil