---
title: Agent Bricks CLI
description: "Build and deploy custom code agents on Databricks with the Agent Bricks CLI (agentbricks): managed memory, sessions, tools, and tracing."
canonical_url: https://docs.databricks.com/aws/en/agents/custom-agents/agent-bricks-cli
---

# Agent Bricks CLI

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/aws/en/release-notes/release-types.md). No workspace setting is required to enable it. Install the Agent Bricks CLI to get started.

The Agent Bricks CLI (`databricks-agentbricks`) is a Databricks command-line tool for developers who build and deploy custom agents in code.

Use the Agent Bricks CLI to write custom agent logic in code using a LangGraph or OpenAI Agents SDK template and deploy from your terminal. To build an agent without code for questions about your data, use [Genie Agents](https://docs.databricks.com/aws/en/genie-agents/index.md) in the Databricks UI. For more, see [What is Agent Bricks?](https://docs.databricks.com/aws/en/agents/concepts/index.md), the [Agent Bricks FAQ](https://docs.databricks.com/aws/en/agents/concepts/faq.md), and the [Agent Bricks quickstart](https://docs.databricks.com/aws/en/agents/quickstart.md).

The Agent Bricks CLI scaffolds a project using a built-in framework based on Databricks best practices. It can then run the project locally for testing and deploy it to the Databricks agent runtime. The CLI enables you to go from an empty directory to a deployed agent without wiring up runtime, tools, memory, and managed resources by hand. For other ways to build custom agents, including the app-based workflow, see [Run agents on Databricks Apps using the legacy agent server](https://docs.databricks.com/aws/en/agents/custom-agents/author-agent.md).

## Prerequisites

* The [Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/install.md), installed and available on your path.
* Python 3.11 or above. The Agent Bricks CLI package installs on Python 3.10, but the projects it scaffolds require Python 3.11 or above. Databricks recommends Python 3.12.
* [`uv`](https://docs.astral.sh/uv/), which runs the scaffolded project for `agentbricks init`, `agentbricks dev`, and `agentbricks deploy`.
* Install the Agent Bricks CLI. To install it as a `uv` tool, run the following:

  ```bash
  uv tool install databricks-agentbricks
  ```

  To install it with `pip` instead, run `pip install databricks-agentbricks`. If the install fails, see [Troubleshooting](https://docs.databricks.com/aws/en/agents/custom-agents/agent-bricks-cli.md#troubleshooting).

## <a id="overview" />Overview: from sign-in to a deployed agent

The following sequence summarizes the steps in [Create a new agent](https://docs.databricks.com/aws/en/agents/custom-agents/agent-bricks-cli.md#new-agent):

```bash
databricks auth login --host "https://<your-workspace-url>" --profile my-workspace
agentbricks login --profile my-workspace
agentbricks init --framework langgraph my-agent
cd my-agent
agentbricks dev
agentbricks deploy my-agent
```

> [!TIP]
>
> Every command and command group supports `--help`. For example, run `agentbricks memory --help` to list the memory commands and their flags.

## The Agent Bricks CLI lifecycle

The Agent Bricks CLI scaffolds a local directory of deployable agent code from a framework template, with the runtime, tests, and an optional chat UI already wired up. You write the application logic (model, tools, and prompts), and the CLI handles running it locally and deploying it to Databricks infrastructure.

**`agent.toml`** is the declarative source of truth for all Databricks-managed resources your agent depends on: tool bindings (data sandbox, managed Model Context Protocol (MCP) services, Unity Catalog functions), and memory, session, and tracing resources. `agentbricks deploy` reads it to provision and wire everything up, so the file, not hand-written setup code, is what deploys.

The three commands that take an agent from a blank directory to production:

* **`agentbricks init`** scaffolds the project from a bundled template, optionally seeding a `.env` file with a Databricks profile so the project runs right away.
* **`agentbricks dev`** runs the agent locally against Databricks model serving so you can test it before deploying.
* **`agentbricks deploy`** provisions the resources declared in `agent.toml` and rolls the agent out to the Databricks agent runtime.

![Agent Bricks CLI lifecycle: init, dev, and deploy phases with their key actions](https://docs.databricks.com/aws/en/images/generative-ai/agent-bricks-lifecycle.svg)

> [!NOTE]
>
> You can also add tools and bind memory and session stores at any time, not only at init. Use `agentbricks tools add`, `agentbricks memory bind`, and `agentbricks sessions bind` to update your agent configuration between any of these steps.

## Agent Bricks CLI capabilities

| Capability       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Model access     | The Agent Bricks CLI automatically provisions model access so your agent can call a Databricks-served model without managing credentials or endpoints. See [Databricks Foundation Model APIs](https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/index.md).                                                                                                                                                                            |
| Managed memory   | Long-term memories that an agent can write and search, partitioned by actor and backed by managed stores. Use memory to persist facts and preferences across sessions, and use `agentbricks memory pipeline` to distill memories from a session store. See [Agent memory](https://docs.databricks.com/aws/en/agents/agent-memory/managed-memory.md) and [Agent memory pipelines](https://docs.databricks.com/aws/en/agents/agent-memory/memory-pipelines.md). |
| Managed sessions | Conversation transcripts held in managed session stores and partitioned by actor, with support for forking sessions into independent copies. See [Agent sessions](https://docs.databricks.com/aws/en/agents/agent-memory/managed-sessions.md).                                                                                                                                                                                                                |
| Tools            | Databricks-managed capabilities declared in `agent.toml`: a sandbox, a Databricks-managed MCP service, or a Unity Catalog function. Custom Python tools are written directly in the project code. See [MCPs](https://docs.databricks.com/aws/en/agents/mcp-tools/index.md).                                                                                                                                                                                   |
| Tracing          | MLflow tracing that is on by default, routing each run's traces to a per-project MLflow experiment for debugging and monitoring. See [Tracing overview](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/overview.md).                                                                                                                                                                                                                                |
| Deployment       | Deploys an agent to the Databricks agent runtime, grants the agent's service principal access to bound stores, and manages the deployment lifecycle.                                                                                                                                                                                                                                                                                                          |

## <a id="new-agent" />Create a new agent

### Step 1: Authenticate with OAuth and save a profile

The Agent Bricks CLI uses [Databricks CLI authentication](https://docs.databricks.com/aws/en/dev-tools/cli/authentication.md). Authenticate to your workspace with OAuth (user-to-machine) and save the credentials as a named profile. Run both of the following commands.

> [!NOTE]
>
> A *profile* is a named set of connection settings (a workspace URL and its credentials) saved in `~/.databrickscfg`. The examples on this page use a profile named `my-workspace`. Choose any name, then pass it with `--profile`.

1. To start the OAuth flow, run the following, replacing the host with your workspace URL. The command opens a browser to complete sign-in, then writes the `my-workspace` profile to `~/.databrickscfg`:

   ```bash
   databricks auth login --host "https://<your-workspace-url>" --profile my-workspace
   ```

2. To validate the profile and save it as the Agent Bricks CLI default so later commands can omit `--profile`, run the following:

   ```bash
   agentbricks login --profile my-workspace
   ```

   If the profile's credentials are missing or rejected, `agentbricks login` reruns `databricks auth login` and retries.

### Step 2: Scaffold the agent project

Scaffold a new agent project, and pass `--framework` to choose the template. This example uses the LangGraph template, which includes a browser chat app:

```bash
agentbricks init --framework langgraph my-agent
cd my-agent
```

The CLI ships one bundled template per framework and `--framework` selects which one to scaffold from: `langgraph` for LangGraph or `openai` for the OpenAI Agents SDK. The CLI writes the project's managed resources and tool bindings to `agent.toml` and template provenance to `.agentbricks/project.toml`. To scaffold the API-only backend without the chat app, add `--disable-chat-app`.

### Step 3: Attach managed session and memory stores

Managed stores let your agent persist conversation history and long-term memory. `agentbricks init` declares a session store and a memory store in `agent.toml`, named after the project, such as `my-agent-cuzvas-memory`. `agentbricks deploy` creates missing stores and grants the agent access, so most agents can skip this step.

To use a different store, bind it by name. Each command replaces the store name in `agent.toml`. It doesn't create the store. To bind a session store named `my-agent-sessions` and a memory store named `my-agent-memory`, run the following:

```bash
agentbricks sessions bind my-agent-sessions
agentbricks memory bind my-agent-memory
```

To start the agent with memories already in the store, create the store and add entries before you deploy. See the **Agent Bricks CLI** tab in [Get started with agent memory](https://docs.databricks.com/aws/en/agents/agent-memory/managed-memory.md#get-started).

### Step 4: View tracing

Tracing is on by default. `agentbricks init` binds a default `/Shared/agentbricks_traces/<project>-<suffix>` MLflow experiment, and `agentbricks dev` and `agentbricks deploy` send each run's traces to it.

To list traces after your agent has produced some, run the following:

```bash
agentbricks tracing list
```

To bind a specific MLflow experiment, run `agentbricks tracing bind --experiment-id <experiment-id>`. To turn tracing off, run `agentbricks tracing unbind`.

### Step 5: Run the agent locally

Run the agent on your machine to test it before you deploy.

```bash
agentbricks dev
```

This starts a local server on port 8000 using the same command and environment as the Databricks agent runtime. The Agent Bricks CLI connects the agent to Databricks model serving so it can call the model locally. The template sets a default model as the `MODEL` value in `agent/agent.py`. To use a different model, edit that value. Send requests to `http://localhost:8000` to interact with the agent.

> [!NOTE]
>
> `agentbricks dev` doesn't connect to memory or session stores. Long-term memory is off, and conversation history lasts only while the local server runs. The chat app shows **Not connected** for memory locally even when a store is bound. Memory connects after `agentbricks deploy`.

### Step 6: Deploy the agent

Deploy the agent to the Databricks agent runtime. The CLI provisions the bound stores, grants the agent's service principal access to them, and rolls out the deployment. The deployed agent is named `agent-bricks-<name>`.

```bash
agentbricks deploy my-agent
```

When the deployment finishes, the CLI returns the deployment's URL. Open that URL to interact with your live agent, which is automatically connected to Databricks model serving. To manage the deployment afterward, use the `agentbricks deployments` commands, such as `agentbricks deployments logs` and `agentbricks deployments stop`.

The first deploy takes a few minutes, mostly to start the app's compute. Later deploys are faster. If the deploy times out or the URL doesn't respond, see [Deploy times out or the URL doesn't respond](https://docs.databricks.com/aws/en/agents/custom-agents/agent-bricks-cli.md#deploy-timeout). For `MCP_USER_AUTH_REQUIRED` errors when calling the deployed agent, see [Troubleshooting](https://docs.databricks.com/aws/en/agents/custom-agents/agent-bricks-cli.md#user-auth-tools).

## <a id="existing-agent" />Bring an existing agent

If you already built an agent with LangGraph or the OpenAI Agents SDK, use the `--existing` flag to move it to the Agent Bricks CLI and [`DurableAgentServer`](https://docs.databricks.com/aws/en/agents/deploy/agent-server.md). The CLI doesn't rewrite your code. Instead, it prepares migration instructions that a coding agent, such as Claude Code or Codex, follows to convert the project.

### Step 1: Prepare the migration

From the agent's project directory, prepare the migration. Pass the framework that the agent uses: `langgraph` for LangGraph or `openai` for the OpenAI Agents SDK.

```bash
agentbricks init --framework langgraph --existing .
```

The CLI writes an `agent-bricks-migrate/` directory that contains the migration instructions, a prompt for your coding agent, and a reference project generated from the CLI's templates. It also adds skills in `.claude/skills/` and `.agent/skills/` that point coding agents to the instructions. The command doesn't change your application code, dependencies, or `.env` file, and doesn't create any resources in your workspace.

### Step 2: Convert the project with your coding agent

Paste the prompt from `agent-bricks-migrate/` into your coding agent. The coding agent converts the project to use `agent.toml` and a `DurableAgentServer` entrypoint, and verifies the conversion.

### Step 3: Check the conversion

Run `agentbricks doctor` in the project directory:

```bash
agentbricks doctor .
```

`agentbricks doctor` inspects the project's files without running its code or contacting Databricks. It succeeds when the project has a valid `agent.toml`, starts `DurableAgentServer` with an invoke handler, and calls the adapter for its framework. A failed report means that the conversion isn't finished.

### Step 4: Clean up, run, and deploy

Delete `agent-bricks-migrate/` and the two skills that point to it, and keep them out of your commits. Then run the agent with `agentbricks dev` and deploy it with `agentbricks deploy`.

### Considerations

* `--existing` supports LangGraph and the OpenAI Agents SDK with `DurableAgentServer`. It doesn't support `--server custom`.
* Switching the agent to a managed session store doesn't move its existing conversation history. The migration instructions ask you to decide how to handle earlier conversations.
* The `--disable-chat-app`, `--memory-store`, and `--session-store` options shape the reference project. They don't create resources.

## <a id="add-mcp-tools" />Add MCP tools

If you build your agent with the [Agent Bricks CLI](https://docs.databricks.com/aws/en/agents/custom-agents/agent-bricks-cli.md), add an MCP Service to your project with `agentbricks tools add mcp <catalog>.<schema>.<service>`. The command accepts any MCP Service in your workspace that you can access, including built-in `system.ai` services and MCP Services in other catalogs and schemas. The command checks that the service exists in your workspace and records the tool in `agent.toml`. The agent connects to the tool at runtime, so you don't write any connection code.

To list the built-in `system.ai` MCP Services that you can add, run the following command:

```bash
agentbricks tools list --kind mcp
```

To list the MCP Services in another schema, run `agentbricks tools list --kind mcp --schema <catalog>.<schema>`.

The following examples add common built-in services:

```bash
# Search the public web.
agentbricks tools add mcp system.ai.web_search

# Answer analytics questions across your workspace with Genie One.
agentbricks tools add mcp system.ai.genie_one_mcp

# Run SQL on a SQL warehouse.
agentbricks tools add mcp system.ai.dbsql

# Connect to third-party applications.
agentbricks tools add mcp system.ai.slack
agentbricks tools add mcp system.ai.github
```

To add an MCP Service from another catalog and schema, such as an [external MCP server](https://docs.databricks.com/aws/en/ai-gateway/register-mcp-service.md), pass its three-part name. The `--name` option sets the tool's ID in `agent.toml`:

```bash
agentbricks tools add mcp main.tools.ticket_search --name tickets
```

By default, a tool runs with the permissions of the user who sent the request to your agent. To run it as the app's service principal instead, add `--auth app`. For Google Drive, Gmail, Google Calendar, and Microsoft 365, each user completes a one-time OAuth login before the first call. See [Connected applications](https://docs.databricks.com/aws/en/agents/mcp-tools/built-in-mcp-services.md#connected-apps).

To review or remove tools, run `agentbricks tools list` or `agentbricks tools remove mcp <service>`.

For other tools, see the following pages:

* All built-in services and what they do: [Databricks-provided MCPs](https://docs.databricks.com/aws/en/agents/mcp-tools/built-in-mcp-services.md).
* Register your own external MCP servers: [External MCP servers](https://docs.databricks.com/aws/en/ai-gateway/register-mcp-service.md).
* Unity Catalog functions as tools: [Create agent tools using Unity Catalog functions](https://docs.databricks.com/aws/en/agents/custom-agents/create-custom-tool.md).
* A single curated Genie Agent: [Genie Agent MCP server](https://docs.databricks.com/aws/en/agents/mcp-tools/genie-agent.md).

## <a id="agent-toml" />`agent.toml` reference

`agent.toml` is the declarative source of truth for the Databricks-managed resources that your agent uses. `agentbricks init` creates it, `agentbricks tools add`, `agentbricks memory bind`, `agentbricks sessions bind`, and `agentbricks tracing bind` update it, and `agentbricks deploy` reads it to provision resources and grant access. You can also edit it directly.

| Section or field              | Description                                                                                                                                                                                                        |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `schema_version`              | The version of the `agent.toml` format. Generated projects use `1`.                                                                                                                                                |
| `[agent]` `framework`         | The framework template: `langgraph` or `openai`.                                                                                                                                                                   |
| `[agent]` `server`            | The agent server: `agentbricks` for `DurableAgentServer`, or `custom` for your own server.                                                                                                                         |
| `[memory_store]` `name`       | The managed memory store that the agent uses.                                                                                                                                                                      |
| `[session_store]` `name`      | The managed session store that the agent uses.                                                                                                                                                                     |
| `[tracing]` `experiment_name` | The MLflow experiment for traces. Remove the section to turn tracing off.                                                                                                                                          |
| `[[tools]]`                   | A tool binding. Each tool has an `id`, an `auth` value of `user` or `app`, and a `source` that identifies the tool, plus an optional `policy`.                                                                     |
| `[auth.user]`                 | Request-user authorization for tools that you write in code: `required` and `additional_api_scopes`. See [Request-user authorization](https://docs.databricks.com/aws/en/agents/deploy/agent-server.md#user-auth). |

The following example is the file that `agentbricks init` generates for a LangGraph agent named `my-agent`:

```toml
schema_version = 1

[agent]
framework = "langgraph"
server = "agentbricks"

[memory_store]
name = "my-agent-cuzvas-memory"

[session_store]
name = "my-agent-cuzvas-sessions"

[tracing]
experiment_name = "/Shared/agentbricks_traces/my-agent-cuzvas"
```

The random suffix (`cuzvas` in this example) is different for each project, so projects with the same name don't share stores or experiments.

The following example shows tool bindings that `agentbricks tools add` writes: a built-in MCP service, a Genie Agent, and a sandbox:

```toml
[[tools]]
id = "web_search"
auth = "user"
source = { kind = "mcp", service = "system.ai.web_search" }

[[tools]]
id = "genie_agent"
auth = "user"
source = { kind = "genie_agent", space_id = "<space-id>" }

[[tools]]
id = "sandbox"
auth = "user"
source = { kind = "sandbox", service = "system.ai.sandbox" }
```

Tools that call a Unity Catalog function use `source = { kind = "uc_function", function = "<catalog>.<schema>.<function>" }` and support only `auth = "app"`.

## <a id="command-reference" />Command reference

The following table lists the Agent Bricks CLI commands.

| Command                    | Description                                                                                               |
| -------------------------- | --------------------------------------------------------------------------------------------------------- |
| `agentbricks login`        | Authenticate a profile and save it as the default.                                                        |
| `agentbricks logout`       | Forget the saved default profile without deleting its credentials.                                        |
| `agentbricks init`         | Scaffold a new agent project, or prepare an existing agent for migration with `--existing`.               |
| `agentbricks doctor`       | Check that an existing agent is set up for the Agent Bricks CLI.                                          |
| `agentbricks dev`          | Run the agent locally with a chat UI.                                                                     |
| `agentbricks memory`       | Manage long-term memory: bind or unbind a store, and manage stores, entries, and memory pipelines.        |
| `agentbricks sessions`     | Manage conversation sessions: bind or unbind a store, and manage session stores.                          |
| `agentbricks tools`        | List, add, and remove the agent's tools.                                                                  |
| `agentbricks mcp`          | Discover managed MCP services.                                                                            |
| `agentbricks tracing`      | Bind, unbind, and inspect tracing.                                                                        |
| `agentbricks deploy`       | Deploy the agent to the Databricks agent runtime.                                                         |
| `agentbricks deployments`  | Manage deployed agents: `list`, `get`, `wait`, `logs`, `start`, `stop`, and `delete`.                     |
| `agentbricks endpoint`     | Invoke an HTTP endpoint.                                                                                  |
| `agentbricks experimental` | Experimental commands that might change without notice: `experimental models` and `experimental prompts`. |

For every flag and option, see the [Agent Bricks CLI command reference](https://github.com/databricks/databricks-ai-bridge/blob/main/integrations/agentbricks/cli.md) on GitHub.

## <a id="troubleshooting" />Troubleshooting

### <a id="store-limit" />Deploy fails because the workspace has reached its limit

Managed memory stores and session stores each have a per-workspace limit. If `agentbricks deploy` fails with `Workspace has reached the maximum of <N> managed memory stores`, do one of the following, then re-run `agentbricks deploy`:

* Free a slot. Run `agentbricks memory stores list --all` to find stores that you no longer need, then delete them with `agentbricks memory stores delete <name>`. For session stores, run `agentbricks sessions stores list` and delete unused stores with `agentbricks sessions stores delete <name>`.
* Deploy without a store. For a memory store limit, run `agentbricks memory unbind`. For a session store limit, run `agentbricks sessions unbind`. The agent then runs without that long-term memory or conversation history.

### <a id="deploy-timeout" />Deploy times out or the URL doesn't respond

If you deploy from a script or a coding agent with a short command timeout, deploy without waiting, then wait separately:

```bash
agentbricks deploy my-agent --no-wait
agentbricks deployments wait agent-bricks-my-agent
```

By default, `agentbricks deployments wait` returns after about 100 seconds. Its exit codes are:

* `0`: The agent is deployed and running.
* `1`: The deploy failed. Stop retrying. Check the error and the output of `agentbricks deployments logs agent-bricks-my-agent`.
* `75`: The deploy is still running. Run the same command again.

In a script that uses `set -e`, exit code 75 stops the script, so retry only on 75:

```bash
while true; do
  agentbricks deployments wait agent-bricks-my-agent && break
  status=$?
  [ "$status" -eq 75 ] || exit "$status"
done
```

If the deploy fails because the app's compute didn't start in time, run `agentbricks deployments get agent-bricks-my-agent` to check the app's state. If the app is stopped, run `agentbricks deployments start agent-bricks-my-agent`. Then re-run `agentbricks deploy my-agent`.

### <a id="user-auth-tools" />Requests to the deployed agent fail with `MCP_USER_AUTH_REQUIRED`

If an MCP tool uses `auth = "user"`, the deployed agent requires Databricks Apps to forward the signed-in user's token. This applies to every request, including prompts that don't call the tool. Requests that use a bearer token directly, such as `curl` calls or CI jobs, fail with `MCP_USER_AUTH_REQUIRED`.

To call the agent programmatically, add the tool with `--auth app`, for example `agentbricks tools add mcp system.ai.dbsql --auth app`. To switch an existing tool, remove it with `agentbricks tools remove mcp <service>`, add it again with `--auth app`, and redeploy.

### <a id="intel-mac-cryptography" />Install fails on an Intel Mac while building `cryptography`

If the install fails on an Intel Mac while building the `cryptography` package from source, install prebuilt packages instead. To install with `pip`, run the following:

```bash
pip install --only-binary :all: databricks-agentbricks
```

### <a id="python-version" />Install or `agentbricks dev` fails because of the Python version

If the install or `agentbricks dev` fails while building dependencies, check your Python version with `python3 --version`. Scaffolded projects require Python 3.11 or above, and Databricks recommends Python 3.12. On newer Python releases, some dependencies might not have prebuilt packages. To install the CLI with Python 3.12, run the following:

```bash
uv tool install --python 3.12 databricks-agentbricks
```

## Additional resources

* Query agents: [Query an agent that uses `DurableAgentServer`](https://docs.databricks.com/aws/en/agents/query-llms.md#durable-agent-server).
* Deploy agents: [Deploy agents on Databricks](https://docs.databricks.com/aws/en/agents/deploy/index.md).
* Connect to models: [Query foundation and embedding models](https://docs.databricks.com/aws/en/ai-gateway/query-model-services.md).
* Agent Bricks FAQ: [Agent Bricks FAQ](https://docs.databricks.com/aws/en/agents/concepts/faq.md).
* Agent tools and MCP services: [MCPs](https://docs.databricks.com/aws/en/agents/mcp-tools/index.md).
* Agent memory concepts and API: [Agent memory](https://docs.databricks.com/aws/en/agents/agent-memory/managed-memory.md).
* Agent sessions concepts and API: [Agent sessions](https://docs.databricks.com/aws/en/agents/agent-memory/managed-sessions.md).
* Distill session history into long-term memory: [Agent memory pipelines](https://docs.databricks.com/aws/en/agents/agent-memory/memory-pipelines.md).
* MLflow Tracing for agents: [Tracing overview](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/overview.md).
