Skip to main content
Glama

runSql

runSql

[ExoBench server version: 1.4.29]

⚠️ EPHEMERAL DATABASE — READ THIS FIRST ⚠️

Each call provisions a fresh database from schema and DESTROYS it on return. Tables, data, indexes, and settings from previous calls are GONE. correlationId is for tracking only — it does NOT preserve DB state. Pass the FULL schema (CREATE TABLE + INSERT) in EVERY call. If the user expects persistence, tell them ExoBench has none.

ExoBench: Execute raw SQL queries against an ephemeral database initialized with the provided schema. Returns query results in a simple JSON format with column headers and row data as a 2D array.

The database type is specified via the databaseType parameter:

  • POSTGRES: Temporary isolated schema with dedicated user, uses PostgreSQL syntax and features (Postgres 17, the default)

  • POSTGRES_18: Same as POSTGRES but runs against a Postgres 18 pool; use it to compare a query's plan and timing on 18 vs POSTGRES (17), e.g. B-tree skip scan, uuidv7(), virtual generated columns

  • SQLSERVER: Temporary isolated schema, uses T-SQL syntax and features

  • MYSQL: Temporary isolated database, uses MySQL syntax and features

  • SQLITE: In-memory, lightweight, uses standard SQLite syntax

WHEN TO USE: When you need to run your own hand-written SQL queries to test database behavior or compare the output with ExoQuery results from validateAndRunKotlinExoQuery. This lets you verify that ExoQuery-generated SQL produces the same results as your expected SQL.

INPUT REQUIREMENTS:

  • query: A valid SQL query (SELECT, INSERT, UPDATE, DELETE, etc.)

  • schema: SQL schema with CREATE TABLE and INSERT statements to initialize the test database

  • databaseType: POSTGRES, POSTGRES_18, SQLSERVER, MYSQL, or SQLITE (defaults to POSTGRES if not specified)

OUTPUT FORMAT:

On success, returns JSON with the SQL query, the seed the run used, and a 2D array of results: {"sql":"SELECT * FROM users ORDER BY id","seed":2215213096,"seedSource":"default","output":[["id","name","age"],["1","Alice","30"],["2","Bob","25"],["3","Charlie","35"]]}

Output format details:

  • First array element contains column headers

  • Subsequent array elements contain row data

  • All values are returned as strings

  • seed/seedSource: the seed every random function ran under (default = derived from correlationId); pass it back as seed to reproduce

On error, returns JSON with error message and the attempted query (if available): {"error":"Query execution failed: no such table: USERS","sql":"SELECT * FROM USERS"}

Or if schema initialization fails: {"error":"Database initialization failed due to: near "CREAT": syntax error\nWhen executing the following statement:\n--------\nCREATE TABLE users ...\n--------","sql":"CREATE TABLE users ..."}

EXAMPLE INPUT:

Query: SELECT * FROM users ORDER BY id

Schema: CREATE TABLE users ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, age INTEGER );

INSERT INTO users (id, name, age) VALUES (1, 'Alice', 30); INSERT INTO users (id, name, age) VALUES (2, 'Bob', 25); INSERT INTO users (id, name, age) VALUES (3, 'Charlie', 35);

(The success and error outputs for this input are the ones shown under OUTPUT FORMAT.)

More query examples, full error-output examples, and how seeding works per engine: getMcpDocs('run-sql').

SCHEMA RULES:

  • Use the syntax of the selected databaseType

  • Table names are case-sensitive (use lowercase for simplicity or quote names)

  • Include INSERT statements to populate test data for meaningful results

  • Schema SQL is split on semicolons (;), so each statement after a ';' is executed separately

  • Avoid semicolons in comments as they will cause statement parsing issues

COMPARISON WITH EXOQUERY: This tool is designed to work alongside validateAndRunKotlinExoQuery for comparison purposes:

  1. Use validateAndRunKotlinExoQuery to run ExoQuery Kotlin code and see the generated SQL + results

  2. Use runSql with your own hand-written SQL to verify you get the same output

  3. Compare the outputs to ensure ExoQuery generates the SQL you expect

  4. Test edge cases with plain SQL before writing equivalent ExoQuery code

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>",
      "schema": "<schema>"
    },
    "name": "runSql"
  }
}

Input Schema

