Skip to main content
Glama

Read Query

readQuery
Read-onlyIdempotent

Execute read-only SQL queries to retrieve and aggregate data from database tables.

Instructions

Execute a read-only SQL query. Allowed statements: SELECT, EXPLAIN.

<when_not_to_use>

  • Data changes (INSERT, UPDATE, DELETE) → use writeQuery

  • Query performance analysis → use explainQuery

  • Discovering tables or columns → use listTables or getTableSchema </when_not_to_use>

<what_it_returns> A JSON array of row objects, each keyed by column name. </what_it_returns>

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorNoOpaque pagination cursor. Omit (or pass `null`) for the first page. On subsequent calls, pass the `nextCursor` returned by the previous response verbatim. Cursors are opaque — do not parse, modify, or persist. Ignored for `EXPLAIN` statements.
queryYesThe SQL query to execute.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
nextCursorNoOpaque cursor pointing to the next page. Absent when this is the final page, when the result fits in one page, or when the statement is a non-`SELECT` kind that does not paginate (e.g. `SHOW`, `EXPLAIN`).
rowsYesResult rows, each a JSON object keyed by a column name.
Behavior5/5

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

Annotations already provide readOnlyHint, idempotentHint, etc. Description adds pagination behavior, cursor semantics, and return format, none of which contradict annotations.

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-organized sections (<usecase>, <when_not_to_use>, <examples>, <what_it_returns>, <pagination>) with no redundancy. Every sentence adds value.

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?

Covers usage, exclusions, examples, pagination, return format. Output schema exists, so return values are documented elsewhere. Sufficient for effective tool selection and invocation.

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 covers 100% of parameters. Description adds context: cursor pagination handling (ignored for EXPLAIN) and query allowed types (SELECT, EXPLAIN). Baseline 3, boosted for added clarity.

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?

Description explicitly states 'Execute a read-only SQL query' and lists allowed statements (SELECT, EXPLAIN). It distinguishes from siblings by name and via <usecase> and <when_not_to_use> sections.

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?

Dedicated <usecase> and <when_not_to_use> sections with clear conditions and references to alternative tools (writeQuery, explainQuery, listTables, getTableSchema). Examples further illustrate proper usage.

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/haymon-ai/dbmcp'

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