Skip to main content
Glama

Count rows

count
Read-only

Calculates the number of rows in a table matching filters, optionally grouped by distinct values to reveal data distribution.

Instructions

Counts the rows in a table that match a filter. With groupBy, counts per distinct value, largest groups first: a quick way to see how data is distributed.

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

Input Schema

NameRequiredDescriptionDefault
tableYesThe table: its TypeScript export or SQL name.
whereNoConditions that must all hold, keyed by column (TypeScript key or SQL name). A plain value means equals: {"published": true}. Operators: {"createdAt": {"gte": "2026-01-01"}}, {"title": {"ilike": "%drizzle%"}}, {"id": {"in": [1, 2]}}, {"deletedAt": {"isNull": true}}. Use {"or": [{...}, {...}]} for alternatives.
groupByNoColumns to count per value of, such as ["status"].

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, destructiveHint=false and openWorldHint=false, so the safety profile is covered. The description adds genuinely new behavior — that grouped results are ordered largest group first — which is not derivable from annotations or schema. It stops short of describing the shape of an ungrouped count result.

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?

Two short sentences, front-loaded with the core operation, with the groupBy variant in the second sentence. No filler and no restatement of the title.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/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 should indicate what the tool returns; it communicates the grouped result semantics but not the ungrouped count return (scalar vs object). Adequate for a simple 3-parameter read tool, but one clause on return shape would close the gap.

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 description coverage is 100%, so the schema already documents `table`, `where` operators, and `groupBy`. The description adds slight meaning for `groupBy` (counts per distinct value, ordered largest first) but says nothing about `where` beyond what the schema carries, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource — counting rows in a table that match a filter — and clarifies the aggregate variant via groupBy. It implicitly separates itself from the sibling `query` tool (row retrieval) but never names it or any other sibling explicitly.

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?

Usage is implied rather than stated: "a quick way to see how data is distributed" hints at the groupBy case, but there is no explicit when-to-use-this-vs-`query`/`explain` guidance and no exclusions or prerequisites.

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