Skip to main content
Glama
MCPg - Production-grade PostgreSQL MCP Server

MCPg - Production-grade PostgreSQL MCP Server

List constraints

list_constraints
Read-only

Retrieve a table's primary, foreign, unique, check, and exclusion constraints by schema and table; set fresh=true to bypass cache after schema changes.

Instructions

List a table's constraints — primary/foreign keys, unique, check, exclusion. Set fresh=true to bypass the cache and re-read live (e.g. after a schema change). Returns a list of objects with name, type, and definition (the constraint SQL).

Example: list_constraints(schema='public', table='orders')

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": {
      "schema": "<schema>",
      "table": "<table>"
    },
    "name": "list_constraints"
  }
}

Input Schema

NameRequiredDescriptionDefault
freshNo
tableYes
schemaYes
databaseNoOptional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.4
    • changedInput schema / properties / database / description
      Previous value: -"Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids."New value: +"Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected."
  2. Changed1 schema field changed
    • addedInput schema / properties / fresh
      Added value: +{
      +  "default": false,
      +  "title": "Fresh",
      +  "type": "boolean"
      +}
  3. First observedv0.6.8

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so safety is covered; the description adds genuinely new behavior by disclosing that results are cached by default and that `fresh=true` forces a live re-read. It also states the return shape (`name`, `type`, `definition`), which goes beyond the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded, followed by the one non-obvious parameter behavior, the return shape, and a concrete call example. Every sentence carries information an agent would otherwise lack, with no filler.

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?

An output schema exists, so enumerating return fields is a bonus rather than a necessity, and the caching semantics fill the real gap. What's missing is edge-case behavior — e.g. what happens for a nonexistent table/schema or whether the list is ever truncated — but for a simple read-only lister this is nearly complete.

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 description coverage is only 25% (just `database` is documented), so the description must compensate — and it does for the most ambiguous param, explaining that `fresh` bypasses the cache and re-reads live. `schema` and `table` are left to inference, though the worked example clarifies their format.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("List a table's constraints") and enumerates the constraint kinds covered — primary/foreign keys, unique, check, exclusion — which lets an agent tell it apart from most siblings. It does not, however, address the overlap with `list_foreign_keys` or `list_indexes`, which an agent must resolve on its own.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives conditional guidance for one parameter ("Set `fresh=true` ... e.g. after a schema change") but never states when to choose this tool over the numerous sibling listers, particularly `list_foreign_keys`. Usage is implied by the enumerated constraint types rather than explicitly routed.

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

Deploy Server

Other Tools