Skip to main content
Glama

Read Query

readQuery
Read-onlyIdempotent

Execute read-only SQL queries (SELECT, EXPLAIN) on a database to retrieve data as JSON. Use for data querying, aggregations, or existence checks.

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 indicate read-only, non-destructive, idempotent, and open-world. The description adds important behavioral details: pagination behavior for SELECT vs. EXPLAIN, and return format (JSON array of row objects). No contradictions with annotations.

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?

The description is well-structured with labeled sections (usecase, when_not_to_use, examples, what_it_returns, pagination). It is slightly verbose but every section contributes meaningful information.

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?

Given the tool's complexity (two parameters, pagination, output schema), the description covers purpose, usage, return format, and pagination adequately. The presence of an output schema reduces the burden, but the description still provides necessary context.

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?

Input schema has 100% coverage with detailed descriptions for both parameters. The description adds value by explaining pagination mechanics (cursor usage) and providing examples, but schema already covers parameter semantics well.

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 the tool executes read-only SQL queries (SELECT, EXPLAIN) and differentiates from siblings like writeQuery and explainQuery. The verb+resource is specific and unambiguous.

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?

The description includes explicit <usecase> and <when_not_to_use> sections, providing concrete scenarios and alternatives (writeQuery, explainQuery, listTables, getTableSchema). Examples further clarify correct 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