Skip to main content
Glama

contentrain_model_delete

Delete a model and its content/meta from Contentrain MCP, with changes auto-committed to git. Use to remove models and associated data.

Instructions

Delete a model and its content/meta. Changes are auto-committed to git — do NOT manually edit .contentrain/ files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYesModel ID to delete
confirmYesMust be true to confirm deletion

Implementation Reference

  • The tool `contentrain_model_delete` is defined and implemented as an anonymous async function within the `registerModelTools` function, handling the deletion of a model and its associated data.
    server.tool(
      'contentrain_model_delete',
      'Delete a model and its content/meta. Changes are auto-committed to git — do NOT manually edit .contentrain/ files.',
      {
        model: z.string().describe('Model ID to delete'),
        confirm: z.literal(true).describe('Must be true to confirm deletion'),
      },
      async ({ model: modelId }) => {
        const config = await readConfig(projectRoot)
        if (!config) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({ error: 'Project not initialized.' }) }],
            isError: true,
          }
        }
    
        // Check model exists
        const existing = await readModel(projectRoot, modelId)
        if (!existing) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({ error: `Model "${modelId}" not found` }) }],
            isError: true,
          }
        }
    
        // Branch health gate
        const deleteHealth = await checkBranchHealth(projectRoot)
        if (deleteHealth.blocked) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              error: deleteHealth.message,
              action: 'blocked',
              hint: 'Merge or delete old contentrain/* branches before creating new ones.',
            }, null, 2) }],
            isError: true,
          }
        }
    
        // Check references
        const refs = await checkReferences(projectRoot, modelId)
        if (refs.length > 0) {
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              deleted: false,
              error: 'REFERENCED_MODEL',
              referenced_by: refs,
              next_steps: ['Remove relation fields from referencing models first'],
            }, null, 2) }],
          }
        }
    
        const branch = buildBranchName('model', modelId)
        const tx = await createTransaction(projectRoot, branch)
    
        try {
          let filesRemoved: string[] = []
    
          await tx.write(async (wt) => {
            filesRemoved = await deleteModel(wt, modelId)
          })
    
          await tx.commit(`[contentrain] delete: ${modelId}`)
          const gitResult = await tx.complete({ tool: 'contentrain_model_delete', model: modelId })
    
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              status: 'committed',
              message: 'Model deleted and committed to git. Do NOT manually edit .contentrain/ files.',
              deleted: true,
              git: { branch, action: gitResult.action, commit: gitResult.commit },
              files_removed: filesRemoved,
              context_updated: true,
            }, null, 2) }],
          }
        } catch (error) {
          await tx.cleanup()
          return {
            content: [{ type: 'text' as const, text: JSON.stringify({
              error: `Delete failed: ${error instanceof Error ? error.message : String(error)}`,
            }) }],
            isError: true,
          }
        } finally {
          await tx.cleanup()
        }
      },
    )
Behavior4/5

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

With no annotations provided, the description carries full disclosure burden. It effectively reveals the git auto-commit side effect and scope of destruction (model + content/meta). However, it omits critical safety context like whether deletion is reversible or what return value indicates success.

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?

Two sentences total. First establishes purpose and scope; second delivers critical behavioral constraint (git auto-commit). No filler, no redundancy, front-loaded with essential information. Every sentence earns its place.

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?

Adequately covers the destructive nature and persistence mechanism for a 2-parameter tool. Missing explicit description of return value or success/failure behavior, though no output schema exists to require this. Could strengthen with irreversibility warning given the destructive nature.

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?

Input schema has 100% description coverage ('Model ID to delete', 'Must be true to confirm deletion'). The description implies the confirm parameter's purpose through the deletion warning, but adds no explicit parameter syntax or format details beyond the schema. Baseline 3 appropriate for complete schema coverage.

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?

Description explicitly states 'Delete a model and its content/meta' — specific verb (Delete), resource (model), and scope (content/meta). This clearly distinguishes from sibling contentrain_content_delete (which deletes entries, not the model structure itself) and contentrain_model_save.

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

Usage Guidelines3/5

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

Provides specific operational guidance about git auto-commit and warns against manual editing of .contentrain/ files. However, lacks explicit guidance on when to use this versus contentrain_content_delete (destroy model structure vs. just content entries) or prerequisites like backup warnings.

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