Skip to main content
Glama
db-conn-mcp

db-conn-mcp

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

NameRequiredDescriptionDefault
formatNo'json' (default): tables, columns, keys as data. 'sql': a runnable DDL script that recreates the schema.json
databaseYesName 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_dirNoDirectory 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.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.8.1
    • addedInput schema / properties / database / description
      Added value: +"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."
    • addedInput schema / properties / format / description
      Added value: +"'json' (default): tables, columns, keys as data. 'sql': a runnable DDL script that recreates the schema."
    • addedInput schema / properties / output_dir / description
      Added value: +"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."
  2. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations only flag readOnlyHint=false and destructiveHint=false; the description supplies the substantive behavior — deterministic schema content with only meta.elapsed_ms varying, inline-by-default return versus a file write when output_dir is set, and the generated filename pattern. That explains why readOnlyHint is false (file creation) rather than contradicting it. Minor gap: it doesn't state whether an existing file is overwritten.

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-loads purpose and mode selection, then moves to return shape and the file-write option; each paragraph has a distinct job. It is dense — the enumerated return keys are close to schema-level detail — but not padded or repetitive.

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?

With no output schema, the description fully compensates by naming the top-level return fields for both formats and the alternate saved_to/summary shape. Combined with mode guidance, determinism note, and the dump_schema_faithful escape hatch, an agent has everything needed to call it correctly.

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 100%, so baseline is 3, but the description adds real meaning: format's default and the semantic distinction between a data dump and a runnable DDL script, plus output_dir's side effect (directory created if missing) and the resulting saved_to summary rather than the payload.

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?

Opens with a specific verb and resource ("Get the whole database's schema at once") and immediately qualifies the two output modes. The phrase "whole database's schema" plus the pointer to dump_schema_faithful for byte-faithful dumps and the implied contrast with get_table_schema let an agent place it among its siblings without opening the schema.

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?

Gives clear selection criteria for format (json for data inspection, sql for rebuilding), for output_dir (recommended for large schemas too big to return inline), and an explicit alternative for exact dumps (dump_schema_faithful). It does not explicitly state when to prefer this over get_table_schema or diff_schemas, so it stops short of full when/when-not coverage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.