# Use the CLI with agents

Use MCP for interactive Altertable operations. Add the CLI when your agent needs local files, ingestion commands, scripts, or CI. The CLI does not replace MCP, and each connection has its own authentication.

> **Before using the Altertable CLI:**
>
> Install the CLI if you haven’t already:
>
> ```bash
> curl -fsSL https://install.altertable.ai | sh
> altertable login
> ```
>
> If `altertable` isn’t found after installation, open a new terminal. Run `altertable login` to log in to your organization and environment. Follow the [CLI setup guide](/docs/lakehouse/clients/cli.md#2-log-in) to configure credentials and verify access.

## Prepare a profile

Check the profile before using the CLI alongside MCP:

```altertable
altertable profile show
altertable profile status
altertable --agent query "SELECT 1 AS connected"
```

Verify that the CLI profile and MCP connection target the intended organization and environment.

## Return structured results

Use the global `--agent` option before the subcommand:

```altertable
altertable --agent query "SELECT table_catalog, table_schema, table_name FROM information_schema.tables LIMIT 10"
```

This returns structured JSON without a pager, colors, or terminal styling. Discover tables before querying them and bound exploratory results with `LIMIT`.

For commands and options, see the [CLI reference](/docs/api-references/cli.md).