---
title: "rayfin docs"
description: "Search, list, fetch, discover, and inspect Rayfin package documentation from the terminal with rayfin docs."
url: https://rayfin.ai/docs/reference/cli/docs
markdown_url: https://rayfin.ai/docs/reference/cli/docs.md
section: reference
product: Rayfin
sdk_version: 2.0.0
cli_version: 2.0.0
last_updated: 2026-11-12T21:44:39-08:00
source: reference/cli/docs.mdx
---

# rayfin docs

> Search, list, fetch, discover, and inspect Rayfin package documentation from the terminal with rayfin docs.

`rayfin docs` queries documentation bundled in the Rayfin packages installed in the current
project. Use it when an MCP server is unavailable or when a script needs JSON output.

## How docs are discovered [#how-docs-are-discovered]

The CLI scans `node_modules` for packages with a `rayfinDocs` field and indexes their
bundled Markdown. Results are version-locked to the project's installed packages. Areas
accepted by `--module` are `guide`, `host`, and `ts-sdk`.

A package advertises docs with a `rayfinDocs` field in its `package.json`:

```json title="node_modules/@microsoft/rayfin-guide/package.json"
{
  "rayfinDocs": {
    "version": 1,
    "dir": "assets/docs",
    "module": "rayfin-guide",
    "kind": "guide"
  }
}
```

The `kind` value determines the docs area exposed through `--module`. Guide and
TypeScript SDK docs load by default. Host docs are available when installed and selected
with `--module host`.

### Guide fallback [#guide-fallback]

[New in 2.0](/docs/reference/changelog#rayfin-20)

When the project has no `@microsoft/rayfin-guide` package installed, `rayfin docs` serves
the general guides from the copy installed with the CLI, so `docs list --module guide`
and guide searches work in a project that only has the CLI. A guide package installed in
the project takes precedence, and SDK and API docs still come only from the project's own
packages.

## `docs list` [#docs-list]

```bash
npx rayfin docs list --module guide
```

| Option                | Default           | Description                                    |
| --------------------- | ----------------- | ---------------------------------------------- |
| `-m, --module <name>` | all default areas | Limit results to `guide`, `host`, or `ts-sdk`. |
| `--json`              | `false`           | Emit a JSON object.                            |
| `--lean`              | `false`           | With `--json`, emit only the inner array.      |
| `--no-cache`          | `false`           | Rebuild the on-disk docs index cache.          |

## `docs search` [#docs-search]

```bash
npx rayfin docs search "row level security" --scope all --limit 5
```

| Option                | Default           | Description                                      |
| --------------------- | ----------------- | ------------------------------------------------ |
| `<query>`             | required          | Search query. Use quotes for multi-word phrases. |
| `-m, --module <name>` | all default areas | Limit to `guide`, `host`, or `ts-sdk`.           |
| `-s, --scope <scope>` | `docs`            | Search `docs`, `symbols`, or `all`.              |
| `-l, --limit <n>`     | `10`              | Maximum results, 1–50.                           |
| `--json`              | `false`           | Emit a JSON object.                              |
| `--lean`              | `false`           | With `--json`, emit only the inner array.        |
| `--no-cache`          | `false`           | Rebuild the docs index cache.                    |

## `docs get` [#docs-get]

[Changed in 1.36](/docs/reference/changelog#rayfin-136)

```bash
npx rayfin docs get --symbol RayfinClient
```

Fetch a doc entry by ID or path, or resolve a symbol name to matching sections. Rayfin
1.36 fixes symbol lookup formatting so symbols such as `RayfinClient` and `'@entity'` are
resolved consistently.

| Option                | Default     | Description                                             |
| --------------------- | ----------- | ------------------------------------------------------- |
| `-i, --id <id>`       | —           | Doc ID, for example `rayfin-guide:data/overview.md`.    |
| `-p, --path <path>`   | —           | Doc path, for example `data/overview.md`.               |
| `-s, --symbol <name>` | —           | Symbol name, for example `RayfinClient` or `'@entity'`. |
| `-m, --module <name>` | all modules | With `--symbol`, limit to `guide`, `host`, or `ts-sdk`. |
| `-l, --limit <n>`     | all matches | With `--symbol`, max sections, 1–50.                    |
| `--json`              | `false`     | Emit a JSON object.                                     |
| `--lean`              | `false`     | With `--json`, emit only the inner entry or sections.   |
| `--no-cache`          | `false`     | Rebuild the docs index cache.                           |

Exactly one of `--id`, `--path`, or `--symbol` is required.

## `docs discover` [#docs-discover]

```bash
npx rayfin docs discover "functions secrets"
```

Finds Rayfin packages by free-form query when the installed corpus is missing the topic.

`discover` recommends `@microsoft/rayfin-storage` and `@microsoft/rayfin-telemetry` in
2.0. Packages marked experimental in the catalog are never recommended, but their docs
are indexed once you install them.
[Changed in 2.0](/docs/reference/changelog#rayfin-20)

| Option            | Default  | Description                             |
| ----------------- | -------- | --------------------------------------- |
| `<query>`         | required | Free-form package query.                |
| `--json`          | `false`  | Emit JSON.                              |
| `--lean`          | `false`  | Emit compact JSON without the envelope. |
| `-l, --limit <n>` | `10`     | Max results, 1–50.                      |

## `docs catalog show` [#docs-catalog-show]

```bash
npx rayfin docs catalog show --json
```

Displays the in-memory package discovery catalog.

| Option   | Description                             |
| -------- | --------------------------------------- |
| `--json` | Emit JSON.                              |
| `--lean` | Emit compact JSON without the envelope. |

## When to use the CLI versus MCP [#when-to-use-the-cli-versus-mcp]

Prefer the MCP server when it is connected because agents can call structured tools instead
of parsing terminal output. Use `rayfin docs` when MCP is unavailable, when you need an
offline terminal workflow, or when a script needs `--json`/`--lean` output and exit codes.

## MCP server [#mcp-server]

`@microsoft/rayfin-mcp` exposes the same version-locked docs corpus over MCP.
`rayfin init ai-files install` writes the `mcpServers.rayfin` entry in `.mcp.json`:

```json title=".mcp.json"
{
  "mcpServers": {
    "rayfin": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@microsoft/rayfin-mcp", "start"]
    }
  }
}
```

Run your agent from the project root so the server resolves that project's packages. Like
the CLI, the 2.0 MCP server serves the general guides from its own installation when the
project has no guide package. [New in 2.0](/docs/reference/changelog#rayfin-20)

| MCP tool                     | Closest CLI command                                              |
| ---------------------------- | ---------------------------------------------------------------- |
| `search_docs(query, module)` | `rayfin docs search <query> --module <module>`                   |
| `get_doc(idOrSymbol)`        | `rayfin docs get --id <id>` or `rayfin docs get --symbol <name>` |
| `list_docs(module)`          | `rayfin docs list --module <module>`                             |
| `discover_packages(query)`   | `rayfin docs discover <query>`                                   |

Use CLI JSON output when MCP is unavailable:

```bash
npx rayfin docs search "row level security" --module guide --json --lean
```

```prompt title="Find version-locked Rayfin docs"
Run `npx rayfin docs search "externalEntraExchange" --scope all --json` from my Rayfin
project root, then use `npx rayfin docs get --id <id>` on the best result and summarize
whether my installed packages support the setting.
```
