Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Generate Ecto schemas

generate_ecto_schemas
Read-only

Read a PostgreSQL schema and emit Ecto (Elixir) schema modules — one .ex file per table, named after the singularised table.

Instructions

Read a PostgreSQL schema and emit Ecto (Elixir) schema modules — one .ex file per table, named after the singularised table. Each module uses Ecto.Schema with field declarations, belongs_to for single-column intra-schema FKs, and timestamps() when both inserted_at and updated_at exist. The Elixir top-level module is configurable via app_module (default MyApp). Returns a JSON object {filename: source} so the agent can write each file. 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.
app_moduleNoMyApp

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.6.8

TDQS

A4.1/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 the safety profile is covered. The description adds valuable context: the return format ({filename: source}), the identifier constraint, and the resulting code conventions. It doesn't cover failure modes beyond the identifier restriction, but relative to annotations this is a solid addition.

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?

Front-loads the core action and output, then adds constraints and alternatives. Dense but every clause carries meaning. Slightly long sentences but 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?

Given a rich tool with a schema-defined database param and an output schema present, the description covers purpose, output shape, identifier constraints, and alternatives well. Minor gap: the required 'schema' parameter's expected values/format isn't clarified.

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 only 33%. The description explains app_module (default MyApp) clearly, which compensates for one gap, and database is documented in-schema. But the required 'schema' parameter is not elaborated in the description beyond 'read a PostgreSQL schema', leaving its semantics to the schema alone.

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 (read a PostgreSQL schema, emit Ecto Elixir schema modules) and details the exact output shape (one .ex per table, Ecto.Schema, belongs_to for FKs, timestamps()). This clearly distinguishes it from sibling generators like generate_prisma_schema or generate_drizzle_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?

Explicitly states when NOT to use it — delimited identifiers (hyphens, spaces, mixed-case) are unsupported and it routes those cases to export_table and dump_database. However, it doesn't explain when to choose Ecto over the other schema generators (Prisma, Drizzle, Diesel) beyond the target framework, which is arguably implicit.

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