Skip to main content
Glama

Foreign key relationships

pg_relationships
Read-onlyIdempotent

Map PostgreSQL foreign key relationships: see which tables reference which columns, including ON DELETE/ON UPDATE actions, with optional table or schema filters and Mermaid ER diagram output.

Instructions

Show the foreign key graph: which table references which, through which columns, with ON DELETE / ON UPDATE actions.

table limits it to the relationships that touch one table (both directions); schema to those that touch a schema; with neither it covers every user schema. format="mermaid" returns a Mermaid erDiagram (entities with their key columns and the relationships) that can be pasted into documentation or a Markdown viewer.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "pg_relationships"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
tableNo
formatNojson
schemaNo
connectionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false and openWorldHint=false, so safety is covered; the description adds real value by disclosing the returned content (reference direction, join columns, ON DELETE/ON UPDATE actions) and the dual json/mermaid rendering. It omits that `limit` (default 200) can truncate a large graph, which is the main undisclosed behavioral trait.

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?

Front-loaded with the core purpose, then the scoping rules, then the output-format note — a logical progression with no filler sentences. Every clause (direction, columns, actions, mermaid paste target) conveys information an agent needs.

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?

With no output schema and annotations already carrying the safety profile, the description covers what the result contains in both formats and how filters narrow it. The only material gap is the unmentioned default row limit, which matters for a graph tool over a large schema.

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?

Schema description coverage is 0%, so the description must carry parameter meaning, and it does well for `table`, `schema`, and `format` — including the non-obvious 'both directions' behavior and what mermaid produces. It says nothing about `limit` or `connection`, leaving two of five parameters with no semantics anywhere.

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?

States a concrete verb and resource — 'Show the foreign key graph: which table references which, through which columns, with ON DELETE / ON UPDATE actions' — which no sibling covers (pg_dependencies and pg_get_ddl address different concerns). An agent can identify this as the FK-graph tool from the first clause alone.

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?

Explains the scoping conditions precisely: `table` yields relationships touching that table in both directions, `schema` scopes to a schema, and omitting both covers every user schema. That is clear usage context, but it never states when to prefer this over a sibling such as pg_dependencies or pg_describe_table, so it stops short of explicit alternatives.

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