# TDX Commands (Server-Side CLI)

Skip the terminal. The full tdx CLI runs inside Studio's server-side sandbox, so you can query databases, manage segments, and validate configurations without leaving the chat — with the same commands you already use locally.

Note
TDX commands execute in an isolated sandbox execution environment — not on your local machine. Your Treasure AI credentials are managed server-side and are not stored in the browser. Network access is restricted to Treasure AI APIs and authorized endpoints.

## Objective

Run tdx CLI commands through the AI for precise, on-demand control over your Treasure AI resources — complementing the AI's autonomous multi-step workflows.

## Prerequisites

- Signed in to Treasure AI Studio ([Getting Started](/products/ai-studio/getting-started))
- **Web or Desktop only** — TDX commands are not available on Mobile


## Running TDX Commands

Ask the AI to run any tdx command on your behalf. The command executes in the server-side sandbox, and the output appears inline in the conversation as a tool call result.


```
You: Run tdx databases to show me what's available

AI: [Runs tdx databases in the sandbox]
    You have 12 databases. Here are the most recently updated...
```

### When to Use Direct Commands

- **Quick lookups.** Ask the AI to run `tdx databases` or `tdx tables mydb` to check what data is available.
- **Precise control.** When you know the exact command, tell the AI to run it directly — it skips the reasoning phase and executes immediately.
- **Validation.** Ask the AI to run `tdx sg validate segment.yaml` or `tdx journey validate journey.yaml` to validate configurations.
- **Debugging.** Ask the AI to run `tdx api --type td /v3/job/list` to inspect raw API responses.


### When to Let the AI Choose Commands

For multi-step workflows — "explore the customer database, find the most useful tables, and build an audience segment of high-value users" — let the AI handle the commands. It chains together the right sequence of calls, interprets the results, and continues working.

## Available TDX Commands

The full tdx CLI is available in the sandbox. Here are the most commonly used command groups:

### Data Commands

| Command | Description | Example |
|  --- | --- | --- |
| `tdx databases` | List all databases | `tdx databases` |
| `tdx tables <db>` | List tables in a database | `tdx tables mydb` |
| `tdx describe <db.table>` | Show table schema (columns and types) | `tdx describe mydb.users` |
| `tdx show <db.table>` | Preview table contents (SELECT * with limit) | `tdx show mydb.users` |
| `tdx query "<sql>"` | Run a Trino SQL query | `tdx query "SELECT * FROM mydb.users LIMIT 10"` |
| `tdx job list` | List recent query jobs | `tdx job list` |


### CDP Commands

| Command | Description | Example |
|  --- | --- | --- |
| `tdx segment list` | List CDP audience segments | `tdx segment list` |
| `tdx sg validate <file>` | Validate a segment YAML file | `tdx sg validate segment.yaml` |
| `tdx parent-segment list` | List parent segments | `tdx parent-segment list` |
| `tdx journey list` | List journeys | `tdx journey list` |
| `tdx journey validate <file>` | Validate a journey YAML file | `tdx journey validate journey.yaml` |
| `tdx activations <segment>` | List activations for a segment | `tdx activations parent/child` |


### AI Commands

| Command | Description | Example |
|  --- | --- | --- |
| `tdx agents` | List agents in current project | `tdx agents` |
| `tdx llm projects` | List LLM projects | `tdx llm projects` |


### Context & Utility Commands

| Command | Description | Example |
|  --- | --- | --- |
| `tdx status` | Show auth status and current context | `tdx status` |
| `tdx use database <db>` | Set the active database for the session | `tdx use database mydb` |
| `tdx api <endpoint>` | Make a raw API request | `tdx api --type td /v3/job/list` |


Pro Tip
Use plural forms as aliases for list commands: `tdx databases` = `tdx database list`, `tdx tables mydb` = `tdx table list mydb`, `tdx segments` = `tdx segment list`.

## Output Formats

By default, tdx outputs results in a human-readable table format. You can control the output format with flags:

| Flag | Format | Use Case |
|  --- | --- | --- |
| `--table` | Table (default) | Human-readable display |
| `--json` | JSON | Structured data for AI processing |
| `--jsonl` | JSON Lines | Streaming/line-by-line processing |
| `--tsv` | TSV | Tab-separated for spreadsheet import |


When the AI runs tdx commands on your behalf, it may use `--json` to get structured output that is easier to process programmatically.

## Server-Side Execution Environment

All tdx commands execute in an isolated server-side sandbox, not on your local machine. This means:

- **Your Treasure AI credentials** are managed server-side and are not stored in the browser
- **Network access** is restricted to Treasure AI APIs and authorized endpoints
- **Filesystem scope** is limited to the chat session's working directory
- **No local side effects** — nothing is installed on or read from your computer


See [Security & Permissions](/products/ai-studio/security) for details on the sandbox execution environment.

## Differences from Treasure Studio Labs

| Feature | Treasure Studio Labs | Treasure AI Studio |
|  --- | --- | --- |
| **Execution environment** | Local machine (your terminal) | Server-side sandbox |
| **Command palette** | `Cmd+Shift+P` for actions | Not available in GA |
| **MCP tools** | Connected via local MCP server | Not available in GA (MCP is post-GA) |


Technical Note
In Treasure Studio Labs, tdx commands executed directly on your local machine using your local tdx installation. In Treasure AI Studio, the same commands execute in the server-side sandbox using a managed tdx installation. The command syntax is identical — the execution environment has changed.

## Verification

- [ ] Ask the AI to run `tdx status` and see your auth status and region
- [ ] Ask the AI to run `tdx databases` and see a list of your Treasure AI databases
- [ ] Expand the tool call to see the full command and raw output


## Troubleshooting

| Issue | Solution |
|  --- | --- |
| Command returns "not found" or empty output | Verify your Treasure AI account has the expected databases and resources. Ask the AI to run `tdx status` to confirm authentication and region are correct |
| Output is truncated | Large outputs are trimmed to fit the chat. Ask the AI to run the command with `--format json` for complete output, or ask it to summarize the results |


## Next Steps

- [Query Execution](/products/ai-studio/query/query-execution) — Running Trino queries through the AI
- [Query Result Tables](/products/ai-studio/query/query-results) — Understanding query result display
- [Skills & Marketplace](/products/ai-studio/skills/skills) — Pre-built skills for SQL, segments, and more