# Neo4j recipe

URL: https://briq.cloud/cookbook/neo4j

> A graph database with a persistent volume, for data an agent should query, not paraphrase.

Tags: database, graph

Guide:

- [Connect to a database from outside](https://briq.cloud/docs/guides/connect-to-a-database-from-outside.md): A briq's database reachable from psql, a BI tool or an app elsewhere, over TLS, with a normal connection string.

## Run it

MCP:

```ts
briq_run({
  recipe: "neo4j",
  params: {
    "version": "5",
    "size": "small",
    "diskGb": 2
  },
  wait: true
})
```

REST:

```bash
curl -X POST https://api.briq.cloud/v1/briqs \
  -H "Authorization: Bearer $BRIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "recipe": "neo4j",
    "params": {
      "version": "5",
      "size": "small",
      "diskGb": 2
    },
    "wait": true
  }'
# → { "briqs": [{ "id": "bq_…", … }], "outputs": { "NEO4J_BOLT_URL": "…" }, … }

# ... when done, for each briq id
curl -X DELETE https://api.briq.cloud/v1/briqs/<id> \
  -H "Authorization: Bearer $BRIQ_API_KEY"
```

## Parameters

| Name | Type | Options | Default | What it does |
| --- | --- | --- | --- | --- |
| `version` | enum | 5 | "5" | — |
| `size` | enum | nano, small, medium, large | "small" | — |
| `diskGb` | number | — | 2 | Volume size, in GB |

## Outputs

Returned by `briq_run` once the stack is healthy. Hosts resolve inside your team network; secrets are generated per run.

| Output | Value |
| --- | --- |
| `NEO4J_BOLT_URL` | `bolt://neo4j.<stack>.internal:7687` |
| `NEO4J_HTTP_URL` | `http://neo4j.<stack>.internal:7474` |
| `NEO4J_USER` | `neo4j` |
| `NEO4J_PASSWORD` | `<NEO4J_PASSWORD>` |

## What it runs

| Briq | Image | Ports | Size | Volume |
| --- | --- | --- | --- | --- |
| neo4j | `neo4j:5` | 7474, 7687 | small | 2 GB at /data |

## When to use it

* The agent's memory is relationships: which service calls which, which bug hit which customer.
  A graph answers "what is connected to this?" directly.
* The agent should write facts in Cypher as it learns them, and query them later.
* You are prototyping a recommendation, fraud or dependency-graph feature and need a real Bolt
  endpoint.

## Tips

* **Auth is on**: user `neo4j`, password `NEO4J_PASSWORD` in the outputs.
* **Connect from outside**: `briq_expose` port 7687 with `protocol: "bolt"` gives a `neo4j+s://`
  address. See [Connect to a database from outside](https://briq.cloud/docs/guides/connect-to-a-database-from-outside).
* **Bolt** (`NEO4J_BOLT_URL`) works with the official drivers, or `cypher-shell` via `briq_exec`.
* **Browser for a human**: `briq_expose` port 7474 with `mode: "private"` (the briq restarts to
  publish it), and port 7687 with `protocol: "bolt"`. In the Browser, connect to the `neo4j+s://`
  address as `neo4j`.
* **Bigger graph?** The volume starts small: pass `diskGb`, e.g. `params: { diskGb: 20 }`. Set it
  when the briq is created, and it counts toward your [plan's disk](https://briq.cloud/docs/cost#plans).
