Skip to main content
The Aspect CLI surface can vary by repository. In addition to built-in tasks, aspect <task> runs tasks declared in your .aspect/*.axl files. The CLI provides a machine-readable view of the tasks, flags, and defaults available in the current workspace, along with structured output for other read-only commands used in automation. Use the features on this page when:
  • You’re writing a shell script or CI job that needs to enumerate tasks or flags without parsing help text.
  • You’re driving aspect from an AI coding agent that needs to discover commands, inspect a task’s flags on demand, and recover from errors without relying on prior knowledge.
  • You’re piping aspect output to a log, another process, or a file and need clean output without interactive progress updates or ANSI escape codes.
  • You want an AI agent to read your team’s build and test results directly, using the aspect mcp server.

Discover the surface with aspect describe

aspect describe prints the resolved CLI surface as JSON on stdout. It includes built-in and custom .axl tasks, the flags each task accepts, and the effective defaults after config.axl is applied. Flag names come from the same definitions used by the CLI, keeping the description aligned with the accepted arguments. Start with the command index, then request full details for a specific task when needed:
Quote multi-word task paths as a single argument. Use to inspect the cache diff task. If you run aspect describe cache diff without quotes, the command reports the extra argument as an error.
Both forms default to JSON on stdout and exit non-zero on an unknown command (aspect describe 'nope' fails), so scripts can rely on the exit status.

The index (aspect describe)

The index lists every reachable task with a copy-pasteable command string, its group path, one-line summary, and defining module. Use it to discover what’s available before drilling into a specific task:

One task’s flags (aspect describe '<command>')

Passing a command string returns the same header plus every flag it accepts, with type, default, allowed values, and description. Feature flags accepted everywhere are included too:

config.axl overrides show through as effective defaults

If your config.axl overrides a task’s default, describe reports the effective default that applies in the current repository. Overrides preserve their declared types, so an integer override reads 2, not ["2"], and include "default_from_config": true:
This makes describe a reliable way to determine a command’s default behavior in the current repository.

Check auth state with aspect auth status --output=json

aspect auth status prints a human-readable summary by default. Pass --output=json for machine-readable data that scripts and agents can use to diagnose authentication problems without parsing the text output:
Each entry includes logged_in, status, identity, its endpoints, and the exact login_command that re-authenticates it. A caller that finds an expired token gets the remedy without additional lookups. Only the JSON goes to stdout. The task header stays on stderr, so you can pipe stdout cleanly to jq or a file. Text output is unchanged.

--output is the standard flag for machine-readable output

Read commands use --output for their format switch. aspect cache diff now documents --output as the spelling for its format flag. The older --format still works but prints a deprecation warning:
See aspect cache diff for the full list of formats.

Pipe-safe help and output

Use aspect --help as a useful first call for both humans and agents:
  • Every built-in task, including build, format, gazelle, lint, and test, has a one-line summary in the top-level help.
  • Task groups list their members inline, so you can see what’s inside a group without a second --help call:
    Long groups use … (+N more) to omit additional members.
  • aspect test --help cross-references aspect cache diff under the section on running only affected tests.
The launcher’s download progress and aspect feature output are also safe to capture:
  • For redirected output, the launcher emits concise progress updates instead of terminal redraws. Interactive terminals and CI retain their existing progress behavior.
  • aspect feature strips ANSI escape codes when its output isn’t a terminal and honors NO_COLOR.

Serve build results to agents with aspect mcp

aspect mcp runs a Model Context Protocol server over stdio. It exposes read-only build and test results from an Aspect Workflows deployment’s REST API: invocations, logs, targets, artifacts, and cross-invocation target statistics. The command is not interactive. An AI tool such as Claude Code or Cursor launches it and speaks MCP on stdin/stdout. Use it when you want an agent to answer questions like “why did CI fail on my branch”, “tail the log of the last failed build”, or “when did this target start flaking”. The agent reads the results directly, so you don’t paste logs into the chat.

Prerequisites

  • The deployment runs Aspect Workflows 6.0.30 or later with the REST API enabled (webapp.web.api_enabled = true). Against an older deployment, or one without the flag, the server still starts. Every tool call then returns a message explaining the version and flag requirement instead of failing, so your MCP config keeps working across an upgrade.
  • Once per developer, configure and sign in to the deployment:
The server reuses the stored deployment credential from aspect auth login and refreshes it automatically, so long agent sessions stay authenticated. It discovers the API host from the deployment’s advertised build-results URL, so there is nothing else to configure.

Register the server in your AI tool

Add an entry to the tool’s MCP configuration. For Claude Code that is .mcp.json in the repository root; for Cursor it is .cursor/mcp.json. Both use the same shape:
The server targets the default configured deployment. To pin one, add --deployment <name> to the args. For several deployments, register one entry per deployment (for example aspect-staging and aspect-prod) with distinct --deployment args:

Available tools

The server publishes 13 read-only tools: Builds are addressed by the id that list_invocations returns. When the agent only has the invocation UUID Bazel printed, it resolves that first with list_invocations(invocation_id=...). Each tool’s description documents this, so agents pick it up from tools/list without extra prompting.

For AXL authors: ctx.aspect.mcp.serve()

The mcp task is a built-in .axl task implemented with the ctx.aspect.mcp.serve(deployment = ...) runtime API. If you wrap or replace the task in your own .axl files, call serve() and return its result as the task’s exit code. Keep stdout untouched: it carries the MCP protocol, and anything else printed there corrupts the JSON-RPC stream. Diagnostics go to stderr.

When to use which command

Example: driving aspect from a script

Enumerate every task, drill into one, and act on its flags:

Example: an agent recovering from an auth failure

See also

  • aspect cache diff: use --output=json with affected-test results.
  • Authenticating the Aspect CLI: learn how aspect auth login works and how CI authenticates with ASPECT_API_TOKEN.
  • Tasks overview: explore the built-in tasks that aspect describe lists and how custom .axl tasks appear alongside them.
  • Build results over MCP: the Workflows-side guide to the MCP server, including operator setup and troubleshooting.