> ## Documentation Index
> Fetch the complete documentation index at: https://docs.andiai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Search the web, fetch pages, and run a local MCP server from the command line with the Andi CLI.

The [Andi CLI](https://github.com/andisearch/andi-cli) (`@andiai/cli` on npm) is a thin client for the hosted API: web search, page fetch, and a local MCP server, with no local index or ranking.

## Install

Install it globally:

```bash theme={null}
npm install -g @andiai/cli
andi search "current weather in san francisco"
```

Or run it directly without installing:

```bash theme={null}
npx -y @andiai/cli search "andi search api" --json
```

## Authentication

Get a key from the [API Console](https://console.andiai.com/signup). The CLI reads it from, in order of precedence: the `--api-key` flag, the `ANDI_API_KEY` environment variable, or `~/.andi/config.json` (`{"apiKey": "..."}`).

```bash theme={null}
export ANDI_API_KEY=YOUR_API_KEY
andi search "typescript satisfies operator"
```

`andi --help` and `andi schema` work without a key.

## Search

```bash theme={null}
andi search "who won the 2026 f1 championship" --mode deep --limit 5
```

Pass up to 5 queries at once — they run as a single API call with fused, deduplicated ranking:

```bash theme={null}
andi search "rust async runtime" "tokio vs async-std" --limit 8
```

`--mode` accepts the same values as [`searchMode`](/search/search-modes): `auto` (default), `low-cost`, `fast`, `balanced`, `deep`, `exhaustive`. Filters mirror the [query parameters](/features/query-parameters): `--country`, `--language`, `--safe`, `--date-range`, `--include-domains`, `--exclude-domains`. Add `--content` to return full page content for each result instead of extracts.

## Fetch a page

```bash theme={null}
andi fetch https://example.com/pricing --query "what does the team plan cost"
```

`--query` focuses the extracts on what you want from the page. See [content retrieval](/search/content-retrieval) for the underlying endpoint.

## Output

`--format auto|json|markdown` controls the shape. The default writes human-readable markdown on an interactive terminal and a JSON envelope (`{"ok": true, "data": ..., "meta": {...}}`) when piped or redirected. `--json` forces JSON. Exit codes distinguish auth failures, exhausted credits, and invalid arguments — run `andi schema` for a machine-readable description of every command, flag, and exit code.

## Local MCP server

`andi mcp` runs a stdio MCP server exposing the same tools as the [hosted MCP server](/resources/ai-agents#andi-search-mcp-server) — for MCP clients that only support stdio transport:

```json theme={null}
{
  "mcpServers": {
    "andi": {
      "command": "npx",
      "args": ["-y", "@andiai/cli", "mcp"],
      "env": { "ANDI_API_KEY": "YOUR_API_KEY" }
    }
  }
}
```

For HTTP-capable clients, prefer the hosted endpoint directly — no install needed. See [build with AI agents](/resources/ai-agents).

## Let your agent set it up

Your agent installs and configures the Andi Search API itself — paste one line:

```text title="Paste into Claude Code, Cursor, or Codex" theme={null}
Set up Andi search for this project: andiai.com
```

Your agent fetches `andiai.com`, follows it to the [install guide](https://api.andiai.com/install.md) at `api.andiai.com`, then gets an API key from the [API Console](https://console.andiai.com/signup), connects the MCP server, and verifies the setup.

<Note>
  **Are you an AI agent?** Fetch [https://api.andiai.com/install.md](https://api.andiai.com/install.md) and follow it to configure Andi Search — MCP server, API key, and verification.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Build with AI agents" icon="robot" href="/resources/ai-agents">
    Hosted MCP server, Agent Skill, and discovery files.
  </Card>

  <Card title="Search modes" icon="gauge-high" href="/search/search-modes">
    Automatic effort by default, manual control when you want it.
  </Card>

  <Card title="Query parameters" icon="sliders" href="/features/query-parameters">
    Full parameter reference.
  </Card>

  <Card title="CLI reference" icon="github" href="https://github.com/andisearch/andi-cli">
    Full command and flag reference on GitHub.
  </Card>
</CardGroup>
