get_database_schema
Retrieve a database's full schema as JSON or a runnable SQL DDL script so you can inspect tables, columns, keys, and indexes or recreate the structure.
Instructions
Get the whole database's schema at once, as JSON or as a runnable SQL script.
format="json" (default): every table with columns, types, nullability, primary key, and foreign keys. format="sql": a SELF-CONTAINED DDL script that recreates the schema — tables, columns, sequences, PK/FK/UNIQUE/CHECK, indexes, trigger functions, and triggers — so running it rebuilds the structure. No extra tools needed; covers the common cases (for a byte-faithful dump use dump_schema_faithful).
Returns meta, database and generated_utc, then table_count and tables
(json) or format and ddl (sql). Schema content is deterministic;
meta.elapsed_ms varies. Returned inline by default; pass output_dir to instead
WRITE it to {database}_schema_{UTC}.{json|sql} and get back saved_to plus a
summary — recommended for large schemas too big to return inline.
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": "get_database_schema"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | 'json' (default): tables, columns, keys as data. 'sql': a runnable DDL script that recreates the schema. | json |
| 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. | |
| output_dir | No | Directory on the machine running this server to write the export file into (created if missing), instead of returning it inline. Omit to return it inline. |