Skip to main content
Glama

generate_resource

Generates a complete CRUD module for any resource with REST endpoints, service layer, database operations, Zod validation, auto-registered routes, and tests. Supports relations and interactive field prompts.

Instructions

Generates a full CRUD module for a resource — controller with 5 REST endpoints (GET /:id, GET /, POST, PATCH /:id, DELETE /:id), service layer with business logic, repository with database operations, Zod validation schemas, TypeScript interfaces, route definitions auto-registered in the Express app with Swagger/OpenAPI docs, and a test file. If fields are not provided, the CLI will prompt interactively (use non-interactive mode by passing fields directly). Relations create foreign key columns in the database and populate the Prisma/Drizzle/Mongoose schema with the correct association types (belongsTo for singular, hasMany for plural relation names). Run add_plugin first if you need auth protection on the generated endpoints.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesResource name in PascalCase, 2+ characters, must start with an uppercase letter. Examples: 'Product', 'OrderItem', 'MedicalRecord'. This becomes the module directory name, database table name, and all class/file names.
fieldsNoComma-separated field definitions in "name:type" format. Supported types: string, number, boolean, date. Examples: "name:string,price:number,isActive:boolean" or "email:string,age:number". Can be omitted for interactive mode.
relationsNoComma-separated relation definitions in "name:RelatedResource" format. Singular names (e.g., "doctor:Doctor") create a belongsTo foreign key. Plural names (e.g., "patients:Patient") create a hasMany inverse. Examples: "doctor:Doctor,patient:Patient" or "category:Category". The related resource must already exist.
dirNoAbsolute or relative path to the BackGen-generated project directory where the resource module will be created. Defaults to current working directory. Example: '/home/user/projects/my-api'.
Behavior4/5

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

No annotations are provided, so the description carries full burden. It discloses creation of multiple files, interactive prompting, and relation behavior (belongsTo/hasMany). However, it does not specify whether existing files are overwritten or if the tool has destructive tendencies, which is a minor gap.

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?

The description is comprehensive but slightly verbose. It is well-structured with the main purpose first, followed by details on relations and prerequisites. Every sentence adds value, though some consolidation could improve conciseness.

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?

Given no output schema, the description thoroughly explains what is generated (endpoints, layers, validation, tests) and how relations work. It also cross-references add_plugin for auth, making the tool self-contained in context. No major gaps identified.

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 input schema already provides 100% coverage with clear descriptions for all four parameters. The description adds value by explaining relation semantics (singular vs. plural) and interactive mode, but this is supplemental rather than essential, as the schema already explains the format.

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?

The description uses a specific verb 'Generates' and identifies the resource as a full CRUD module, listing the specific components (controller, service, repository, etc.). It clearly distinguishes itself from sibling tools like add_plugin or generate_factory by focusing on resource generation.

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?

Explicitly states when to use the tool (to generate a CRUD module) and provides an alternative instruction: 'Run add_plugin first if you need auth protection.' Also explains interactive vs. non-interactive mode, giving clear guidance on when to provide fields.

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

Install Server

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/IbrahimKhaled19/BackGen'

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