Skip to main content
Glama

Rebuild the CREATE statement of an object

pg_get_ddl
Read-onlyIdempotent

Rebuilds the CREATE DDL for PostgreSQL tables, views, functions, sequences, types, indexes, triggers, and schemas, so you can copy structures or review definitions.

Instructions

Rebuild the CREATE statement (DDL, as SQL text) of a table, view, materialized view, function, procedure, sequence, type (enum, domain, composite, range), index, trigger or schema.

A table comes with its columns (types, defaults, identity and generated columns, NOT NULL), constraints, PARTITION BY / PARTITION OF, INHERITS, indexes, comments, triggers, row level security and policies. Names are always schema-qualified. Owners and GRANTs are not included. name is name or schema.name; a function accepts a signature such as shop.order_total(bigint). Use it to copy a structure or to review how an object was defined.

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": {
      "name": "<name>"
    },
    "name": "pg_get_ddl"
  }
}

Input Schema

NameRequiredDescriptionDefault
kindNotable
nameYes
connectionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and openWorldHint=false, so the safety profile is covered. The description adds genuinely useful behavioral context beyond that: exactly what a table DDL includes (columns, identity/generated, constraints, partitioning, inheritance, indexes, comments, triggers, RLS policies), that names are always schema-qualified, and importantly that owners and GRANTs are excluded.

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?

The first sentence front-loads the core action and output type, then the detail follows in a scoped second paragraph. The long enumeration of table sub-objects is dense but each item conveys real coverage information rather than filler. Minor trimming of the kind list (which duplicates the enum) would make it tighter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, and the description compensates by stating the return is SQL text and defining inclusion/exclusion boundaries. For a single-object DDL reader that is nearly complete; the remaining gaps are the meaning of `connection` and behavior when the named object does not exist.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description must carry the parameter burden. It does well for the required `name` argument, spelling out both accepted forms (`name` or `schema.name`) and the function signature syntax like `shop.order_total(bigint)`. However, `connection` is never mentioned and `kind` is only implied by the object list, leaving two of three parameters without narrative meaning.

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 states a precise verb and output form ('Rebuild the CREATE statement (DDL, as SQL text)') and enumerates every supported object kind, so there is no ambiguity about what the tool produces. The exhaustive kind list plus the closing 'Use it to copy a structure or to review how an object was defined' cleanly separates it from metadata-inspection siblings like pg_describe_object or pg_list_objects.

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?

It gives clear use contexts: 'Use it to copy a structure or to review how an object was defined.' That is enough to select the tool for structure-copying or definition-review tasks. It stops short of explicit exclusions or naming an alternative for cases where DDL reconstruction is the wrong choice.

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