
SurrealDB
STDIOOfficial Model Context Protocol server for SurrealDB database operations and cloud management
Official Model Context Protocol server for SurrealDB database operations and cloud management
SurrealMCP is the official Model Context Protocol (MCP) server for SurrealDB and SurrealDB Cloud that enables AI assistants, AI agents, Developer IDEs, AI chatbots, and data platforms to interact with SurrealDB databases and SurrealDB Cloud.
stdio
, HTTP, and Unix socket connectionsstdio
and OpenTelemetry tracingcargo install --path .
docker run --rm -i --pull always surrealdb/surrealmcp:latest start
SurrealMCP can be integrated with various AI coding tools and assistants to enable AI-powered database operations. Below are installation and configuration instructions for popular AI coding platforms.
Configure Cursor:
Add the SurrealMCP configuration:
{ "name": "SurrealDB", "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "surrealdb/surrealmcp:latest", "start" ] }
{ "name": "SurrealDB", "command": "surrealmcp", "args": ["start"], "env": { "SURREALDB_URL": "ws://localhost:8000/rpc", "SURREALDB_NS": "myapp", "SURREALDB_DB": "production", "SURREALDB_USER": "admin", "SURREALDB_PASS": "password123" } }
Verify installation:
Configure Cline:
Edit the file at: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
Add the following configuration:
{ "mcpServers": { "SurrealDB": { "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "surrealdb/surrealmcp:latest", "start" ], "disabled": false, "autoApprove": [] } } }
{ "mcpServers": { "SurrealDB": { "command": "surrealmcp", "args": ["start"], "env": { "SURREALDB_URL": "ws://localhost:8000/rpc", "SURREALDB_NS": "myapp", "SURREALDB_DB": "production", "SURREALDB_USER": "admin", "SURREALDB_PASS": "password123" }, "disabled": false, "autoApprove": [] } } }
Verify installation:
Configure Claude Desktop:
Edit the Claude Desktop App's MCP settings file:
%APPDATA%\Claude\claude_desktop_config.json
~/Library/Application Support/Claude/claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
Add the following configuration:
{ "mcpServers": { "SurrealDB": { "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "surrealdb/surrealmcp:latest", "start" ], "disabled": false, "autoApprove": [] } } }
{ "mcpServers": { "SurrealDB": { "command": "surrealmcp", "args": ["start"], "env": { "SURREALDB_URL": "ws://localhost:8000/rpc", "SURREALDB_NS": "myapp", "SURREALDB_DB": "production", "SURREALDB_USER": "admin", "SURREALDB_PASS": "password123" }, "disabled": false, "autoApprove": [] } } }
Verify installation:
Configure VSCode:
Create a file at: .vscode/mcp.json
in your workspace
Add the following configuration:
{ "servers": { "SurrealDB": { "type": "stdio", "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "surrealdb/surrealmcp:latest", "start" ] } } }
{ "inputs": [ { "type": "promptString", "id": "surrealdb-url", "description": "SurrealDB URL", "default": "ws://localhost:8000/rpc" }, { "type": "promptString", "id": "surrealdb-ns", "description": "SurrealDB Namespace" }, { "type": "promptString", "id": "surrealdb-db", "description": "SurrealDB Database" }, { "type": "promptString", "id": "surrealdb-user", "description": "SurrealDB Username" }, { "type": "promptString", "id": "surrealdb-pass", "description": "SurrealDB Password", "password": true } ], "servers": { "SurrealDB": { "type": "stdio", "command": "surrealmcp", "args": ["start"], "env": { "SURREALDB_URL": "${input:surrealdb-url}", "SURREALDB_NS": "${input:surrealdb-ns}", "SURREALDB_DB": "${input:surrealdb-db}", "SURREALDB_USER": "${input:surrealdb-user}", "SURREALDB_PASS": "${input:surrealdb-pass}" } } } }
Verify installation:
Configure Roo Code:
Click the MCP icon in the top navigation of the Roo Code pane, then select "Edit MCP Settings" to open the configuration file.
Add the following configuration:
{ "mcpServers": { "SurrealDB": { "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "surrealdb/surrealmcp:latest", "start" ], "disabled": false, "autoApprove": [] } } }
{ "mcpServers": { "SurrealDB": { "command": "surrealmcp", "args": ["start"], "env": { "SURREALDB_URL": "ws://localhost:8000/rpc", "SURREALDB_NS": "myapp", "SURREALDB_DB": "production", "SURREALDB_USER": "admin", "SURREALDB_PASS": "password123" }, "disabled": false, "autoApprove": [] } } }
Verify installation:
Configure Windsurf:
~/.codeium/windsurf/mcp_config.json
)Add the SurrealMCP configuration:
{ "servers": [ { "name": "SurrealDB", "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "surrealdb/surrealmcp:latest", "start" ] } ] }
{ "servers": [ { "name": "SurrealDB", "command": "surrealmcp", "args": ["start"], "env": { "SURREALDB_URL": "ws://localhost:8000/rpc", "SURREALDB_NS": "myapp", "SURREALDB_DB": "production", "SURREALDB_USER": "admin", "SURREALDB_PASS": "password123" } } ] }
Verify installation:
Configure Zed:
Add the SurrealMCP configuration:
Under the context_servers
key, add a new entry:
"surreal": { "source": "custom", "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "surrealdb/surrealmcp:latest", "start" ], "enabled": true, }
"surreal": { "source": "custom", "command": "surrealmcp", "args": ["start"], "enabled": true, "env": { "SURREALDB_URL": "ws://localhost:8000/rpc", "SURREALDB_NS": "myapp", "SURREALDB_DB": "production", "SURREALDB_USER": "admin", "SURREALDB_PASS": "password123" } }
Verify installation:
You can integrate SurrealMCP with n8n using the MCP Client Tool node.
To use SurrealMCP without installing cargo
you can use Docker. SurrealMCP runs locally via stdio with a single Docker command. Instantly start an in-memory or local database at the edge directly from your AI tool, with ephemeral or persisted data.
{ "mcpServers": { "SurrealDB": { "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "surrealdb/surrealmcp:latest", "start" ] } } }
To use SurrealMCP without installing cargo
you can use Docker. SurrealMCP can be run as an HTTP server with a single Docker command. Instantly start an in-memory or local database at the edge directly from your AI tool, with ephemeral or persisted data.
{ "mcpServers": { "SurrealDB": { "command": "docker", "args": [ "run", "--rm", "-p", "8080:8080", "--pull", "always", "surrealdb/surrealmcp:latest", "start", "--bind-address", "127.0.0.1:8080", "--server-url", "http://localhost:8080" ] } } }
# Start as a STDIO server (default) surrealmcp start # Start as a HTTP server surrealmcp start --bind-address 127.0.0.1:8000 # Start as a Unix socket surrealmcp start --socket-path /tmp/surrealmcp.sock
# Database connection surrealmcp start \ --endpoint ws://localhost:8000/rpc \ --ns mynamespace \ --db mydatabase \ --user root \ --pass root # Server configuration surrealmcp start \ --bind-address 127.0.0.1:8000 \ --server-url https://mcp.surrealdb.com \ --cloud-auth-server https://auth.surrealdb.com \ --expected-audience https://custom.audience.com/ \ --rate-limit-rps 100 \ --rate-limit-burst 200 # Disable authentication (for development) surrealmcp start --bind-address 127.0.0.1:8000 --auth-disabled
All configuration options can be set via environment variables:
export SURREALDB_URL="ws://localhost:8000/rpc" export SURREALDB_NS="mynamespace" export SURREALDB_DB="mydatabase" export SURREALDB_USER="root" export SURREALDB_PASS="root" export SURREAL_MCP_BIND_ADDRESS="127.0.0.1:8000" export SURREAL_MCP_SERVER_URL="https://mcp.surrealdb.com" export SURREAL_CLOUD_AUTH_SERVER="https://auth.surrealdb.com" export SURREAL_MCP_EXPECTED_AUDIENCE="https://custom.audience.com/" export SURREAL_MCP_RATE_LIMIT_RPS="100" export SURREAL_MCP_RATE_LIMIT_BURST="200" export SURREAL_MCP_AUTH_REQUIRED="false" export SURREAL_MCP_CLOUD_ACCESS_TOKEN="your_access_token_here" export SURREAL_MCP_CLOUD_REFRESH_TOKEN="your_refresh_token_here" surrealmcp start
The server supports Bearer token authentication with SurrealDB Cloud. When authentication is enabled:
aud
claim against the expected audienceiss
claim against the expected issuerYou can specify a custom expected audience for JWT token validation:
# Set a custom audience surrealmcp start --expected-audience "https://myapp.com/api" # Or via environment variable export SURREAL_MCP_EXPECTED_AUDIENCE="https://myapp.com/api" surrealmcp start
This is useful when:
For SurrealDB Cloud operations, you can provide pre-configured access and refresh tokens instead of fetching them dynamically:
# Set pre-configured tokens surrealmcp start \ --access-token "your_access_token_here" \ --refresh-token "your_refresh_token_here" # Or via environment variables export SURREAL_MCP_CLOUD_ACCESS_TOKEN="your_access_token_here" export SURREAL_MCP_CLOUD_REFRESH_TOKEN="your_refresh_token_here" surrealmcp start
This is useful when:
Note: When both access and refresh tokens are provided, the server will use these tokens for all SurrealDB Cloud API operations instead of attempting to fetch new tokens.
When integrating with the MCP server, clients should:
Discover the authorization configuration:
curl http://localhost:8000/.well-known/oauth-protected-resource
Request a token from the authorization server using the returned audience:
# Example Auth0 token request curl -X POST https://auth.surrealdb.com/oauth/token \ -H "Content-Type: application/json" \ -d '{ "client_id": "your-client-id", "client_secret": "your-client-secret", "audience": "https://custom.audience.com/", "grant_type": "client_credentials" }'
Use the token for authenticated requests:
curl -H "Authorization: Bearer YOUR_TOKEN" \ http://localhost:8000/mcp
The audience value ensures that tokens are issued specifically for the MCP server instance.
SurrealMCP provides a comprehensive set of tools for interacting with SurrealDB databases and SurrealDB Cloud:
memory
, file:/path
, rocksdb:/path
ws://host:port
, http://host:port
cloud:instance_id
The new cloud connection feature allows you to connect directly to SurrealDB Cloud instances using the connect_endpoint
tool with the cloud:instance_id
format:
# Connect to a SurrealDB Cloud instance connect_endpoint('cloud:abc123def456', 'myapp', 'production')
This feature:
curl http://localhost:8000/health
curl http://localhost:8000/.well-known/oauth-protected-resource
This endpoint returns the authorization server configuration including the expected audience:
{ "resource": "https://mcp.surrealdb.com", "authorization_servers": ["https://auth.surrealdb.com"], "bearer_methods_supported": ["header"], "audience": "https://mcp.surrealdb.com/" }
Clients should use the audience
value when requesting tokens from the authorization server.
The server implements the Model Context Protocol and can be used with MCP-compatible clients.
cargo build
cargo test
docker build -t surrealmcp . docker run -p 8000:8000 surrealmcp start --bind-address 0.0.0.0:8000
This project is licensed under the Business Source License.