Skip to main content
Glama

Database Schema

db_schema
Read-onlyIdempotent

Retrieve the live PostgreSQL schema with column types, constraints, indexes, and foreign key relationships. Use it to verify column details and structure before building queries or debugging errors.

Instructions

Returns the full database schema with column-level detail: every table's columns with their data types, nullability, defaults, constraints (primary key, unique, check), indexes, and foreign key relationships presented as a relationship diagram. This is introspected live from PostgreSQL's information_schema, so it always reflects the current state of the database.

When to use:

  • When you need column-level detail beyond what db_overview provides.

  • Before constructing queries with specific columns, to verify column names and types.

  • When the user asks about table structure, constraints, or relationships.

  • When debugging query errors related to column types or constraints.

Behavioral notes:

  • Schema is fetched fresh on every call (not cached) to catch DDL changes.

  • Only schemas listed in PG_SCHEMAS are included (default: public).

  • The relationship diagram shows foreign keys between tables, useful for JOIN queries.

Returns: JSON with tables (each containing columns with type, nullable, default, constraints), indexes, and a relationships array.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoName of the database to query (from pgautopilot.json). Omit to use the current default database.
Install Server

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint, and the description adds non-redundant behavioral context: live introspection from information_schema, no caching to catch DDL changes, PG_SCHEMAS filtering with public default, and the relationship diagram's use for JOIN queries. No statement contradicts 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.

Conciseness4/5

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

Well-structured with a front-loaded summary, explicit use cases, behavioral notes, and a return-shape section. There is minor redundancy between 'introspected live from PostgreSQL's information_schema' and 'fetched fresh on every call (not cached)', and the Returns paragraph partly repeats the opening sentence, so it is not a perfect 5.

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?

Even with no output schema, the Returns paragraph specifies the JSON shape (tables with columns, type, nullable, default, constraints, indexes, relationships array). Behavioral notes cover freshness and schema scope, and the one optional parameter is fully described in the schema, so nothing essential is missing for correct invocation.

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?

The single optional `database` parameter is fully documented in the input schema (100% coverage), so the baseline is 3. The description does not add parameter-specific details beyond the schema, which is acceptable given the schema already explains the parameter's meaning and default behavior.

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 specific verb and resource: 'Returns the full database schema with column-level detail' and enumerates exact contents (columns, data types, nullability, defaults, constraints, indexes, foreign keys). It explicitly contrasts with db_overview ('beyond what db_overview provides'), making sibling differentiation clear.

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

Usage Guidelines5/5

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

Provides a dedicated 'When to use' list with concrete triggers: needing column-level detail, verifying column names/types before constructing queries, answering structure/constraint/relationship questions, and debugging type/constraint errors. It names db_overview as the alternative and the condition that selects this tool, giving an agent clear routing guidance.

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

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyberreinxy/pgautopilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server