Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

Count Rows in Table

pg_count_rows
Read-only

Get the exact row count for a PostgreSQL table, with optional WHERE filter. Provides precise count for tables of any size.

Instructions

Get exact row count for a table, optionally with a filter condition.

Args:

  • table: Table name (required)

  • schema: Schema name (default: public)

  • where_clause: Optional WHERE condition (without the WHERE keyword)

Returns: JSON: { table, schema, count, where_clause } Markdown: formatted count with filter info

Note: For large tables (>10M rows), pg_table_stats provides a faster estimated count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name
schemaNoPostgreSQL schema name (default: public)public
where_clauseNoOptional WHERE condition without 'WHERE', e.g. "status = 'active'"
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. Description adds value by specifying that it provides an exact count, supports optional WHERE clause, and includes a large-table performance note. No contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Concise and well-structured: main purpose sentence, then Args/Returns/Note sections. Every sentence adds value; no redundancy.

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?

With annotations and simple output, description fully covers behavior: exact count, filter usage, return format, and alternative for large tables. No gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. Description repeats parameter names and meanings from schema (e.g., 'table: Table name (required)') without adding new semantic details or format constraints.

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?

Description clearly states 'Get exact row count for a table', using specific verb 'Get' and resource 'row count'. It distinguishes from sibling tool 'pg_table_stats' which provides estimated counts.

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 provides a usage alternative: 'For large tables (>10M rows), pg_table_stats provides a faster estimated count.' Also mentions optional filter condition, guiding appropriate use.

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