> Source: https://wexa.ai/docs/context/knowledge-base-retrieve

# knowledge-base-retrieve

Retrieve raw knowledge base documents by tag. Needs the `fabric:orchestrate.read` grant.

The shape of `result` for `knowledge-base-retrieve` is not recorded here: it was not captured against a live deployment. Call it once and read what comes back rather than assuming a shape.

**Retrieve by tag and goal**

**Wexa MCP server**

```bash
curl -sS -X POST https://fabric.wexa.ai/mcp/$FABRIC_PROJECT_ID \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "Mcp-Session-Id: $MCP_SESSION_ID" \
  -H "content-type: application/json" -H "accept: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"knowledge-base-retrieve","arguments":{"tags":["procurement-policy"],"goal":"Who approves a large purchase?","limit":5}}}'
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/knowledge-base-retrieve \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"tags":["procurement-policy"],"goal":"Who approves a large purchase?","limit":5}'
```

**TypeScript SDK**

```ts
import { Fabric } from '@wexa-fabric/sdk'

const fabric = new Fabric()
const result = await fabric.knowledgeBaseRetrieve({
  tags: [ 'procurement-policy' ],
  goal: 'Who approves a large purchase?',
  limit: 5
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.knowledge_base_retrieve(
    tags=["procurement-policy"],
    goal="Who approves a large purchase?",
    limit=5,
)
```

## Parameters

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `tags` | array | Required | Knowledge base tags to filter on. A tag nothing was stored under returns nothing. A non-empty array. |
| `goal` | string | Optional | Natural-language query that reorders the tagged documents; it never widens the search. |
| `limit` | integer | Optional | Max results (default 10). A positive integer. |
| `offset_point_id` | string | Optional | Pagination cursor from a prior response. |
| `include_image_data` | boolean | Optional | Include base64 image payloads (default false). |

**Errors**

- `UpstreamError` (503): `S8:knowledge-base-unavailable`: the document store is down or refused the platform's credential. Never an empty result in disguise: no matches is a normal response with an empty list. Retry later.

**More details**

Full description from the tool, as the gateway advertises it:

Retrieve raw KB documents by tags. The results can be reasoned over directly (by you, the calling agent) to build a process_flow_manifest and call create-process-flow — or fed into a separate classification-style flow first, if the reasoning itself warrants its own dedicated flow. Don't build operational flows straight from unreasoned retrieve output — read it and think first, whichever way you do that.

Not marked consequential: it is audited lightly and the project's write gate never holds it.

Every tool call works the same way: [How every tool call works](/docs/sdks-and-apis/how-every-tool-call-works).
