MCP server
by lfnovo
SurrealDB is a versatile graph database supporting graph, document, and relational data with powerful query and bulk man
Connects AI assistants to SurrealDB's multi-model database for executing queries and managing data across graph, document, and relational paradigms.
SurrealDB is a community-built MCP server published by lfnovo that provides AI assistants with tools and capabilities via the Model Context Protocol. SurrealDB is a versatile graph database supporting graph, document, and relational data with powerful query and bulk man It is categorized under databases.
You can install SurrealDB in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
MIT
SurrealDB is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
Enable Claude to query your database directly using natural language
Example
Ask 'Show me top 10 customers by revenue this month' and get SQL results instantly
Eliminate manual SQL writing for ad-hoc queries, get insights 10x faster
Generate complex reports and analytics without leaving conversation
Example
Analyze sales trends, cohort retention, user behavior patterns conversationally
Democratize data access—non-technical team members can query databases
Understand database structure, relationships, and data models
Example
'Explain the user_orders table schema and its relationships'
Onboard engineers faster, explore unfamiliar databases efficiently
Share your MCP server with the developer community
According to our notes, SurrealDB benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.
We wired SurrealDB into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.
SurrealDB is among the better-indexed MCP projects we tried; the explainx.ai summary tracks the official description.
SurrealDB has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
Strong directory entry: SurrealDB surfaces stars and publisher context so we could sanity-check maintenance before adopting.
Strong directory entry: SurrealDB surfaces stars and publisher context so we could sanity-check maintenance before adopting.
SurrealDB has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
SurrealDB is a well-scoped MCP server in the explainx.ai directory — install snippets and categories matched our Claude Code setup.
We evaluated SurrealDB against two servers with overlapping tools; this profile had the clearer scope statement.
SurrealDB reduced integration guesswork — categories and install configs on the listing matched the upstream repo.
showing 1-10 of 35
A Model Context Protocol (MCP) server that enables AI assistants to interact with SurrealDB databases
</div> <a href="https://glama.ai/mcp/servers/@lfnovo/surreal-mcp"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@lfnovo/surreal-mcp/badge" alt="surreal-mcp MCP server" /> </a>The SurrealDB MCP Server bridges the gap between AI assistants and SurrealDB, providing a standardized interface for database operations through the Model Context Protocol. This enables LLMs to:
# Run directly from PyPI (once published)
uvx surreal-mcp
# Or run from GitHub
uvx --from git+https://github.com/yourusername/surreal-mcp.git surreal-mcp
# Clone the repository
git clone https://github.com/yourusername/surreal-mcp.git
cd surreal-mcp
# Install dependencies
uv sync
# Run the server (multiple ways)
uv run surreal-mcp
# or
uv run python -m surreal_mcp
# or
uv run python main.py
# Clone the repository
git clone https://github.com/yourusername/surreal-mcp.git
cd surreal-mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install package
pip install -e .
# Run the server
surreal-mcp
# or
python -m surreal_mcp
The server uses environment variables for configuration.
| Variable | Description | Example |
|---|---|---|
SURREAL_URL | SurrealDB connection URL | ws://localhost:8000/rpc |
SURREAL_USER | Database username | root |
SURREAL_PASSWORD | Database password | root |
| Variable | Description | Example |
|---|---|---|
SURREAL_NAMESPACE | Default SurrealDB namespace | test |
SURREAL_DATABASE | Default SurrealDB database | test |
Note: If
SURREAL_NAMESPACEandSURREAL_DATABASEare not set as environment variables, you must providenamespaceanddatabaseparameters in each tool call.
You can copy .env.example to .env and update with your values:
cp .env.example .env
# Edit .env with your database credentials
Or set them manually:
export SURREAL_URL="ws://localhost:8000/rpc"
export SURREAL_USER="root"
export SURREAL_PASSWORD="root"
export SURREAL_NAMESPACE="test"
export SURREAL_DATABASE="test"
Add to your MCP client settings (e.g., Claude Desktop):
Using uvx (recommended):
{
"mcpServers": {
"surrealdb": {
"command": "uvx",
"args": ["surreal-mcp"],
"env": {
"SURREAL_URL": "ws://localhost:8000/rpc",
"SURREAL_USER": "root",
"SURREAL_PASSWORD": "root",
"SURREAL_NAMESPACE": "test",
"SURREAL_DATABASE": "test"
}
}
}
}
Using local installation:
{
"mcpServers": {
"surrealdb": {
"command": "uv",
"args": ["run", "surreal-mcp"],
"env": {
"SURREAL_URL": "ws://localhost:8000/rpc",
"SURREAL_USER": "root",
"SURREAL_PASSWORD": "root",
"SURREAL_NAMESPACE": "test",
"SURREAL_DATABASE": "test"
}
}
}
}
All tools support optional namespace and database parameters to override the default values from environment variables.
Execute raw SurrealQL queries for complex operations.
-- Example: Complex query with graph traversal
SELECT *, ->purchased->product FROM user WHERE age > 25
# Query with namespace/database override
query("SELECT * FROM user", namespace="production", database="main")
Retrieve all records from a table or a specific record by ID.
# Get all users
select("user")
# Get specific user
select("user", "john")
# Select from a different database
select("user", namespace="other_ns", database="other_db")
Create a new record with auto-generated ID.
create("user", {
"name": "Alice",
"email": "alice@example.com",
"age": 30
})
Replace entire record content (preserves ID and timestamps).
update("user:john", {
"name": "John Smith",
"email": "john.smith@example.com",
"age": 31
})
Permanently remove a record from the database.
delete("user:john")
Partially update specific fields without affecting others.
merge("user:john", {
"email": "newemail@example.com",
"verified": True
})
Apply JSON Patch operations (RFC 6902) to records.
patch("user:john", [
{"op": "replace", "path": "/email", "value": "new@example.com"},
{"op": "add", "path": "/verified", "value": True}
])
Create or update a record with specific ID.
upsert("settings:global", {
"theme": "dark",
"language": "en"
})
Bulk insert multiple records efficiently.
insert("product", [
{"name": "Laptop", "price": 999.99},
{"name": "Mouse", "price": 29.99},
{"name": "Keyboard", "price": 79.99}
])
Create graph relationships between records.
relate(
"user:john", # from
"purchased", # relation name
"product:laptop-123", # to
{"quantity": 1, "date": "2024-01-15"} # relation data
)
# Create a user
user = create("user", {"name": "Alice", "email": "alice@example.com"})
# Update specific fields
merge(user["id"], {"verified": True, "last_login": "2024-01-01"})
# Query with conditions
results = query("SELECT * FROM user WHERE verified = true ORDER BY created DESC")
# Delete when done
delete(user["id"])
# Create entities
user = create("user", {"name": "John"})
product = create("product", {"name": "Laptop", "price": 999})
# Create relationship
relate(user["id"], "purchased", product["id"], {
"quantity": 1,
"total": 999,
"date": "2024-01-15"
})
# Query relationships
purchases = query(f"SELECT * FROM {user['id']}->purchased->product")
# Insert multiple records
products = insert("product", [
{"name": "Laptop", "category": "Electronics", "price": 999},
{"name": "Mouse", "category": "Electronics", "price": 29},
{"name": "Desk", "category": "Furniture", "price": 299}
])
# Bulk update with query
query("UPDATE product SET on_sale = true WHERE category = 'Electronics'")
<<<<<<< HEAD
=======
You can work with multiple databases in a single session by using the namespace and database parameters:
# Create a record in the production database
create("user", {"name": "Alice"}, namespace="prod", database="main")
# Query from staging database
select("user", namespace="staging", database="main")
# Copy data between databases
users = select("user", namespace="staging", database="main")
for user in users["data"]:
create("user", user, namespace="prod", database="main")
Behavior Summary:
| Scenario | Result |
|---|---|
| Env vars set, no params | Uses pooled connection (best performance) |
| Env vars set, params provided | Uses override connection with specified namespace/database |
| No env vars, params provided | Uses override connection with specified namespace/database |
| No env vars, no params | Fails with clear error message |
main
The server is built with:
The project includes a comprehensive test suite using pytest.
# Make sure SurrealDB is running
surreal start --user root --pass root
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=surreal_mcp
# Run specific test file
uv run pytest tests/test_tools.py
# Run specific test class o
---
Run data quality queries to catch anomalies and inconsistencies
Example
Find duplicate records, missing values, orphaned foreign keys automatically
Maintain data integrity with less manual SQL work
Prerequisites
Time Estimate
15-30 minutes including configuration and testing
Steps
Troubleshooting
✓ Do
✗ Don't
💡 Pro Tips
Architecture
MCP server acts as bridge between Claude and database, translating natural language to SQL queries and returning results in structured format.
Protocols
Compatibility
✓ Use when
Use for ad-hoc data queries, exploratory analysis, report generation, schema exploration, and democratizing data access. Best for read-heavy analytics workloads.
✗ Avoid when
Avoid for production write operations, mission-critical transactions, real-time OLTP workloads, or when database contains sensitive PII without proper access controls. Use read replicas, not primary.