Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Generate Drizzle schema

generate_drizzle_schema
Read-only

Read a PostgreSQL schema and emit a Drizzle ORM TypeScript schema string (drizzle-orm/pg-core). Covers tables, columns with PG-native types, primary/foreign keys, unique constraints, indexes, defaults, and enums.

Instructions

Read a PostgreSQL schema and emit a Drizzle ORM TypeScript schema string (drizzle-orm/pg-core). Covers tables, columns with PG-native types, primary/foreign keys, unique constraints, indexes, defaults, and enums. Single-column FKs emit column-level .references(); composite FKs are a documented v1 gap. Views, foreign tables, partitions, triggers, and functions are out of scope. Returns the rendered TypeScript schema.ts source as a single string. Schema/table/column names must be plain identifiers ([A-Za-z_][A-Za-z0-9_]*); delimited names (hyphens, spaces, mixed-case-only) are not supported here because they become source identifiers in generated code — use SQL tools (export_table, dump_database) for those objects. See docs/identifier-policy.md.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaYes
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.6.8

TDQS

A4.4/5.0
Behavior5/5

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

Annotations only carry readOnlyHint=true and openWorldHint=false. The description adds substantial behavioral context beyond that: the exact coverage set (tables, columns, PK/FK, unique constraints, indexes, defaults, enums), the v1 gap on composite FKs, the out-of-scope object classes, the return shape ('rendered TypeScript schema.ts source as a single string'), and the identifier restriction with a doc pointer.

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?

Purpose and output are front-loaded in the first sentence, and the density is high — coverage list, gaps, scope exclusions, return type, and naming policy all carry real information. It runs long and the identifier-policy sentence is a dense run-on that could be split, but nothing is padding.

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?

An output schema exists, so return values needn't be fully specified, yet the description still names the return type. For a code-generator tool with real scope limits, all the decision-relevant facts are present: what's covered, what's a known gap, what's excluded, and which fallback tools handle the excluded cases.

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 coverage is 50%: the `database` param is documented in-schema (secondary read-only DB, points to list_databases), but `schema` has none. The description implies `schema` is a schema name and adds the identifier constraint '[A-Za-z_][A-Za-z0-9_]*' that governs it, but does not say whether it accepts a single schema, a pattern, or how to enumerate candidates. Baseline 3 is right at this coverage level.

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 + resource with the target technology named: 'Read a PostgreSQL schema and emit a Drizzle ORM TypeScript schema string (drizzle-orm/pg-core).' The Drizzle/pg-core anchoring distinguishes it cleanly from the sibling generators (generate_prisma_schema, generate_diesel_schema, generate_ecto_schemas, etc.) without needing to open any 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?

It establishes scope boundaries (views, foreign tables, partitions, triggers, functions out of scope; composite FKs a v1 gap) and routes the delimited-name case to explicit alternatives: 'use SQL tools (export_table, dump_database) for those objects.' What's missing is any statement about when to prefer this over the other ORM generators, though the ORM name makes that largely self-evident.

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