get_table_schema
Retrieve a table's columns, data types, primary and foreign keys, and optional indexes before writing filters or JOINs. Use it to inspect structure and verify what a slow query actually indexes.
Instructions
Get columns, types, and primary/foreign keys for a table.
For one table. For every table at once use get_database_schema; for a view, function, trigger, sequence or index definition use get_object_definition.
Returns meta, table, columns (name, type, nullable, default), primary_key
and foreign_keys, plus indexes when asked for; a table that does not exist is
an error.
Pass include_indexes=true to also get the table's indexes (name, its KEY columns in index order — an INCLUDE payload is not listed — whether it is unique, and its method: btree, gin, ...). Use it before writing a filter or a JOIN, or when a query is slow and you want to know what is actually indexed. Omitted by default, so the plain answer stays small.
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>",
"table": "<table>"
},
"name": "get_table_schema"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table or view name exactly as list_tables shows it (case-sensitive, no quotes), optionally schema-qualified: 'orders' or 'public.orders'. | |
| database | Yes | 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. | |
| include_indexes | No | Also return the table's indexes. Default false keeps it small. |