Skip to main content
Glama

Run a read-only query

run_sql

Execute a single read-only SELECT or WITH query and return up to 50 rows; unsafe or unsupported SQL is refused, and database errors help fix invalid queries.

Instructions

Execute one read-only SELECT or WITH statement and return up to 50 rows. Anything else is refused: several statements, a write, a write inside a CTE, ATTACH, PRAGMA, SET, a row lock. When the database rejects the query you get its own error text back, which is usually enough to fix it.

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>"
    },
    "name": "run_sql"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden and does so well: read-only enforcement, the exact refusal categories, the 50-row cap, and that database errors are surfaced verbatim as self-correcting feedback. It omits auth/permission requirements and how to page past the 50-row limit, which keeps it short of a 5.

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?

Three sentences, front-loaded with the capability and immediately followed by the refusal set and the error-recovery behavior. No filler; each sentence supplies a distinct operational fact.

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

Completeness4/5

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

An output schema exists, so return values need not be described, and the description is complete for a read-only execution tool: it covers enforcement, limits, and failure modes. Only minor operational details (permissions, paging beyond 50 rows) are absent.

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 0% and the single parameter is bare ('query': string), so the description must compensate — and it does by defining what query text is acceptable (a single SELECT or WITH), which is the only semantic that matters here. It does not name the SQL dialect or give example syntax, a minor residual gap for a one-parameter tool.

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 gives a specific verb ('Execute'), a specific resource ('one read-only SELECT or WITH statement'), and the exact result envelope ('up to 50 rows'). An agent can immediately tell this is the ad-hoc query tool, distinct from metadata siblings like describe_table and list_tables, without opening the schema.

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

Usage Guidelines4/5

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

It clearly enumerates what is refused — multiple statements, writes, writes inside CTEs, ATTACH, PRAGMA, SET, row locks — which functions as explicit when-not guidance and prevents wasted calls. It does not route the agent toward alternatives (e.g. describe_table for schema discovery), so it falls short of the tier where sibling selection is spelled out.

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

Deploy Server

Other Tools