> Source: https://wexa.ai/docs/context/graph-subgraph

# graph-subgraph

A bounded part of the project's context graph to draw: nodes and the relationships among them. Needs the `fabric:query.read` grant.

The shape of `result` for `graph-subgraph` 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.

**Read a neighbourhood**

**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":"graph-subgraph","arguments":{"focus":"4:a1:12","focus_key":"customer-42","hops":1,"limit":500}}}'
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/graph-subgraph \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"focus":"4:a1:12","focus_key":"customer-42","hops":1,"limit":500}'
```

**TypeScript SDK**

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

const fabric = new Fabric()
const result = await fabric.graphSubgraph({
  focus: '4:a1:12',
  focus_key: 'customer-42',
  hops: 1,
  limit: 500
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.graph_subgraph(
    focus="4:a1:12",
    focus_key="customer-42",
    hops=1,
    limit=500,
)
```

## Parameters

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `focus` | string | Optional | Node id to centre on: the `id` of a node in an earlier answer. With no `focus` you get an overview. |
| `focus_key` | string | Optional | The focus node's key value, for a fast lookup. |
| `hops` | integer | Optional | Neighbourhood depth around `focus`, 1 to 3 (default 1). |
| `limit` | integer | Optional | Most nodes to return, 1 to 10000. |
| `q` | string | Optional | Search text matched against node captions. |
| `rels` | array | Optional | Keep only these relationship types: non-empty strings without commas. |
| `types` | array | Optional | Keep only these node types: non-empty strings without commas. |

**Errors**

- `PolicyDenied` (403): the project's access rules refuse the read (`S5:governance`).

**More details**

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

A bounded part of this project's context graph to draw: nodes and the relationships among them, as the
console's Context Graph loads them. Ask for an overview, a node's neighbourhood, or a search. Only what
you may see is returned: the same access rules as query-context and the console apply. Use it to draw
a graph in your own app; use query-context for exact questions.

### Fields of the result

- `nodes`: `[{id, label, type, labels, properties, boundary}]`. `label` is the caption; `type` the node type. A `boundary` node was pulled in only to complete an edge.
- `edges`: `[{id, from, to, type, properties}]` among the returned nodes.
- `truncated`: `true` when `limit` (or the server's cap) was reached.

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).
