# Command reference

> Every command of the opendb binary: chat, settings, users, roles, privileges, MCP tokens and models.

Source: https://opendb.tools/en/docs/commands

## Before you start

```bash
opendb app:help
```

This command lists every OpenDB command.

Three rules apply to all commands:

- **Login.** Every command asks you to log in. The `--name=` option gives the username. The password is always asked for, never passed as an argument.
- **Optional arguments.** An argument you do not give is asked for.
- **Same rules as the interface.** Commands apply the same validation and the same privileges as the web interface.

## Interface and conversation

| Command | Purpose |
|---|---|
| `opendb serve` | Starts the web interface |
| `opendb chat` | Opens a conversation with the agent. See [Chat in the terminal](/en/docs/cli). |

## Settings

| Command | Purpose |
|---|---|
| `opendb settings` | Global settings: agent, exports, account, AI providers, email, cache |
| `opendb project:settings [project]` | A project's settings: information, connection, agent tables, memory, archives, deletion |
| `opendb ai:models [provider]` | Lists the enabled models. `--json` prints the raw JSON. |

```bash
opendb project:settings shop
opendb ai:models ollama
```

## Users

| Command | Purpose |
|---|---|
| `opendb user:list` | Lists users and their roles |
| `opendb user:create [user]` | Creates a user. `--role=` gives them a role, and can be repeated. |
| `opendb user:update [user]` | Changes a user |
| `opendb user:delete [user]` | Deletes a user and their privileges. `--force` skips the confirmation. |

Options of `user:update`:

| Option | Purpose |
|---|---|
| `--rename=` | The new name |
| `--password` | Asks for a new password |
| `--role=` | The user's roles, which **replace** their current roles |

```bash
opendb user:create camille --role=analyste
opendb user:update camille --password
```

The root account cannot be deleted.

## Roles

| Command | Purpose |
|---|---|
| `opendb role:list` | Lists roles and their number of users |
| `opendb role:create [role]` | Creates a role. `--description=` says what it is for. |
| `opendb role:update [role]` | Renames a role (`--rename=`) or changes its description (`--description=`) |
| `opendb role:delete [role]` | Deletes a role. Its users lose its privileges. |
| `opendb role:assign [role] [user]` | Gives a role to a user. `--revoke` takes it away. |

```bash
opendb role:create support --description="Read orders and customers"
opendb role:assign support camille
```

## Privileges

| Command | Purpose | MySQL equivalent |
|---|---|---|
| `opendb privilege:grant [grantee]` | Grants privileges | `GRANT` |
| `opendb privilege:revoke [grantee]` | Revokes privileges | `REVOKE` |
| `opendb privilege:show [grantee]` | Shows privileges as `GRANT` statements | `SHOW GRANTS` |

Options shared by `grant` and `revoke`:

| Option | Purpose |
|---|---|
| `--role` | The grantee is a role, not a user |
| `--privilege=` | A privilege, such as `select` or `send-mail`, or `all`. Can be repeated. |
| `--project=` | The project involved. Without this option, the privilege applies to the whole instance. |
| `--table=` | A table of the project. Without this option, the privilege applies to the whole project. |

Specific options:

| Option | Command | Purpose |
|---|---|---|
| `--with-grant-option` | `grant` | The grantee can grant these privileges too |
| `--grant-option` | `revoke` | Only revokes the right to grant these privileges |

```bash
# A role that reads and exports a whole project
opendb privilege:grant support --role --privilege=select --privilege=export --project=shop

# My own privileges
opendb privilege:show
```

The permission model is explained in [Users, roles and privileges](/en/docs/users-roles-privileges).

## MCP server

| Command | Purpose |
|---|---|
| `opendb mcp:token-create [name]` | Creates a token. `--project=` names the project. |
| `opendb mcp:token-list` | Lists your tokens |
| `opendb mcp:token-revoke [token]` | Revokes a token. `--force` skips the confirmation. |
| `opendb mcp:serve` | Starts the MCP server, with the token from the `OPENDB_MCP_TOKEN` variable |

You do not run `mcp:serve` yourself: your MCP client does. See [MCP server](/en/docs/mcp-server).

## Help for a command

```bash
opendb help chat
```

Shows a command's description, arguments and options.
