Skip to main content
Glama
db-conn-mcp

db-conn-mcp

table_stats

Read-onlyIdempotent

Retrieve read-only approximate row counts and disk/index sizes per table, largest first, to plan migration copy order and spot anomalies without table scans.

Instructions

Approximate row counts and disk/index sizes per table, largest first.

Read-only. Uses the database's own statistics — fast, no table scans — so counts are as fresh as the last ANALYZE or autovacuum run; for an exact count run SELECT count(*) with execute_read_query. Useful for planning migration copy order and spotting anomalies; for columns and keys use get_table_schema. One row per table, so ask the narrower question instead of filtering afterwards: table for one table, min_size_bytes to skip anything smaller, limit for the top N.

Returns meta, database and tables, one item per table with schema, table, approx_rows, table_bytes, index_bytes and total_bytes, plus truncated when limit is set (true when more tables matched); meta.truncated repeats it, and is false without limit.

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": {
      "database": "<database>"
    },
    "name": "table_stats"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoReturn only the N largest tables by total size. Omit for all.
tableNoOnly this table, exactly as list_tables shows it, optionally schema-qualified ('public.orders'). Omit for every table.
databaseYesName of a configured database, exactly as list_databases returns it (case-sensitive). Not a DSN, host or server-side database name. An unknown name is an error that lists the configured names.
min_size_bytesNoSkip tables whose total size is below this many bytes.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.8.1
    • addedInput schema / properties / database / description
      Added value: +"Name of a configured database, exactly as list_databases returns it (case-sensitive). Not a DSN, host or server-side database name. An unknown name is an error that lists the configured names."
    • addedInput schema / properties / limit / description
      Added value: +"Return only the N largest tables by total size. Omit for all."
    • addedInput schema / properties / min_size_bytes / description
      Added value: +"Skip tables whose total size is below this many bytes."
    • addedInput schema / properties / table / description
      Added value: +"Only this table, exactly as list_tables shows it, optionally schema-qualified ('public.orders'). Omit for every table."
  2. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Goes well beyond the read-only annotations by disclosing the mechanism (database's own statistics, no table scans) and the resulting freshness caveat (only as fresh as the last ANALYZE/autovacuum). It also flags a behavioral edge case: truncated is returned when limit is set and is false without it.

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-loads the one-line summary, then caveats, then return shape, with no filler sentences. The closing detail about meta.truncated repeating the flag is slightly redundant but justified by the absence of an output schema.

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?

Covers what the tool computes, how fresh it is, when to use alternatives, and the full return shape including the truncated flag, which is necessary since no output schema exists.

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 100%, so the schema already documents all four parameters; the description mostly echoes them, but adds genuine guidance that these filters are the intended narrowing mechanism rather than post-filtering the results.

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 resource and its measurement ('Approximate row counts and disk/index sizes per table, largest first'), which is immediately distinguishable from schema-inspection or row-sampling siblings.

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 routes away: 'for an exact count run SELECT count(*) with execute_read_query' and 'for columns and keys use get_table_schema'. It also prescribes push-down parameters ('ask the narrower question instead of filtering afterwards') for table, min_size_bytes and limit.

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