Skip to main content
Glama
MCPg - Production-grade PostgreSQL MCP Server

MCPg - Production-grade PostgreSQL MCP Server

Find unused objects

find_unused_objects
Read-only

Identify tables and indexes with zero scans since pg_stat reset to flag potential unused objects for cleanup review; excludes primary and unique indexes.

Instructions

Find tables and indexes with zero scans since pg_stat was last reset — a strong signal of dead code, but NOT a verdict. Tables report seq+idx scan counts, write counts, and estimated row count; indexes report size and definition. Excludes PRIMARY KEY and UNIQUE indexes (PG needs those regardless of scans). Run this after the database has been hot for a meaningful period — fresh stats produce false positives. Returns an object with tables (list of candidate tables with their stats) and indexes (list of candidate indexes with size and definition).

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": {
      "schema": "<schema>"
    },
    "name": "find_unused_objects"
  }
}

Input Schema

NameRequiredDescriptionDefault
schemaYes
databaseNoOptional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected.

Output Schema

NameRequiredDescriptionDefault
schemaYes
tablesYes
indexesYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.4
    • changedInput schema / properties / database / description
      Previous value: -"Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids."New value: +"Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected."
  2. First observedv0.6.8

TDQS

A4/5.0
Behavior4/5

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

Annotations already establish read-only, closed-world behavior, and the description still adds real substance: the PK/UNIQUE exclusion (a behavioral rule that would otherwise surprise an agent), the stats-reset baseline, and the false-positive caveat. It does not discuss cost, row limits, or what happens on empty results, which keeps it out of the top band.

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-loaded with the core definition and four tight sentences with no filler. The final sentence enumerating the `tables` and `indexes` keys is somewhat redundant with the output schema, but it partially earns its place by restating what each entry carries.

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?

For an analytical read tool with an output schema, the description covers the signal, the caveats, the exclusions, and the return shape. The one real hole is the required `schema` parameter, which is undocumented in both the schema and the description.

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

Parameters2/5

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

Schema coverage is 50%: the `database` param is well documented in the schema, but the required `schema` param has only a title and no description anywhere. The description never mentions the schema scope or whether scan stats are per-schema or per-database, so the agent must guess at the required parameter's meaning.

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 states a specific verb and resource pair — find tables and indexes with zero scans since pg_stat was last reset — plus the interpretation of that signal. An agent knows exactly what this returns and how it differs from pure catalog listings like list_indexes or list_tables.

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

Usage Guidelines4/5

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

"Run this after the database has been hot for a meaningful period — fresh stats produce false positives" gives clear preconditions, and "NOT a verdict" tells the agent how to frame results. It stops short of naming alternatives such as recommend_index_drops, which targets a nearby question, so the routing is implied rather than explicit.

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