NameRequiredDescriptionDefault
seedNoInteger seed for the SQL's random functions (Postgres setseed, SQL Server RAND(seed)). Omitted: the DEFAULT_SEED is derived from correlationId, so one session reuses the same data. Returned as seed/seedSource.
queryYes A valid SQL query to execute against the database. Can be any valid SQL statement (syntax depends on databaseType parameter — Postgres, SQL Server, MySQL, or SQLite): - SELECT queries (with WHERE, JOIN, GROUP BY, ORDER BY, LIMIT, etc.) - INSERT statements - UPDATE statements - DELETE statements - DDL statements like CREATE/ALTER/DROP (applied after schema initialization) The query will be executed against a database initialized with the provided schema parameter. ${SCHEMA} = the run's schema name (SQL Server scalar UDF: ${SCHEMA}.fn(x)). Example: SELECT * FROM users WHERE age > 25 ORDER BY name
schemaYes SQL schema to initialize the ephemeral test database. Must include: 1. CREATE TABLE statements for all tables used in the query 2. INSERT statements with test data Use syntax appropriate for the selected databaseType (Postgres, SQL Server, MySQL, or SQLite). Table names are case-sensitive. The schema is split on semicolons, so each statement is executed separately. Example: CREATE TABLE users ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, age INTEGER ); INSERT INTO users (id, name, age) VALUES (1, 'Alice', 30); INSERT INTO users (id, name, age) VALUES (2, 'Bob', 25); INSERT INTO users (id, name, age) VALUES (3, 'Charlie', 35);
databaseTypeNo Database type to use for query execution. Must be POSTGRES, POSTGRES_18, SQLSERVER, MYSQL, or SQLITE. Defaults to POSTGRES if not specified. - POSTGRES: Temporary isolated schema with dedicated user, uses PostgreSQL syntax and features (Postgres 17, the default) - POSTGRES_18: Same as POSTGRES but runs against a Postgres 18 pool; use it to compare a query's plan and timing on 18 vs POSTGRES (17), e.g. B-tree skip scan, uuidv7(), virtual generated columns - SQLSERVER: Temporary isolated schema, uses T-SQL syntax and features - MYSQL: Temporary isolated database, uses MySQL syntax and features - SQLITE: In-memory, lightweight, uses standard SQLite syntax Choose based on: - Your target deployment database - Specific SQL dialect features you need to test (e.g. T-SQL TOP vs LIMIT, IDENTITY vs SERIAL)
correlationIdNo [TRACKING ONLY — does NOT preserve DB state, schema, or settings between calls.] Echo the correlationId from the previous ExoBench response so the ExoBench team can correlate your workflow for analytics. Omitted = a new one is created. Each tool call still provisions a fresh ephemeral DB from its own schema parameter.
customDelimiterNo LAST RESORT ONLY — Do NOT use this parameter unless all other approaches have failed. ExoBench has a highly robust, dialect-aware SQL script splitter that correctly handles: - Single-quoted string literals (including '' escape sequences) - Double-quoted identifiers (PostgreSQL, SQL Server) - Bracket-quoted identifiers (SQL Server: [col;name]) - Backtick-quoted identifiers (MySQL: `col;name`) - Dollar-quoted function bodies (PostgreSQL: $$ ... $$ and $tag$ ... $tag$) - Line comments (-- comment; still in comment) - Block comments (/* nested /* block */ comments */ supported for all dialects except MySQL) - MySQL hash comments (# comment; to end of line) - MySQL's -- comment rule (requires whitespace after the dashes) In the vast majority of cases, you do NOT need this parameter. The splitter handles all standard SQL constructs including stored procedures, triggers, and functions that contain semicolons within their bodies. If you encounter a GENUINE splitting failure (the schema executes incorrectly because a semicolon inside a construct was misinterpreted as a delimiter), you may set customDelimiter to a unique string that does NOT appear inside any of your SQL statements. The system will then split ONLY on that string — with NO intelligence about quoting or comments. You are fully responsible for ensuring the delimiter is truly unique in your script. Example: If your schema has a pathological construct that confuses the splitter, you could separate statements with '---SPLIT---' and set customDelimiter to '---SPLIT---'. DO NOT use this to work around issues that the splitter already handles. If you think the splitter is failing on a standard construct, it is almost certainly a bug — report it instead of using this escape hatch.
exobenchServerVersionNoExoBench server version — copy the X.X.X from the [ExoBench server version: X.X.X] tag at the top of this tool's description.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only say readOnly=false, destructive=false, idempotent=false, which is not enough for a SQL-execution tool; the description adds the crucial behavioral fact that state is ephemeral and destroyed on every return, that correlationId does not preserve it, and that the full schema must be resent each call. It also documents the seeding/reproducibility mechanism and both success and error payload shapes, none of which the annotations convey. The 'destroyed' language does not contradict destructiveHint=false because the tool destroys only the sandbox it provisioned itself, not user-owned data.

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

Conciseness3/5

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

The critical ephemeral warning is correctly front-loaded and the sections are well labeled, but the description is very long and repeats the databaseType bullet list (including the POSTGRES_18 explanation) verbatim from the schema, and repeats parameter definitions in an INPUT REQUIREMENTS list. Those blocks are duplicate content rather than added value, adding bulk an agent must parse on every call.

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?

For a 7-parameter tool with no output schema, the description supplies everything an agent needs: return-value layout (header row + stringified rows), error payload variants, schema-splitting rules and their semicolon caveat, case sensitivity, and per-dialect differences. Nothing material about correct invocation is left undocumented.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3; the description earns extra by explaining intent the schema cannot: correlationId is tracking-only and must not be relied on for persistence, seed reproduces the run's random values, and customDelimiter is an explicitly discouraged last-resort escape hatch. The only deduction is that the 'INPUT REQUIREMENTS' section largely restates the parameter list already in the 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 opens with a concrete verb+resource ("Execute raw SQL queries against an ephemeral database initialized with the provided schema") and immediately distinguishes this tool from validateAndRunKotlinExoQuery as the hand-written-SQL counterpart. An agent can tell exactly what this does and what its sibling does differently without opening either schema.

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?

There is an explicit "WHEN TO USE" block plus a numbered 4-step comparison workflow with validateAndRunKotlinExoQuery, and a pointer to getMcpDocs('run-sql') for deeper material. The engine-selection guidance ("use POSTGRES_18 to compare plan and timing on 18 vs 17") is a concrete usage condition rather than a vague hint.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources