Skip to main content
Glama
ChingEnLin
by ChingEnLin

count_rows

Read-only

Count rows in a PostgreSQL table with an optional WHERE filter. Returns an exact count without row data.

Instructions

Count rows in a PostgreSQL table, optionally filtered by a WHERE clause.

Exact, unlike the estimates from list_tables, and returns no row data.

Args: table: Table name. where: Optional WHERE clause body without the WHERE keyword, e.g. "status = 'active'". schema: Schema name. Defaults to the session schema, then 'public'. database: Database name. Defaults to the session database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYes
whereNo
schemaNo
databaseNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With annotations already declaring readOnlyHint=true and destructiveHint=false, the safety profile is covered. The description adds meaningful behavioral context: exactness (not an estimate), no row data in the result, and default resolution for schema and database. This goes beyond annotations, though it does not mention potential performance characteristics on large tables.

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?

The description is compact yet comprehensive, with a clear purpose statement followed by a bulleted Args list. Every sentence adds value: the first sentence states the function, the second highlights key differentiators (exactness and no row data), and the Args section documents parameters. No wasteful words.

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 simple count tool with four parameters, an output schema already defined, and annotations covering safety, this description is complete. It covers all parameter semantics, defaults, and the tool's core value proposition. The output schema handles return-value details, so this description fully satisfies the contextual needs.

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

Parameters5/5

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

Schema description coverage is 0%, meaning the schema provides no parameter descriptions. The description's Args section compensates fully by explaining each parameter: table name, WHERE clause body (with example), schema defaulting behavior, and database defaulting behavior. This adds substantial meaning beyond the bare schema fields.

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 opens with 'Count rows in a PostgreSQL table, optionally filtered by a WHERE clause', which specifically identifies the action (count) and resource (PostgreSQL table). It further distinguishes itself from sibling tools by contrasting with list_tables' estimates, making its purpose unmistakable.

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?

The description explicitly states it is 'Exact, unlike the estimates from list_tables', providing a direct when-to-use comparison. It also notes 'returns no row data', which implies when not to use this tool if row data is needed, giving clear contextual guidance (e.g., use sample_rows or run_query for actual rows).

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/ChingEnLin/SQMCPaL'

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