Skip to main content
Glama
Automata MCP

Automata MCP

Run a read-only SQL query

run-query
Read-only

Executes a single read-only PostgreSQL query and returns one page of rows, enforcing table allowlists, timeouts, and paging so agents can inspect data without writes.

Instructions

[PostgreSQL] Run one read-only SQL statement and return its rows. Exactly one statement — a second one after a semicolon is rejected by the database, not silently run. It executes inside a read-only transaction with a statement timeout, so nothing it does can change data, and every table it touches must be inside this connector's allowlist: the planner is asked which relations the query resolves to, through views and CTEs included, before a single row is read, and a query that reaches outside is refused with the offending table named. Functions this connector cannot see inside — anything outside pg_catalog — are refused too, so a query calling a helper function must be rewritten against the tables directly. Prefer describe-table over SELECT * on a wide table. The result is ONE PAGE of at most maxRows rows: when hasMore is true you have NOT seen the whole result — call again with page: nextPage. Each page re-runs the query, so pages only line up when it has an ORDER BY on a unique column; add one before paging. For very deep results a keyset predicate (WHERE id > ) is cheaper than a high page number. Long cells are clipped at 2000 characters unless you pass fullValues: true. Never summarise a hasMore: true result as if it were the full answer.

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": {
      "sql": "<sql>"
    },
    "name": "run-query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesOne SQL query: SELECT, WITH … SELECT, VALUES or TABLE. Not a write.
pageNo1-based page of `maxRows` rows. Walk it up with nextPage while hasMore is true; pages are consistent only under an ORDER BY on a unique column.
maxRowsNoRows per page, at most 1000. For more rows, keep this and walk `page` with nextPage — add an ORDER BY on a unique column first so the pages line up. The query is stopped at this many rather than truncated afterwards.
timeoutMsNoServer-side statement timeout, in milliseconds
fullValuesNoReturn every cell whole instead of clipping each at 2000 characters. Set it only when you need a long text or JSON value in full: a page of large cells can make a very large response.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior4/5

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

Goes well beyond the readOnlyHint/destructiveHint/openWorldHint annotations: read-only transaction, statement timeout, pre-execution relation resolution through views and CTEs, refusal with the offending table named, and refusal of opaque functions. The one genuinely important behavior — that each page re-runs the query so pages are only consistent under a unique ORDER BY — is disclosed, but the interaction between page re-execution and mutable data is only partly spelled out.

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 contract, then constraints, then paging advice — a logical order with dense sentences. It runs long and repeats the page/nextPage/ORDER BY advice that also appears in the schema, so a few clauses could be trimmed, but none are pure padding.

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?

For a query tool with no output schema, the description supplies what an agent needs: the row/page return shape, hasMore/nextPage semantics, cell clipping, and failure modes. The closing warning not to summarize a hasMore:true result as complete closes the most likely downstream error, so nothing material 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 coverage is 100%, so the baseline is 3; the description earns above that by explaining consequences the schema does not: pagination re-runs the query (so ORDER BY on a unique column is required for alignment), maxRows stops the query rather than truncating afterwards, and fullValues trades response size for cell completeness at 2000 chars. It mostly restates nextPage/page mechanics that the schema already carries, which keeps it short of a 5.

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?

Opens with a specific verb+resource+engine tag: "[PostgreSQL] Run one read-only SQL statement and return its rows." It distinguishes itself from write paths ("Not a write" implied throughout, sibling run-statement left to its own definition) and from the sibling describe-table by telling the agent to prefer describe-table over SELECT * on wide tables.

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?

Explicitly routes the agent: prefer describe-table over SELECT *; use a keyset predicate instead of a high page number for deep results; set fullValues only when a long text/JSON value is needed. It also states the refusal conditions (multiple statements, out-of-allowlist relations, non-pg_catalog functions) so the agent knows when not to attempt a query at all.

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