# MCP server

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

Give an AI assistant direct access to your RushDB data without writing integration code. The RushDB MCP server (`@rushdb/mcp-server`) runs in three ways:

| Mode                                                         | Best for                        | Connects to        | Setup                   |
| ------------------------------------------------------------ | ------------------------------- | ------------------ | ----------------------- |
| [Hosted OAuth](#hosted-oauth-no-installation)                | ChatGPT, Claude.ai, web clients | RushDB Cloud       | Add one URL and sign in |
| [Local, Cloud API key](#local-mcp-api-key)                   | Claude Desktop, Cursor, VS Code | RushDB Cloud       | Add an MCP config block |
| [Local, self-hosted engine](#self-hosted-engine-direct-mode) | Claude Desktop, Cursor, VS Code | Your own `rushdb` engine | Add an MCP config block |

Reference: [MCP Server Reference](../learn/reference/mcp/index.mdx) · [All MCP Tools](../learn/reference/mcp/tools.mdx)

---

## Hosted OAuth: No installation

Use this endpoint:

```
https://mcp.rushdb.com/mcp
```

### ChatGPT

1. Open **Settings → Connectors → Add connector**.
2. Enter `https://mcp.rushdb.com/mcp`.
3. Sign in with your RushDB account.
4. Choose the project to expose.

### Claude.ai

1. Open **Settings → Integrations → Add integration**.
2. Enter `https://mcp.rushdb.com/mcp`.
3. Authorize with your RushDB account.
4. Choose the project to expose.

:::caution
Always include `/mcp`. The root domain does not serve the MCP protocol.
:::

### Permissions

The consent screen asks which access to grant the client:

| Choice | OAuth scope | Tools the client gets |
| --- | --- | --- |
| Read records | `records:read` | The read tools only: schema discovery, queries, search and export |
| Read & write records | `records:write` | Every tool. A token granted `records:write` also carries `records:read` |

Every tool call needs a token: the endpoint rejects a call without one, read tools included. Each tool declares the scope it needs in its `securitySchemes`, so clients that compare it with the token's scope show only the tools the token allows.

Each tool also carries MCP annotations that tell the client whether it reads, writes or overwrites data. Clients that honor them may ask you to confirm a call first, including updates such as `updateRecord`, because an update overwrites values. See [Safety levels](../learn/reference/mcp/tools.mdx#safety-levels).

---

## Local MCP: RushDB Cloud API key {#local-mcp-api-key}

Get an API key at [app.rushdb.com](https://app.rushdb.com), add the relevant configuration, then restart your client.

### Claude Desktop

Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "rushdb": {
      "command": "npx",
      "args": ["-y", "@rushdb/mcp-server"],
      "env": {
        "RUSHDB_API_KEY": "your-api-key-here"
      }
    }
  }
}
```

### Cursor

Add `.cursor/mcp.json` in your project:

```json
{
  "mcpServers": {
    "rushdb": {
      "command": "npx",
      "args": ["-y", "@rushdb/mcp-server"],
      "env": {
        "RUSHDB_API_KEY": "your-api-key-here"
      }
    }
  }
}
```

### VS Code: Copilot agent mode

Add `.vscode/mcp.json`:

```json
{
  "servers": {
    "rushdb": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@rushdb/mcp-server"],
      "env": {
        "RUSHDB_API_KEY": "your-api-key-here"
      }
    }
  }
}
```

---

## Self-hosted engine: Direct mode {#self-hosted-engine-direct-mode}

Direct mode connects a local stdio MCP client to a RushDB engine you run. It needs no RushDB Cloud account, API key, dashboard or OAuth. Start the engine:

```bash
rushdb up
```

A local `rushdb up` listens on `http://127.0.0.1:3000` and accepts the token `local-token`. Configure the MCP server with that URL and token:

```json
{
  "mcpServers": {
    "rushdb": {
      "command": "npx",
      "args": ["-y", "@rushdb/mcp-server"],
      "env": {
        "RUSHDB_MODE": "direct",
        "RUSHDB_ENGINE_URL": "http://127.0.0.1:3000",
        "RUSHDB_ENGINE_TOKEN": "local-token"
      }
    }
  }
}
```

The `mcpServers` block above works in Claude Desktop and Cursor. [Get started](../index.mdx#2-connect-an-mcp-client) has the one-line commands for Claude Code (`claude mcp add`) and Codex (`codex mcp add`), the VS Code file, and the config path of each client.

To use your own token, start the engine with it and put the same value in `RUSHDB_ENGINE_TOKEN`. Use your own token whenever something other than your own machine can reach the engine, and always in Docker, where the engine refuses the default token:

```bash
export RUSHDB_TOKEN="$(openssl rand -hex 32)"
rushdb up
echo "$RUSHDB_TOKEN"   # the value for RUSHDB_ENGINE_TOKEN
```

Direct mode offers every tool whose work the engine does:
- schema discovery;
- record reads and writes, with ordering, projections and aggregations;
- relationships, labels and properties;
- bulk import and CSV export;
- text indexes and keyword search;
- external vector indexes, with vector and hybrid search by a `queryVector` you supply.

The RushDB Cloud tools are not listed, and are refused if called: `smartSearch` (natural-language search), the relationship-pattern tools, and anything that needs managed embeddings (a text `query` for vector search, managed indexes).

Direct mode runs over stdio only, on the same machine as the client: the MCP HTTP transport authenticates through RushDB Cloud's OAuth.

---

## Verify the connection

Ask your assistant:

> Call `getSchemaMarkdown` and show me what labels exist in my RushDB project.

A new project or engine returns an empty schema. That still confirms the connection works.

---

## Mandatory workflow

RushDB MCP exposes a discovery-first workflow so agents query the schema that exists instead of guessing labels, fields, or operators:

1. Call `getSchemaMarkdown` at the start of a session. It returns labels, property names and types, value ranges, and relationships.
2. Classify the request as a listing, aggregation, traversal, keyword or semantic search, or mutation.
3. Call `getSearchQuerySpec` before building queries with dates, metrics, `groupBy`, relationship traversal, or vector search.
4. Use the discovered label and property names exactly as returned. Labels are case-sensitive.

Clients with MCP Prompts support can fetch `rushdb.queryBuilder` at session start. Other clients can call `getQueryBuilderPrompt` for the same instructions.

## Local configuration reference

| Variable              | Mode   | Required | Default                         | Description                                          |
| --------------------- | ------ | -------- | ------------------------------- | ---------------------------------------------------- |
| `RUSHDB_API_KEY`      | Cloud  | yes      | —                               | RushDB Cloud API key                                 |
| `RUSHDB_API_URL`      | Cloud  | no       | `https://api.rushdb.com/api/v1` | A RushDB Cloud API endpoint other than the default   |
| `RUSHDB_MODE`         | Direct | yes      | —                               | Set to `direct`                                      |
| `RUSHDB_ENGINE_URL`   | Direct | yes      | —                               | The engine's base URL, e.g. `http://127.0.0.1:3000`  |
| `RUSHDB_ENGINE_TOKEN` | Direct | yes      | —                               | The engine token                                     |
| `RUSHDB_ENGINE_SCOPE` | Direct | no       | —                               | The tenant, on an engine started with `--multitenant` |

:::tip Security
Treat `RUSHDB_API_KEY` and `RUSHDB_ENGINE_TOKEN` like passwords. Inject them through your MCP client or an OS keychain, and do not commit them to version control.
:::

## Essential tools

| Need                                   | Start with                                                                              |
| -------------------------------------- | --------------------------------------------------------------------------------------- |
| Discover a schema                      | `getSchemaMarkdown`, `getSchema`                                                        |
| Build a precise query                  | `getSearchQuerySpec`, `findRecords`                                                     |
| Read or write records                  | `getRecord`, `createRecord`, `updateRecord`, `setRecord`                                |
| Connect records                        | `findRelationships`, `attachRelation`, `detachRelation`                                 |
| Work in batches                        | `bulkCreateRecords`, `bulkDeleteRecords`, `exportRecords`                               |
| Keyword search                         | `createTextIndex`, `listTextIndexes`, `textSearch`                                      |
| Vector and hybrid search               | `findEmbeddingIndexes`, `createEmbeddingIndex`, `vectorSearch`                          |
| Natural-language search [Cloud]        | `smartSearch`                                                                           |
| Review inferred graph structure [Cloud] | `listRelationshipPatterns`, `analyzeRelationshipPatterns`, `approveRelationshipPattern` |

Each MCP tool publishes its input schema to the connected client. See [All MCP Tools](../learn/reference/mcp/tools.mdx) for the complete catalog.

## Troubleshooting

| Symptom                                  | Check                                                                                                      |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| Hosted connector cannot discover actions | Confirm the URL is `https://mcp.rushdb.com/mcp`, including `/mcp`, then remove and recreate the connector. |
| Hosted connector lists only read tools   | The connector was granted **Read records**. Remove it, add it again and choose **Read & write records**.   |
| The client asks to confirm every update  | Expected: update, replace and delete tools are marked destructive. The client's own settings decide when it asks. |
| Local MCP reports a missing API key      | Set `RUSHDB_API_KEY` in the MCP client's `env` block and restart the client.                               |
| Direct mode cannot reach the engine      | Check `RUSHDB_ENGINE_URL` with `curl $RUSHDB_ENGINE_URL/health`, and that the token matches the engine's.  |
| A tool is missing in direct mode         | It needs RushDB Cloud; see the [tool catalog](../learn/reference/mcp/tools.mdx).                           |
| A query uses the wrong label or property | Call `getSchemaMarkdown` again and use the case-sensitive names it returns.                                |
| A structured query fails validation      | Call `getSearchQuerySpec` and rebuild the query from the documented operators.                             |

---

## Make the agent more effective

Install [RushDB Agent Skills](./skills.mdx) after the MCP connection. Skills teach the agent discovery-first querying, graph modeling, faceted search, and persistent memory patterns.

## Next steps

- [Browse the complete MCP tools reference](../learn/reference/mcp/tools.mdx)
- [Install Agent Skills](./skills.mdx)
- [Bootstrap persistent agent memory](../learn/agent-memory/quickstart.mdx)
- [Use RushDB with AI agents](./agents.mdx)
