Skip to main content
Glama
Datris MCP Server

Datris MCP Server

query_postgres

Execute read-only SQL SELECT queries against PostgreSQL to retrieve data, with automatic row limits and safeguards against long-running scans.

Instructions

Execute a read-only SQL SELECT query against PostgreSQL. Use the metadata discovery tools (list_postgres_databases, list_postgres_schemas, list_postgres_tables, list_postgres_columns) first to explore available data before constructing queries. Only SELECT is allowed; LIMIT is auto-appended if missing. Queries are cancelled if they run too long, so avoid full-table scans. For approximate row counts — "how many rows / records does table X have", overviews, or summarizing several tables — do NOT run exact SELECT COUNT(*) (it scans the whole table and can take many seconds on a large one). Instead read the planner estimate, which is effectively instant regardless of table size: SELECT reltuples::bigint AS estimate FROM pg_class WHERE relname = '<table>'. Use exact COUNT(*) only when the user explicitly needs an exact count of a known-small or filtered result.

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": "query_postgres"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesSQL SELECT query to execute
limitNoMaximum rows to return (default: 100). Pass -1 for unlimited — no cap, returns every matching row.

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?

With no annotations, the description carries the full behavioral burden and does well: read-only enforcement, auto-appended LIMIT, timeout cancellation, and the cost profile of full-table scans are all disclosed. It stops short of saying what the result set looks like, how query errors or cancellations are surfaced, or whether there are statement-length or concurrency constraints.

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 constraint, then ordered from discovery to safety to the performance tip. The COUNT(*) discussion is longer than the rest but each sentence carries concrete guidance; tightening the reltuples example slightly would help.

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 two-parameter query tool with no output schema, the definition covers the operation, the safety rails, the timeout/scan risk, and the main performance pitfall an agent would otherwise stumble into. Nothing essential to invoking it correctly 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 both parameters are already documented, but the description adds real semantics the schema lacks — that the sql value must be a SELECT and that a LIMIT is auto-appended when omitted. It doesn't explain when to set limit=-1 versus relying on the default, leaving that inference to the schema.

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?

States a specific verb and resource ('Execute a read-only SQL SELECT query against PostgreSQL') and immediately bounds scope to SELECT-only, which cleanly separates it from the query_databricks/query_snowflake/query_mongodb siblings and from the list_postgres_* metadata tools.

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?

Gives explicit when-to-use routing: call the metadata discovery tools first, and use the pg_class reltuples estimate instead of COUNT(*) for approximate counts, reserving exact COUNT(*) for known-small or filtered results. It even names the condition that selects each path, which is unusually actionable.

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