Skip to main content
Glama

Sample rows of a table

pg_sample_rows
Read-onlyIdempotent

Preview a table or view by returning a small sample of rows, optionally limited to selected columns or randomized, to inspect data shape without running a full query.

Instructions

Show a few rows of a table or view to see what the data looks like.

Pick columns to keep the answer small; by default every column the connection allows is listed (columns protected by the connection's rules are left out, and values of credential-like columns are redacted). limit is at most 100. By default the rows are simply the first ones the server finds, in no particular order; random=true draws a random sample instead (on a big table this reads the whole table once, so it can take a while; the time limit of the connection applies). For a filtered read use pg_query.

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": {
      "table": "<table>"
    },
    "name": "pg_sample_rows"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
tableYes
randomNo
columnsNo
connectionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Goes well beyond the annotations by disclosing that column listing is bounded by the connection's rules, that credential-like column values are redacted, that `limit` is capped at 100, and that random sampling can be slow and is bounded by the connection's time limit. The read-only/idempotent profile is already carried by annotations, so this added operational context is the right kind of value; only error behavior is undisclosed.

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 purpose, then organized by parameter in the order an agent would consider them. Slightly dense with parentheticals, but each sentence contributes a distinct constraint rather than restating the name.

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?

With no output schema, the description does enough: it establishes that rows come back with a possibly restricted column set and that ordering is unspecified by default. Only the `connection` selection semantics and failure modes are left unstated, which is a minor gap for a five-parameter read tool.

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 0%, so the description must carry parameter meaning, and it does for most: `columns` narrows the projection, `limit` maxes at 100, `random` switches between first-found and sampled order, and `table` is the target relation. The `connection` parameter is only referenced obliquely ('the connection's rules') without explaining how to select among connections.

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 ('Show a few rows of a table or view') plus the intent ('to see what the data looks like'), and explicitly separates itself from pg_query for filtered reads. An agent can distinguish this sampling tool from the broader query sibling without opening either schema.

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 routing guidance: use pg_query for a filtered read, use `columns` when the answer should stay small, and use `random=true` only when a true sample is needed, warning that on a big table it reads the whole table once. Both the when-to-use and the when-not-to-use cases are covered.

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