# uip docsai

> Syntax and options for `uip docsai`, which queries UiPath documentation via natural language and returns AI-generated answers with source URLs.

`uip docsai` asks natural-language questions against UiPath's documentation, returning an AI-generated answer with source URLs and suggested follow-up questions. Internally, the tool talks to a hosted MCP server (`SearchDocumentation` tool) rather than a REST endpoint — this is why the output shape has a `query_id` field.

See [Tools (plugins)](./concepts-tools.md) for how this tool integrates with the CLI.

## Synopsis

```
uip docsai ask <query> [--source <docs|technical_solution_articles>]
```

All subcommands honor the [global options](./global-options.md) and [exit codes](./exit-codes.md).

## uip docsai ask

Search UiPath documentation. Returns a synthesized answer and the sources that backed it.

### Arguments
- `<query>` *(required)* — The question, as a natural-language string. Wrap in quotes if it contains spaces.

### Options

- `--source <source>` — Knowledge base to search. One of `docs` (default) or `technical_solution_articles`. Invalid values fail at parse time.

### Examples

```bash
# Ask a how-to question against the main docs
uip docsai ask "How do I create a process?"

# Search the technical solution articles instead
uip docsai ask "Selector failed with 404" --source technical_solution_articles
```

## Output formatting

`uip docsai ask` adapts its output to the CLI's [global `--output` mode](./global-options.md):

- `--output table` (default) and `--output plain` print a readable, human-friendly response: the answer text, then a `Sources:` list, then (if present) `Follow-up questions:`.
- `--output json` emits the parsed response in the standard envelope.

## Data shape (--output json)

```json
{
  "Code": "DocsAIAsk",
  "Data": {
    "query_id": "a1b2c3d4-0000-0000-0000-000000000001",
    "text": "To create a process, open UiPath Orchestrator, navigate to Processes, and click Add.",
    "sources": [
      "https://docs.uipath.com/orchestrator/standalone/2022.4/user-guide/managing-processes"
    ],
    "disclaimers": [],
    "followups": [
      "What permissions are required to create a process in Orchestrator?"
    ]
  }
}
```

- `query_id` — unique ID for this query.
- `text` — AI-generated answer.
- `sources` — absolute URLs for the documentation pages cited in the answer.
- `disclaimers` — any cautions the server wants the client to surface alongside the answer (often empty).
- `followups` — suggested next questions, ranked.

If the server returns a response the CLI cannot parse as the structured shape above, `Data` falls back to the raw content array from the MCP tool call so nothing is lost.

## Error behavior

- Failure to create the MCP client, or a failed MCP tool call: `Message: "Error querying DocsAI"`, with the underlying error and the HTTP status in `Instructions`. The CLI closes the client cleanly before exiting. `Result` and `ErrorCode` follow the HTTP status:
  - When DocsAI refuses the request with HTTP 403, `Result` is `AuthenticationError` (exit 2) and `ErrorCode` is `permission_denied`. An HTTP 401 gives `AuthenticationError` with `authentication_required`.
  - Any other failure, such as a connectivity issue, gives `Result: "Failure"` (exit 1).
- Server-side error (e.g., rate limit): `Failure: "DocsAI returned an error"` with the raw content payload in `Instructions`.

## Related

- [Tools (plugins)](./concepts-tools.md) — install, update, uninstall the `docsai-tool` package.
- [`uip mcp`](./uip-mcp.md) — lets a *client* MCP host invoke the CLI; `docsai` goes the other direction and calls a *remote* MCP server.
- [`uip login`](./uip-login.md) — session used to authenticate DocsAI calls.
