contentrain_describe
Retrieve the complete schema for a single content model to understand its structure and fields before creating content.
Instructions
Get full schema of a single model (read-only). Do NOT manually create content files — use contentrain_content_save instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Model ID (e.g. "blog-post", "hero") | |
| include_sample | No | Include one sample entry | |
| locale | No | Locale for sample content (default: config default locale) |
Implementation Reference
- The handler function for the 'contentrain_describe' tool. It fetches model definition, stats, and optionally a sample entry, then returns the schema and metadata.
server.tool( 'contentrain_describe', 'Get full schema of a single model (read-only). Do NOT manually create content files — use contentrain_content_save instead.', { model: z.string().describe('Model ID (e.g. "blog-post", "hero")'), include_sample: z.boolean().optional().default(false).describe('Include one sample entry'), locale: z.string().optional().describe('Locale for sample content (default: config default locale)'), }, async ({ model: modelId, include_sample, locale }) => { const modelDef = await readModel(projectRoot, modelId) if (!modelDef) { return { content: [{ type: 'text' as const, text: JSON.stringify({ error: `Model "${modelId}" not found` }) }], isError: true, } } const config = await readConfig(projectRoot) const effectiveLocale = locale ?? config?.locales.default ?? 'en' const stats = await countEntries(projectRoot, modelDef) const result: Record<string, unknown> = { id: modelDef.id, name: modelDef.name, kind: modelDef.kind, domain: modelDef.domain, i18n: modelDef.i18n, description: modelDef.description, fields: modelDef.fields, stats: { total_entries: stats.total, locales: stats.locales }, } if (include_sample) { const sample = await getSample(projectRoot, modelDef, effectiveLocale) if (sample) result['sample'] = sample } // Stack-aware import snippet const stack = config?.stack ?? 'other' result['import_snippet'] = generateImportSnippet(modelDef, stack, effectiveLocale) return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], } }, )