Docs ยท Tools

Commands and scripts

Serve your CLIs and scripts to agents as reviewed tools that run on your own hosts, through a connector.

Docs menu
On this page
  1. Two ways to run things on a host
  2. Before you start: the connector user
  3. Commands
  4. 1. Allow binaries on the host
  5. 2. Create the team's commands server
  6. 3. Submit a spec
  7. 4. A second admin approves it
  8. 5. Pin the tools and set approvals
  9. Reviewed scripts
  10. See also

Two ways to run things on a host#

A connector can run programs on its host for agents, in two ways:

CommandsReviewed scripts
What runsA binary on the connector's allowlist, through a command spec: reviewed YAML that turns one binary into a few narrow toolsA script an agent wrote, with an interpreter the connector allows
What the agent controlsOnly the arguments, checked against the tool's schema and placed into a fixed command line. The binary runs directly, not through a shellNothing after approval: the approved text and its hash are fixed
Who reviewsA second admin of the team approves each spec versionA team admin approves each script version

Both are off until you turn them on in the connector's connector.yaml. The connector's own settings are a ceiling the gateway cannot widen. Every call still goes through identity, policy, approvals and the audit log, like any other tool.

Before you start: the connector user#

Commands and scripts run as a dedicated run_as user that you create on the host. It can be neither root nor the connector's own user, so the connector has to run as root to switch to it.

The one-line Linux installer runs the service as the unprivileged bastn-connector user. To run commands or scripts, run it as root with a drop-in, which survives upgrades:

sh
sudo useradd --system --no-create-home bastn-cmd
sudo systemctl edit bastn-connector
ini
[Service]
User=root
Group=root

Then sudo systemctl restart bastn-connector. Running as root, the connector warns at start when its state directory /var/lib/bastn-connector belongs to another user, because that user controls the connector's identity; sudo chown -R root:root /var/lib/bastn-connector settles it.

Warning

Every other capability of that connector then runs as root too. Give the run_as user no credentials, and consider a separate connector for commands.

The Docker image runs as a non-root user and cannot switch users, so use the Linux install for commands and scripts.

Commands#

1. Allow binaries on the host#

Add a commands capability to connector.yaml and restart the connector:

yaml
capabilities:
  - name: commands
    kind: commands
    enabled: true                  # off unless set
    run_as: bastn-cmd              # never root, never the connector's own user
    profiles: [linux-readonly]     # built-in read-only allowlist
    binaries:
      - { name: deployctl, path: /opt/acme/bin/deployctl, max_effect: write }
      - { name: ip, path: /usr/sbin/ip, max_effect: destructive, deny_flags: ["netns", "-force", "-batch"] }
  • binaries maps the name a spec uses to an absolute path on this host. Nothing else runs.
  • max_effect is the most a binary may do: read, write or destructive. A tool that declares more is not available on this connector.
  • deny_flags are flags the connector refuses on the final command line, whatever the spec allows.
  • The linux-readonly profile allows ping ip ss df free uptime uname lsblk systemctl journalctl dig getent ls tail at their usual paths, read only. A systemctl allowed by it refuses restart, whatever a spec declares.

The connector's Commands view in the dashboard (Tools, Connectors, open the connector) shows its allowlisted binaries, the run_as user, and which command specs can run there and why not. On the host, bastn-connector commands test <spec.yaml> checks a spec against this allowlist without running any tool.

2. Create the team's commands server#

A team admin opens Tools, chooses New server, opens More types, picks the transport Commands (team) and the team. A team has one commands server. Its tools appear on /mcp as <server>__<spec>_<tool>, each with a target argument naming the connector to run on.

3. Submit a spec#

A command spec describes one binary as a few tools. This is a trimmed copy of the uptime spec from bastn's read-only Linux pack:

yaml
spec: bastn.command/v1
name: uptime
binary: uptime
description: Show how long the system has been up, the users and the load averages
version:
  argv: ["-V"]
  match: '(?:procps(?:-ng)?(?: version)?|BusyBox) v?([0-9][0-9.]*)'
defaults:
  timeout: 10s
  env: { LC_ALL: C }
tools:
  - name: show
    effect: read
    description: Show uptime and load averages (1, 5 and 15 minutes)
    argv: ["{flags}"]
    flags:
      format: { type: string, enum: [pretty, since], emit: ["--{value}"], description: "pretty: \"up 2 days, 3 hours\"; since: boot time. procps-ng only" }

On the Commands page, in the Advanced group of the navigation, choose Submit a spec, pick the team, paste the YAML and give a reason. The spec is checked at once: one that does not parse is refused with its findings, line by line. An agent can also propose a spec through the team's fleet server (below).

For the 14 read-only Linux specs that match the linux-readonly profile, write to support@bastn.ai.

4. A second admin approves it#

The reviewer opens the version on the Commands page. It shows who submitted it and why, its SHA-256, each tool with its effect and an example command line, and the diff against the active version. Approve sends the hash the reviewer saw: if the version changed in the meantime, nothing is approved.

Approving needs a team admin who did not write the version and holds no key of the agent that proposed it.

A team with a single admin cannot approve its own specs. It can:

  • invite a second admin to the team, or
  • list the spec under local_specs in connector.yaml: the host's operator trusts it without a gateway review, and gateway policy still applies to its tools.

Only if neither works, write to support@bastn.ai: there is an operator setting that lets a named team approve its own specs.

An approved version is active on the next call, and an earlier approved version can be rolled back to without a new review. Each step is recorded in the audit log.

5. Pin the tools and set approvals#

A server created in the dashboard hides new tools until they are pinned, so publishing a tool is two decisions: the spec review and the pin. Pin the approved tools on the All tools tab of Tools; the Commands page says when approved tools are still unpinned. Then add them to the agents' categories.

  • Destructive tools are held for a person on every call by default.
  • Write tools run without a person unless an approval policy matches. Org admins create approval policies; one can be limited to connectors with a given name or label, such as env=prod.
  • A spec's selector, set in its Availability section, limits which connectors it runs on, by name or label.

Reviewed scripts#

When no command fits, an agent can write a script. Nothing runs until a team admin approves that exact text.

On the host, turn scripts on in connector.yaml and restart the connector. Scripts need a dedicated run_as user too, as above.

yaml
scripts:
  enabled: true
  interpreters:          # the only programs a script can name
    sh: /bin/sh
  run_as: bastn-scripts  # a dedicated user, not the connector's own

Then, in the dashboard:

  1. **Expose the connector's scripts capability** as a server, like any other capability: see Expose a capability to agents.
  2. Create the team's fleet server: Tools, New server, More types, transport Fleet (team), pick the team. Its tools let agents list the team's connectors, push a script and follow its review. Put them in the agent's category.
  3. Review under Approvals, Script reviews (in the More menu of the tabs). Each card shows who pushed the script and why, the user it runs as, the text, and the diff against the active version. Approving sends the hash of the text you read; the connector re-checks it before every run.

The same four-eyes rule applies: the person who pushed a script, or holds a key of the agent that pushed it, cannot approve it. A team with a single admin needs a second admin for script reviews; otherwise write to support@bastn.ai about the operator setting for single-admin teams. A script's tool carries the effect the reviewer approved, so a destructive script is also held on every call.

See also#

Something missing or wrong on this page? Write to support@bastn.ai.