Skip to main content
Glama

contentrain_scaffold

Generate project structures using templates for blogs, landing pages, documentation, ecommerce sites, SaaS applications, internationalization setups, and mobile projects with automatic git commits.

Instructions

Template-based project setup. Available templates: blog, landing, docs, ecommerce, saas, i18n, mobile. Changes are auto-committed to git.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateYesTemplate ID: blog, landing, docs, ecommerce, saas, i18n, mobile
localesNoOverride locales
with_sample_contentNoInclude sample content (default: true)

Implementation Reference

  • The `contentrain_scaffold` tool implementation, which handles template-based project setup, model creation, and initial content seeding within a git transaction.
    server.tool(
      'contentrain_scaffold',
      `Template-based project setup. Available templates: ${listTemplates().join(', ')}. Changes are auto-committed to git.`,
      {
        template: z.string().describe('Template ID: blog, landing, docs, ecommerce, saas, i18n, mobile'),
        locales: z.array(z.string()).optional().describe('Override locales'),
        with_sample_content: z.boolean().optional().default(true).describe('Include sample content (default: true)'),
      },
      async ({ template: templateId, locales, with_sample_content }) => {
        const config = await readConfig(projectRoot)
        if (!config) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              error: 'Project not initialized. Run contentrain_init first.',
            }) }],
            isError: true,
          }
        }
    
        const tmpl = getTemplate(templateId)
        if (!tmpl) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              error: `Unknown template: "${templateId}". Available: ${listTemplates().join(', ')}`,
            }) }],
            isError: true,
          }
        }
    
        // Branch health gate
        const scaffoldHealth = await checkBranchHealth(projectRoot)
        if (scaffoldHealth.blocked) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              error: scaffoldHealth.message,
              action: 'blocked',
              hint: 'Merge or delete old contentrain/* branches before creating new ones.',
            }, null, 2) }],
            isError: true,
          }
        }
    
        const effectiveLocales = locales ?? config.locales.supported
        const defaultLocale = effectiveLocales[0] ?? 'en'
    
        const branch = buildBranchName('new', `scaffold-${templateId}`, defaultLocale)
        const tx = await createTransaction(projectRoot, branch)
    
        try {
          const modelsCreated: Array<{ id: string; kind: string; fields: number }> = []
          let contentCreated = 0
          let vocabAdded = 0
    
          await tx.write(async (wt) => {
            // Write models
            await Promise.all(tmpl.models.map(async (model) => {
              await writeModel(wt, model)
              modelsCreated.push({
                id: model.id,
                kind: model.kind,
                fields: model.fields ? Object.keys(model.fields).length : 0,
              })
            }))
    
            // Write sample content via content pipeline (handles content_path, locale_strategy, meta)
            if (with_sample_content && tmpl.sample_content) {
              contentCreated = await writeSampleContent(wt, tmpl, effectiveLocales, config)
            }
    
            // Merge vocabulary
            if (tmpl.vocabulary) {
              vocabAdded = await mergeVocabulary(wt, tmpl.vocabulary, effectiveLocales)
            }
    
          })
    
          await tx.commit(`[contentrain] scaffold: ${templateId} (${defaultLocale})`)
          const gitResult = await tx.complete({
            tool: 'contentrain_scaffold',
            model: tmpl.models.map(m => m.id).join(', '),
            locale: defaultLocale,
          })
    
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              status: 'committed',
              message: 'Scaffold applied and committed to git. Do NOT manually edit .contentrain/ files.',
              models_created: modelsCreated,
              content_created: contentCreated,
              vocabulary_terms_added: vocabAdded,
              git: { branch, action: gitResult.action, commit: gitResult.commit },
              context_updated: true,
              next_steps: [
                'Customize models with contentrain_model_save',
                'Add content with contentrain_content_save',
                'Run contentrain_submit when ready',
              ],
            }, null, 2) }],
          }
        } catch (error) {
          await tx.cleanup()
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              error: `Scaffold failed: ${error instanceof Error ? error.message : String(error)}`,
            }) }],
            isError: true,
          }
        } finally {
          await tx.cleanup()
        }
      },
    )
Behavior3/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It successfully communicates the critical side effect that 'Changes are auto-committed to git,' which is essential for a setup tool. However, it omits other important behavioral aspects: whether it overwrites existing files, required git state, failure modes, or return value structure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

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

Three tightly constructed sentences with zero waste. Purpose is front-loaded ('Template-based project setup'), followed by enumeration of options, and closing with behavioral note. Every sentence earns its place with no redundant or filler text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple 3-parameter schema with complete coverage and no output schema, the description adequately covers the essential operational context (templates and git side effects). However, it lacks completeness regarding the tool's output/return value, idempotency guarantees, or filesystem impact details that would be expected for a project scaffolding tool.

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 description coverage is 100%, establishing a baseline of 3. The description mirrors the schema by listing available templates, adding no additional semantic depth for 'locales' or 'with_sample_content' parameters. It neither adds constraint details beyond the schema nor leaves parameters undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States specific verb ('setup') and resource ('project'), clearly identifying this as a project scaffolding tool. Lists available template options (blog, landing, etc.) which helps distinguish it from sibling content management tools. However, it does not explicitly differentiate from 'contentrain_init' which may cause confusion about when to use each.

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

Usage Guidelines2/5

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

Provides no guidance on when to use this tool versus alternatives (particularly 'contentrain_init'), nor does it mention prerequisites like git initialization or existing directory state. The description focuses only on what the tool does, not when to invoke it.

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/Contentrain/ai'

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