Skip to main content
Glama

query

Execute SurrealQL queries to interact with SurrealDB databases for complex operations like SELECT with JOINs, schema definitions, transactions, and graph traversals.

Instructions

Execute one or more SurrealQL queries against the connected SurrealDB database.

This tool allows you to run any valid SurrealQL queries directly. Use this for complex queries that don't fit the other tool patterns, such as:

  • Complex SELECT queries with JOINs, GROUP BY, or aggregations

  • Custom DEFINE statements for schemas

  • Transaction blocks with BEGIN/COMMIT

  • Graph traversal queries

Queries are executed sequentially. If a query fails, execution continues with the remaining queries, and the error is captured in that query's result.

Args: queries: A list of SurrealQL queries to execute. Examples: - ["SELECT * FROM user WHERE age > 18"] - ["SELECT * FROM user", "SELECT * FROM product"] - ["CREATE user:alice SET name = 'Alice'", "CREATE user:bob SET name = 'Bob'"] namespace: Optional SurrealDB namespace override. If not provided, uses SURREAL_NAMESPACE env var. database: Optional SurrealDB database override. If not provided, uses SURREAL_DATABASE env var.

Returns: A dictionary containing: - success: Boolean indicating if at least one query executed successfully - results: Array of per-query results, each containing: - success: Boolean indicating if this specific query succeeded - data: The query results (only present on success) - error: Error message (only present on failure) - total: Total number of queries executed - succeeded: Number of queries that succeeded - failed: Number of queries that failed

Example: >>> await query(["SELECT * FROM user", "SELECT * FROM product"]) { "success": true, "results": [ {"success": true, "data": [{"id": "user:1", "name": "Alice"}]}, {"success": true, "data": [{"id": "product:1", "name": "Laptop"}]} ], "total": 2, "succeeded": 2, "failed": 0 }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queriesYes
namespaceNo
databaseNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and delivers well. It discloses key behavioral traits: queries execute sequentially, failure doesn't stop execution (error captured per query), and namespace/database fallback to environment variables. It doesn't mention authentication needs, rate limits, or side effects, but covers execution flow thoroughly.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured and appropriately sized. Front-loaded with purpose and usage guidelines, followed by parameter details, return format, and example. Every sentence earns its place: no fluff, clear sections with headings (Args, Returns, Example). Efficient communication of complex functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 3 parameters with 0% schema coverage, no annotations, but with output schema (Returns section), the description is complete. It explains all parameters thoroughly, describes execution behavior, provides usage guidance versus siblings, and documents the return structure. The example solidifies understanding. No gaps for a general-purpose query tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate fully. It does: each parameter (queries, namespace, database) is explained with meaning, optionality, defaults, and examples. The 'queries' parameter gets extensive examples showing array usage and query types. This adds significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool 'Execute one or more SurrealQL queries against the connected SurrealDB database' with specific verb ('Execute') and resource ('SurrealQL queries'). It distinguishes from siblings by mentioning 'complex queries that don't fit the other tool patterns' and listing specific sibling-incompatible use cases like JOINs, DEFINE statements, and transactions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance is provided: 'Use this for complex queries that don't fit the other tool patterns' with concrete examples (SELECT with JOINs, DEFINE, transactions, graph traversal). This clearly indicates when to use this tool versus the simpler sibling tools like select, create, update, etc.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lfnovo/surreal-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server