# Use RushDB with AI agents

Source: https://docs.rushdb.com/connect/agents/

RushDB gives agents a structured data layer, a traversable graph, and persistent memory. Choose the shortest setup that matches your agent.

## Fastest setup: Give the agent the guide

Paste this prompt into a coding agent such as Claude Code, Codex or Cursor. It is the same prompt as on [Get started](../index.mdx):

```text
Set up RushDB as this project's database.

1. Install the RushDB MCP server (@rushdb/mcp-server) and the RushDB agent skills (github.com/rush-db/skills).
2. Use RushDB Cloud with an API key from app.rushdb.com, or a local engine:
   curl -fsSL https://rushdb.com/install.sh | sh && rushdb up
   (direct mode: engine URL http://127.0.0.1:3000, token local-token)
3. Before writing any query, read the schema catalog (labels, properties, types, relationship shapes) and use only fields that exist.
4. Docs: https://docs.rushdb.com/
```

For a longer, machine-readable guide, send `Fetch https://rushdb.com/agent-setup and follow the instructions exactly.` It walks the agent through MCP connection, schema discovery, memory labels, nested record linking, recall patterns, and semantic search.

## Coding assistant: MCP + skills + memory

For Claude Desktop, Cursor, VS Code Copilot, OpenClaw, or another local coding agent:

1. [Connect the local MCP server](./mcp.mdx) — to RushDB Cloud with an API key, or to your own engine in direct mode.
2. [Install RushDB Agent Skills](./skills.mdx).
3. Start a new agent session.
4. Send:

```
Set up RushDB as my persistent memory layer.
```

The agent calls `getSchemaMarkdown`, creates a `SESSION`, and validates recall. For the full bootstrap prompt and recommended labels, follow the [Agent Memory Quickstart](../learn/agent-memory/quickstart.mdx).

## Custom agent harness

For an application-controlled agent, choose the interface based on where orchestration lives:

| Interface      | Use it when                                                              |
| -------------- | ------------------------------------------------------------------------ |
| MCP tools      | Your framework already supports MCP tool discovery and invocation        |
| TypeScript SDK | Your harness runs in Node.js, the browser, or an edge-compatible runtime |
| Python SDK     | Your harness runs in Python                                              |
| REST API       | You need language-neutral HTTP integration with RushDB Cloud             |
| Native protocol | You run your own engine and need language-neutral HTTP integration      |

[Connect with an SDK →](./sdks.mdx)

## Native memory providers

MCP exposes model-directed tools. Native providers additionally recall before inference, persist completed turns, participate in session/compaction lifecycle, and fail open when remote memory is unavailable.

| Runtime      | Native integration                                                                                 |
| ------------ | -------------------------------------------------------------------------------------------------- |
| OpenClaw     | [Additive RushDB memory plugin](./openclaw-memory.mdx) — preserves local Markdown/SQLite memory |
| Hermes Agent | [RushDB MemoryProvider](./hermes-memory.mdx) — automatic prefetch and non-blocking durable sync |

Both build on [`@rushdb/agent-memory-contract`](https://www.npmjs.com/package/@rushdb/agent-memory-contract), the provider-neutral TypeScript boundary for agent memory: the `AgentMemoryEvent v1` model, deterministic ids, scope filters, idempotent writes and semantic recall. Use it to build a native integration for another runtime; see the [Agent Memory Event Contract](../learn/agent-memory/event-contract.mdx).

Recall is a vector search. On RushDB Cloud, memories are embedded for you. On a self-hosted engine, the integrations need an embedding model of your own: the native providers take an OpenAI-compatible endpoint, and the contract takes an `embedder`:

```typescript

const memory = new RushDBAgentMemory({
  engineUrl: 'http://127.0.0.1:3000',
  engineToken: process.env.RUSHDB_ENGINE_TOKEN,
  embedder: {
    dimensions: 1536,
    embed: async (texts) =>
      (await openai.embeddings.create({ model: 'text-embedding-3-small', input: texts })).data.map((d) => d.embedding)
  }
})

await memory.ensureIndexes() // creates external indexes of the embedder's dimensions
```

At the start of each agent session:

1. Call `getSchemaMarkdown` to discover the live schema.
2. Recall the latest `SESSION` and relevant `DECISION`, `TASK`, or `PREFERENCE` records.
3. Create a new `SESSION`.

Before the session ends:

1. Store decisions, tasks, observations, and artifacts.
2. Link them to the session through nested JSON or relationships.
3. Confirm the stored summary.

## Verify

Ask your agent:

> Search RushDB for `SESSION` records. Show the most recent one and summarize any linked decisions or tasks.

If you have not bootstrapped memory yet, use the [Agent Memory Quickstart](../learn/agent-memory/quickstart.mdx) first.

## Next steps

- [Agent Memory Quickstart](../learn/agent-memory/quickstart.mdx)
- [Schema Self-Awareness](../learn/agent-memory/schema-self-awareness.mdx)
- [Agent-Safe Query Planning](../learn/tutorials/agent-memory/agent-safe-query-planning.mdx)
- [Using RushDB Agent Skills in OpenClaw](../learn/tutorials/agent-memory/agent-skills-with-openclaw.mdx)
- [Agent Memory Event Contract](../learn/agent-memory/event-contract.mdx)
