Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

Get Sample Rows from Table

pg_sample_rows
Read-only

Retrieve a sample of rows from a PostgreSQL table, applying optional filters, column selection, and ordering. Specify schema, limit, and output format as JSON or Markdown.

Instructions

Retrieve a sample of rows from a PostgreSQL table, with optional filtering and column selection.

Args:

  • table: Table name (required)

  • schema: Schema name (default: public)

  • limit: Number of rows to return, 1-500 (default: 10)

  • where_clause: Optional WHERE clause (without the WHERE keyword), e.g. "status = 'active'"

  • columns: Comma-separated column names to select (optional, default: all columns)

  • order_by: ORDER BY clause (without ORDER BY), e.g. "created_at DESC"

  • response_format: Output format

Returns: JSON: { table, schema, row_count, columns: string[], rows: object[] } Markdown: formatted table of results

Security: table and schema names are validated against actual database objects before use.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name to sample
schemaNoPostgreSQL schema name (default: public)public
limitNoNumber of rows (default: 10, max: 500)
where_clauseNoOptional WHERE condition without 'WHERE', e.g. "age > 18 AND active = true"
columnsNoComma-separated column names to return (default: all, e.g. 'id, name, email')
order_byNoORDER BY clause without 'ORDER BY', e.g. 'created_at DESC'
response_formatNoOutput format: 'markdown' for human-readable, 'json' for machine-readablemarkdown
Behavior4/5

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

No contradiction with annotations (readOnlyHint=true, destructiveHint=false). The description adds context about security validation of table/schema names and specifies return formats (JSON and Markdown), which goes beyond 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 a clear main purpose and bullet-like arg list. It is somewhat verbose but effective. The main purpose is front-loaded, making it easy for an AI to parse.

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?

Given 7 parameters, 100% schema coverage, no output schema, and existing annotations, the description covers purpose, parameter nuances, return formats, and security notes. Minor missing details about sampling algorithm and performance, but overall complete.

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 description coverage is 100%, baseline is 3. The description adds value by clarifying syntax for where_clause and order_by (omit keywords) and explaining response_format options, which enriches parameter semantics.

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 'Retrieve a sample of rows from a PostgreSQL table' with optional filtering and column selection. This specific verb-resource combination distinguishes it from sibling tools like pg_count_rows (counts only) and pg_execute (custom SQL).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for quick sampling with optional filters, but does not explicitly state when to use this tool versus siblings like pg_query or pg_count_rows. No exclusion criteria or alternative recommendations are provided.

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/foxter-io/mcp-postgresql'

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