Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Analyze table bloat

analyze_table_bloat
Read-only

Identify and rank tables and indexes by bloat percentage, worst first. Uses catalog estimates by default; enable precise mode for exact pgstattuple analysis.

Instructions

Rank a schema's tables and indexes by estimated bloat, worst first. By default uses a cheap catalog-only estimate (relpages vs a reltuples/row-width floor) plus the dead-tuple ratio from pg_stat_user_tables. Set precise=true to use pgstattuple / pgstatindex for an exact (but I/O-heavy) read when the extension is installed — it falls back to the estimate and reports method='estimate' if it isn't. Returns tables and indexes (each capped at limit) with per-object est_bloat_pct, plus available and method.

Example: analyze_table_bloat(schema='public', limit=20, precise=false)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
schemaYes
preciseNo
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
detailYes
methodYes
schemaYes
tablesYes
indexesYes
availableYes
Behavior5/5

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

The description discloses key behavioral traits: the two estimation methods (catalog vs. I/O-heavy precise), fallback to estimate if pgstattuple is missing, and the return of a method field. This adds significant value beyond the annotations (readOnlyHint, openWorldHint), which already indicate read-only behavior. No contradiction.

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 concise (3 sentences plus an example), well-structured, and front-loaded. The first sentence states the purpose, the second explains methods, and the third describes the return structure. Every sentence adds value without 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?

Given the tool's complexity (two methods, multiple output fields), the description provides sufficient context: it mentions return fields (tables, indexes, est_bloat_pct, available, method) and the fallback behavior. The presence of an output schema further supplements completeness. No gaps remain for an AI agent to misuse the tool.

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 low (25%), but the description adds meaning by explaining the precise parameter's effect and fallback. It mentions limit, schema, and precise in the example. However, it does not describe the schema or limit parameters in depth beyond what the schema provides. The output schema likely documents return fields, so the description compensates adequately for the low parameter coverage.

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 clearly states the tool's purpose: 'Rank a schema's tables and indexes by estimated bloat, worst first.' It uses a specific verb ('rank'), identifies the resource ('tables and indexes'), and specifies the scope ('by estimated bloat'), distinguishing it from sibling tools like analyze_lock_hotspots or analyze_query_plan that focus on other metrics.

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?

The description explains when to use the tool (for bloat analysis) and provides an example. It also clarifies the precise parameter behavior and fallback logic. However, it does not explicitly state when not to use it or mention alternative tools for related tasks, though the sibling list provides context.

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/devopam/MCPg'

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