listTables

Return the structure of every table, view and materialised view in a schema: kind, comment, storage options, columns and their per-column index counts, index count and constraint count.

read-onlyany connectionsweeps instancesweeps group

Synopsis

listTables(schema)

Description

Return the structure of every table, view and materialised view in a schema: kind, comment, storage options, columns and their per-column index counts, index count and constraint count. Structure only -- it changes when someone issues DDL and not otherwise. For row counts, scan counters, dead tuples and vacuum times call listTableStats; for measured on-disk sizes call listTableSizes.

Parameters

schema requiredstring

Also accepts connection, instance, group, described once under arguments every tool takes.

Output

Keyed by table name; each value is that table's structure. An absent extension or a missing grant is reported as {error, hint} in place of the map.

Scope

A physical replica is byte-identical here, so asking each member of a replication group adds nothing.

Example mocked data

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "listTables",
    "arguments": {
      "schema": "shop"
    }
  }
}

Result

{
  "orders": {
    "kind": "table",
    "description": "Customer purchase orders.",
    "reloptions": null,
    "columns": {
      "id": {
        "description": null,
        "index_count": 1
      },
      "customer_id": {
        "description": null,
        "index_count": 1
      },
      "status": {
        "description": "pending | paid | shipped",
        "index_count": 0
      }
    },
    "index_count": 2,
    "constraint_count": 3
  },
  "customers": {
    "kind": "table",
    "description": "",
    "reloptions": [
      "fillfactor=90"
    ],
    "columns": {
      "id": {
        "description": null,
        "index_count": 1
      },
      "email": {
        "description": null,
        "index_count": 1
      }
    },
    "index_count": 2,
    "constraint_count": 2
  }
}

Invented values on a fictional shop database, shaped by and checked against this tool's output schema. Real output is returned as structuredContent to clients that negotiate MCP 2025-06-18 or later.

See also

listSchemas, tableDetails, tableStats, largeObjects, listPartitions, partitionDetails, listTableStats, tableSize, listTableSizes, listFunctions, functionDetails, listEnums, enumDetails, listTypes, typeDetails, columnHistogram, listExtendedStatistics, listSequences