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

# query_brain

> Semantic search over a public brain. Returns the most relevant passages.

Runs a semantic (RAG) search over a public [brain](/brains/overview) and returns the most relevant passages of indexed content, ranked by relevance. This is the main way to pull accurate, up-to-date context about a library or topic into the agent. Get the brain ID from [list\_public\_brains](/mcp/tools/list-public-brains) first.

## Input

| Parameter  | Type      | Required | Description                                                                             |
| ---------- | --------- | -------- | --------------------------------------------------------------------------------------- |
| `brainId`  | string    | Yes      | The brain to search. Get it from [list\_public\_brains](/mcp/tools/list-public-brains). |
| `query`    | string    | Yes      | Natural-language description of the context you need.                                   |
| `limit`    | number    | No       | Max passages to return. Default 5, max 20.                                              |
| `entities` | string\[] | No       | Optional entity names to focus the search on.                                           |

## Example

**Prompt:**

> *"Using the Supabase brain, how do I set up Row Level Security policies?"*

**Tool call:**

```json theme={null}
{
  "brainId": "fa8d5392-fc77-4eb4-8a4c-64e0005c56b6",
  "query": "How do I set up Row Level Security policies?",
  "limit": 3
}
```

**Response:**

```
3 results for "How do I set up Row Level Security policies?":

- Result: 1
- Score: 0.821
- Source: supabase.com/docs/guides/database/postgres/row-level-security
- URL: https://supabase.com/docs/guides/database/postgres/row-level-security
- Node ID: ab699e6d-0a57-4383-a191-8fbed2832f9f
- Content:
You can enable RLS for any table using the `enable row level security` clause:

    alter table "table_name" enable row level security;

Once you have enabled RLS, no data will be accessible via the API when using a
publishable key, until you create policies.
```

Each result carries a `Score`, a `Source`, and a `Node ID`. Pass that node ID to [get\_brain\_node](/mcp/tools/get-brain-node) to read the full source.

<Warning>
  `query_brain` is metered. Every call counts against your brain-query usage.
</Warning>

<Note>
  The underlying endpoint reports query failures inside the response body rather than as an HTTP error. The tool surfaces a clear `Query failed: ...` message when that happens, so you do not need to handle status codes yourself.
</Note>

## When to use it

* The agent needs precise, sourced context about a library and a general answer is not enough.
* You want to ground the agent in real documentation instead of relying on its training data.
* You have already picked a brain with [list\_public\_brains](/mcp/tools/list-public-brains).

## See also

* [list\_public\_brains](/mcp/tools/list-public-brains): find a brain to query.
* [get\_brain\_node](/mcp/tools/get-brain-node): read the full source behind a result.
* [get\_brain\_tree](/mcp/tools/get-brain-tree): browse the brain's structure instead of searching.
