Skip to main content
SurrealDB tool enables agents to interact with multi-model databases, supporting document, graph, and relational data through native SurrealQL queries.
The user asks a data question; SurrealDB tools let the agent query and update records safely.

Installation

Environment Variables

Quick Start

1

Simple Agent Usage

2

Direct Tool Usage

Available Methods

query(sql)

Execute a SurrealQL query.

create(table, data)

Create a new record in a table.

select(table, conditions=None)

Select records from a table.

Multi-Model Examples

Document Data

Graph Data

Relational Data

Configuration Options

Connection URLs

Different connection formats supported:

Function-Based Usage

Docker Setup

Basic SurrealDB Server

Never use default credentials (root/root) in production. Always use strong, unique passwords and environment variables for security.

With Persistent Storage

Production Setup

Authentication

Connection Pooling

Advanced Features

Transactions

Real-time Subscriptions

Geospatial Queries

Error Handling

Common Errors

Performance Tips

  1. Use Prepared Statements: For repeated queries, use parameterized queries
  2. Batch Operations: Group multiple operations in transactions
  3. Index Strategy: Create indexes on frequently queried fields
  4. Connection Reuse: Reuse connections instead of creating new ones

SurrealQL Quick Reference

Data Types

  • Basic: string, number, boolean, datetime
  • Complex: object, array, geometry, duration
  • Special: thing (record ID), uuid, bytes

Common Operations

PostgreSQL

Relational database

MongoDB

Document database

Redis

Key-value store

MySQL

Relational database

SQLite

Embedded database

Best Practices

Leverage SurrealDB’s multi-model capabilities for complex data — combine documents, graphs, and relations in one schema instead of forcing everything into a single model.
Use namespaces to separate environments (dev, staging, prod) so agents and tools never cross wires between datasets.
Always use authentication in production environments; avoid root credentials in agent-facing tools.
Set up monitoring for query performance and resource usage, especially when agents run ad hoc SurrealQL.
Implement regular backups for persistent storage setups before relying on agents for write-heavy workflows.

Community & Support