Skip to main content
Glama

Run SQL

query
Read-onlyIdempotent

Run one SQL statement to answer data questions: select columns, join tables, filter, sort, and group rows. Read-only unless writes are enabled; returns rows or affected counts.

Instructions

Run exactly ONE SQL statement — the general tool for answering questions: specific columns, JOINs (follow fk from describe), filters, sorting, GROUP BY. Read-only connections accept only SELECT/SHOW/DESCRIBE/EXPLAIN/WITH/VALUES/TABLE (+PRAGMA on SQLite); multiple statements are refused. Prefer sample/count for simple peeks and totals, explain for performance. A LIMIT is added automatically when missing. Returns rows[N]{columns} plus rows, truncated (true = more rows exist — narrow with WHERE or raise limit) and ms; write statements (only if writes are enabled) return affected instead. On failure returns isError with 'error: ' (e.g. refused statement, unknown table, SQL error).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesA single SQL statement in the connection's dialect, without a trailing ';' chain.
limitNoMax rows (default 100; capped by settings, usually 200).
formatNoResult format. Default from settings: toon (compact table: rows[N]{cols}: then one line per row).
databaseNoOptional database to use instead of the connection's default (names from `databases`). Omit to use the default.
connectionYesConnection name exactly as returned by `connections` (e.g. "shop"). Unknown or unexposed names return an error.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv0.2.2
    • changedInput schema / properties / connection / description
      Previous value: -"Connection name (from `connections`)"New value: +"Connection name exactly as returned by `connections` (e.g. \"shop\"). Unknown or unexposed names return an error."
    • changedInput schema / properties / database / description
      Previous value: -"Database name to use instead of the connection's default (optional)"New value: +"Optional database to use instead of the connection's default (names from `databases`). Omit to use the default."
    • changedInput schema / properties / format / description
      Previous value: -"Result format (default from settings: toon)"New value: +"Result format. Default from settings: toon (compact table: rows[N]{cols}: then one line per row)."
    • changedInput schema / properties / limit / description
      Previous value: -"Max rows (default 100, capped by settings)"New value: +"Max rows (default 100; capped by settings, usually 200)."
    • addedInput schema / properties / limit / minimum
      Added value: +1
    • changedInput schema / properties / sql / description
      Previous value: -"A single SQL statement"New value: +"A single SQL statement in the connection's dialect, without a trailing ';' chain."
  2. First observedv0.1.0

TDQS

A4.6/5.0
Behavior4/5

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

With annotations already declaring readOnlyHint/idempotentHint/destructiveHint, the description still adds substantial non-obvious behavior: accepted statement whitelist, multi-statement refusal, automatic LIMIT insertion, truncation flag semantics with remediation ('narrow with WHERE or raise limit'), latency field, and the error envelope ('isError with error: <reason>'). The only blemish is the clause that write statements 'return affected' when writes are enabled, which sits in mild tension with readOnlyHint=true and destructiveHint=false as a static contract.

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

Conciseness4/5

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

Front-loaded with the core action and the tool's role, then layered with constraints, alternatives, return shape, and failure mode in a logical order. Every clause carries information, though the single dense block is long enough that it edges past optimal brevity.

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?

There is no output schema, so the description must carry the return contract itself — and it does: rows[N]{columns} plus rows, the truncated flag and its meaning, ms, affected for writes, and the isError/'error: <reason>' failure format with examples. Combined with the statement whitelist and LIMIT behavior, nothing an agent needs to call this correctly is missing.

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 description coverage is 100%, so the baseline is 3 and the schema already carries most parameter meaning. The description genuinely adds on top: the SQL must be 'in the connection's dialect' without a trailing ';' chain, the `limit` parameter is auto-filled when absent, and the `limit`/truncation interaction is spelled out. That is real semantic value beyond the property descriptions.

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?

States a specific verb and resource ('Run exactly ONE SQL statement') and immediately positions itself as 'the general tool for answering questions'. It names the sibling tools it should not be confused with (`sample`/`count` for peeks and totals, `explain` for performance), so an agent can route correctly without opening any 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?

Explicit when-to-use and when-to-use-something-else: prefer `sample`/`count` for simple peeks and totals, `explain` for performance. It also states the hard constraint (exactly one statement; multiple are refused) and what the read-only connection accepts, which is exactly the decision context an agent needs before choosing this tool.

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