Skip to main content
Glama

run_sql_query

Execute a single read-only SQL statement and return structured results, with automatic LIMIT injection, hard row caps, and timeout guarding to keep responses bounded.

Instructions

Execute a read-only SQL query and return structured results.

Safety guardrails (see README "Design decisions"):

  • Only SELECT / WITH / EXPLAIN / DESCRIBE / SHOW statements are permitted; DDL/DML and system commands are rejected.

  • Only one statement per call.

  • If the query has no LIMIT clause, one is auto-injected using row_limit (or the server default). Results are always hard-capped at the server's max_row_limit, regardless of what you request, to keep responses bounded.

  • The query is cancelled if it runs longer than the server's configured timeout.

Use get_row_count first if you need to know the true size of a table beyond what this capped result shows.

Args: sql: A single read-only SQL statement. row_limit: Desired max rows (capped at the server's max_row_limit). Ignored if your query already has LIMIT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
row_limitNo
Behavior5/5

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

With no annotations provided, the description carries full burden and does an excellent job: it discloses read-only enforcement, single-statement restriction, automatic LIMIT injection, server-side row cap, and query timeout cancellation. This is far beyond minimal.

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?

The description is well-organized with a short intro, bullet-pointed guardrails, and a compact Args section. Every sentence adds relevant information and there is no wasted text.

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?

The description thoroughly covers safety guardrails, limits, and the row-count caveat. However, it does not describe the exact shape of the 'structured results' return value, and with no output schema, a bit more detail about the return format would make it fully complete.

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 coverage is 0%, but the description fully compensates by explaining each parameter: sql is a single read-only statement, and row_limit is a desired cap that may be ignored if the query already has LIMIT. This adds meaning the schema lacks entirely.

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 it executes a read-only SQL query and returns structured results, with explicit allowed statement types (SELECT/WITH/EXPLAIN/DESCRIBE/SHOW). It is easily distinguished from sibling tools like get_row_count, get_schema, and list_datasets.

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?

The description explicitly recommends using get_row_count when true table size is needed, providing a clear alternative. However, it does not explicitly contrast with other data exploration tools like get_data_profile or generate_chart, so the guidance is good but not exhaustive.

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/MostafaAI10/OmniData-MCP'

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