Skip to main content
Glama

Contentrain AI

npm: @contentrain/mcp npm: contentrain npm: @contentrain/query Agent Skills Docs License: MIT

Website · Docs · Discord · Twitter · LinkedIn

Extract, govern, and ship structured content from your codebase.

Contentrain is a content governance ecosystem for teams and AI agents. Agent generates. Human approves. Git records every change.

This repository holds its open-source tools (MIT, no account needed): the MCP engine, CLI, query SDK, rules, skills and types, plus the open packages of the WordPress migration pipeline (wp-import, emitter-astro, verify, astro-kit, decide). They help teams turn hardcoded UI text, docs, and structured content into a governed, reviewable content layer that lives in Git as structured JSON and Markdown. Agents can extract, create, translate, and update content, while Contentrain enforces schema, Git review, and portable file output.

Agent extracts or updates content → Contentrain standardizes → Human reviews → Any platform consumes

Try it in 30 seconds

npx contentrain init        # create .contentrain/ workspace
npx contentrain serve       # open the local review UI

That's it. You now have a governed content workspace with models, validation, review branches, and a local UI — no account, no cloud, no proprietary content format.

Start here:

Related MCP server: NomaCMS MCP Server

What Contentrain is for

  • Rescuing hardcoded strings from existing apps and turning them into structured, translatable content

  • Starting new projects with a real content layer instead of scattering copy across components

  • Serving the same content across web, docs, mobile, and backend systems from plain JSON and Markdown in Git

What it is not

  • Not an AI writing app

  • Not a database-first or dashboard-first CMS replacement for every team

  • Not a proprietary content runtime that locks your app to one platform

What it looks like

Before: Hardcoded strings scattered across your codebase — no structure, no translations, no review.

export default function Hero() {
  return (
    <section>
      <h1>Welcome to our platform</h1>
      <p>Start your free trial today</p>
      <button>Get Started</button>
    </section>
  )
}

After: Content lives in .contentrain/, typed and structured. Source files use i18n keys.

export default function Hero() {
  const t = useTranslations()
  return (
    <section>
      <h1>{t('hero.title')}</h1>
      <p>{t('hero.subtitle')}</p>
      <button>{t('hero.cta')}</button>
    </section>
  )
}
// .contentrain/content/marketing/hero/en.json
{
  "cta": "Get Started",
  "subtitle": "Start your free trial today",
  "title": "Welcome to our platform"
}

The normalize flow extracts strings, creates models, and patches your source files — all through reviewable git branches.

This is the strongest entry point into the product:

take the content chaos already in your codebase and turn it into a governed, reviewable content layer.

How it works

┌─────────────┐     ┌──────────────────┐     ┌──────────────┐
│  AI Agent    │────▶│  MCP (23 tools)  │────▶│ .contentrain/│
│  (decides)   │     │  (enforces)      │     │ (stores)     │
└─────────────┘     └──────────────────┘     └──────┬───────┘
                                                     │
                    ┌──────────────────┐              │
                    │  Review UI / Git │◀─────────────┘
                    │  (human approves)│
                    └──────────────────┘
  • Agent decides what content should exist and where it should come from

  • Contentrain enforces schemas, validation, canonical serialization, and git workflow

  • Human reviews through branches, PRs, or the local Serve UI

  • Output is plain JSON + Markdown that any language or framework can consume

4 content kinds

Kind

What it stores

Storage

Example

Collection

Multiple typed entries

JSON object-map

Blog posts, products, team

Singleton

Single entry per locale

JSON object

Hero section, site config

Document

Markdown + frontmatter

.md files

Docs, articles, changelog

Dictionary

Flat key-value strings

JSON flat map

i18n translations, UI labels

27 field types (string, email, url, image, relation, array, object, markdown, ...) with built-in validation.

Use your content anywhere

Content is plain JSON and Markdown. Any language reads it directly.

For TypeScript projects, generate a typed SDK:

npx contentrain generate
import { query, singleton, dictionary, document } from '#contentrain'

const hero    = singleton('hero').locale('en').get()
const posts   = query('blog-post').locale('en').include('author').all()
const labels  = dictionary('ui-labels').locale('tr').get('auth.login')
const article = document('docs').locale('en').bySlug('getting-started')

Works with Nuxt, Next.js, Astro, SvelteKit, Vue, React, Node, Go, Python, Flutter, and 20+ stacks.

Why teams use it

  • Git-native — every write goes through worktree isolation + review branches

  • Normalize flow — scan codebase for hardcoded strings → extract → create i18n-ready content → patch source files

  • MCP engine — 23 tools (5 more for media on a media-capable provider such as Studio) over stdio or HTTP transport, works with Claude Code, Cursor, Windsurf, or any MCP client

  • Provider-agnostic engine — the same tool surface runs over a local worktree, GitHub, or GitLab (self-hosted included) with zero tool-code changes. HTTP transport available for remote drivers such as Studio.

  • Canonical serialization — sorted keys, deterministic output, clean git diffs, conflict-free parallel edits

  • Agent rules & skills — behavioral policies and step-by-step workflows ship as npm packages

  • Serve UI — local web dashboard for browsing models, content, validation, and normalize status

  • Framework-agnostic — MCP doesn't know your framework. Agent + skills handle stack-specific logic

Agent Skills

This repo ships 16 Agent Skills — reusable workflow procedures that any AI coding agent can load on demand.

Install all skills to your agent:

npx skills add Contentrain/ai/packages/skills

Or install a specific skill:

npx skills add Contentrain/ai/packages/skills --skill contentrain-normalize

Skills work with Claude Code, Cursor, Windsurf, GitHub Copilot, OpenAI Codex, Gemini CLI, and 40+ other agents.

See AGENTS.md for the full skill catalog and agent guidance.

Packages

Package

npm

Role

@contentrain/mcp

npm

23 MCP tools + stdio / HTTP transport + Local / GitHub / GitLab providers

contentrain

npm

CLI + Serve UI + MCP stdio entrypoint

@contentrain/query

npm

Generated TypeScript query SDK

@contentrain/types

npm

Shared type definitions + constants

@contentrain/rules

npm

Agent quality rules for IDE integration

@contentrain/skills

npm

Workflow procedures + framework guides

@contentrain/wp-import

npm

WordPress WXR / REST → RawIR → .contentrain store

@contentrain/emitter-astro

npm

ProjectIR → a complete Astro project

@contentrain/verify

npm

SEO, indexing, link and asset gates for a built site

@contentrain/astro-kit

npm

Copy-in Astro components + catalog + builder mapping tables

@contentrain/decide

npm

Typed decisions — rule first, then Jev, then Claude Haiku — cached, budgeted, audited

Starter Templates

Production-ready templates with Contentrain content models, generated SDK client, and framework-specific patterns:

Template

Framework

Use Case

astro-blog

Astro

Blog / editorial

astro-landing

Astro

Landing page

next-commerce

Next.js

E-commerce storytelling

next-multi-surface-saas

Next.js

Marketing + app + docs unified

next-saas-dashboard

Next.js

SaaS dashboard UI copy

next-white-label-portal

Next.js

White-label / multi-tenant

nuxt-admin-console

Nuxt

Admin console / operations

nuxt-saas

Nuxt

SaaS marketing site

sveltekit-editorial

SvelteKit

Editorial / publication

vitepress-docs

VitePress

Documentation site

Each template is a GitHub template repo — click "Use this template" to start.

templates/astro-starter lives in this repository: the base a WordPress migration starts from — posts, pages, archives and permalinks, SEO, RSS, sitemap, search, Studio forms and comments, Gutenberg block styles — and it passes its own gates (astro check, knip, build + Pagefind, built-site checks) with no content. node scripts/starter-gates.mjs runs them on a standalone copy; CI runs them with the SDK at HEAD, empty and with the fixtures in templates/fixtures/ (wp-demo and others). The starter's own CI, which a delivered site keeps, adds Lighthouse.

Quick reference

npx contentrain init         # initialize project
npx contentrain setup        # configure the MCP server and rules for your IDE
npx contentrain import <wxr-or-url> # import a WordPress site into .contentrain
npx contentrain serve        # local review UI (port 3333)
npx contentrain serve --stdio # MCP over stdio for IDE agents
npx contentrain validate     # check content health
npx contentrain generate     # generate typed SDK client
npx contentrain status       # project overview
npx contentrain doctor       # setup health check
npx contentrain reconcile    # merge a diverged base branch, content-aware
npx contentrain studio login   # authenticate with Studio
npx contentrain studio connect # connect repo to Studio project

Documentation

  • 2-Minute Demo — the fastest way to understand the product

  • Getting Started — install, connect an agent, and run the first workflow

  • Normalize Guide — the main hardcoded-string rescue flow

  • Ecosystem Map — package-to-product bridges across AI and Studio

  • Contentrain Studio — open-core team operations for Git-native structured content, self-hostable or available as managed plans (Starter/Pro/Enterprise)

  • Full Docs — guides, package reference, and framework integration

The Contentrain ecosystem

Contentrain has four parts. This repository is the first.

Part

What it does

License

Open-source tools (Contentrain/ai, docs)

MCP engine, CLI, query SDK, normalize flow, rules, skills and types, plus the open WordPress migration packages. Developers and agents pull content out of code and structure it in their own repository.

MIT

Studio (Contentrain/studio, studio.contentrain.io)

The team operating surface for governed content: structured editing, review, roles and Git-backed operations. Media, CDN delivery, APIs and remote MCP (MCP Cloud) depend on plan and deployment. Managed plans or self-hosted.

AGPL-3.0 core, separately licensed ee/

Migrate (migrate.contentrain.io)

A paid service that moves WordPress sites to Astro, with their content and template structure.

Hosted service

Bridge (Contentrain/wordpress-bridge, WordPress.org)

A free WordPress plugin that exports posts, pages, custom fields and interface text as a validated Contentrain store (JSON + Markdown), as a ZIP or to your own GitHub repository.

GPL-2.0-or-later

Development

pnpm install && pnpm build && pnpm test
pnpm lint          # oxlint, warnings treated as errors
pnpm docs:check    # the docs must not state a number the code disagrees with

pnpm docs:check runs three checks, all needing pnpm build first:

  • facts — resolves counts (MCP tools, skills, field types, capability keys) from the packages that own them and compares every place the docs, this README and AGENTS.md state one.

  • examples — every @contentrain/* import in a documented example must name a real export, and no example may mix CommonJS with a top-level await (a shape that runs in no module system at all).

  • server.json — packages/mcp/server.json (the MCP Registry manifest) must name the current @contentrain/mcp version.

The facts and examples checks self-test against real defects from this repo's history before they run, so a check that stops catching fails loudly instead of passing silently.

See RELEASING.md for the versioning and publish workflow.

Community

If Contentrain AI is useful to you, consider giving it a star — it helps others discover the project.

License

MIT

Available Tools

23 tools
contentrain_applyA

Apply normalize operations. Two modes: "extract" writes agent-approved strings to Contentrain content files (source untouched), "reuse" patches source files with agent-provided replacement expressions. DRY RUN (default, dry_run:true): validates inputs, resolves conflicts, and returns a full preview — NO changes to disk or git. EXECUTE (dry_run:false): writes files to disk, commits to a branch, and requires branch health check to pass. Recommended workflow: always run dry_run first, review the preview, then call again with dry_run:false to execute. Normalize operations always use review workflow (never auto-merge).

Inputs: mode (required), scope, dry_run, patches, +1 more.

contentrain_branch_deleteA
Destructive

Delete a pending contentrain (cr/) branch that will not be merged — e.g. a branch left behind by a failed operation, or a superseded draft. Only cr/ branches can be deleted; the contentrain branch is protected. This is destructive: the branch and its unmerged commits are removed.

Inputs: branch (required), confirm (required).

contentrain_branch_listA
Read-onlyIdempotent

List pending contentrain (cr/*) branches with their merge status against the contentrain branch. Use this to discover branch names for contentrain_merge / contentrain_branch_delete, and to monitor branch-health limits (warning at 50, blocked at 80 unmerged).

Inputs: remote, unmerged_only.

contentrain_bulkA
Destructive

Batch operations on content entries: copy a locale, or delete many collection entries. All operations are auto-committed to git. To publish or change status, use contentrain_content_status. DRY RUN (dry_run:true): runs the whole operation in a throwaway worktree and reports exactly what would change — nothing is committed and no branch survives. Recommended workflow: preview with dry_run:true, review the counts, then call again to execute.

Inputs: model (required), operation (required), confirm, dry_run, +3 more.

contentrain_content_deleteA
Destructive

Delete content entries. For dictionaries, use "keys" to remove specific keys (omit to delete entire locale file). Changes are auto-committed to git — do NOT manually edit .contentrain/ files after calling this tool.

Inputs: model (required), confirm (required), id, keys, +2 more.

contentrain_content_listA
Read-onlyIdempotent

List content entries (read-only). Each entry carries its publish state under "meta" — status, plus publish_at/expire_at when set — read from the listed locale's meta; singletons and dictionaries carry it at the top level. Local and remote sessions return the same shape. Change status with contentrain_content_status. Returns data from .contentrain/ — do NOT manually create or modify content files.

Inputs: model (required), limit, filter, locale, +2 more.

contentrain_content_saveA
Destructive

Save content entries. Entry format varies by model kind: DICTIONARY — provide "locale" and "data" (flat key-value, all string values); "id" and "slug" are ignored; data keys are the identities. COLLECTION — provide "locale" and "data"; "id" is optional (auto-generated if omitted); "slug" is ignored. DOCUMENT — provide "slug" (required), "locale", and "data"; use the "body" key inside data for markdown content. SINGLETON — provide only "locale" and "data". MEDIA FIELDS (image/video/file): for a media-library asset, pass its storage path ("media/...") or URL; in cloud mode these are automatically normalized to absolute public delivery URLs on save (in markdown bodies too), so saved content renders in a browser anywhere with no SDK — in local mode the relative path is kept as-is. For external images (e.g. a CDN or Unsplash URL), pass the URL directly; it is saved untouched. Changes are auto-committed to git — do NOT manually edit .contentrain/ files after calling this tool.

Inputs: model (required), entries (required).

contentrain_content_statusA
DestructiveIdempotent

Change the status of content entries — this is how an entry is published, unpublished or archived. Address records the way their meta is laid out: COLLECTION — "entry_ids"; DOCUMENT — "slugs"; SINGLETON and DICTIONARY — neither (one record per locale). i18n models change every supported locale unless "locale" is given. Setting status "published" validates the targeted entries first; if they have errors, nothing is committed. Records already at the requested status are reported as unchanged and not rewritten. contentrain_content_list shows each entry's current status under "meta". Changes are committed to git and follow the project's review or auto-merge workflow — do NOT manually edit .contentrain/meta files.

Inputs: model (required), status (required), slugs, locale, +1 more.

contentrain_describeA
Read-onlyIdempotent

Get full schema of a single model (read-only). Do NOT manually create content files — use contentrain_content_save instead.

Inputs: model (required), locale, include_sample.

contentrain_describe_formatA
Read-onlyIdempotent

Describes the Contentrain content file format for any language/platform. Returns a comprehensive specification of the file structure, JSON formats, markdown conventions, meta files, and locale strategies.

Inputs: no named parameters.

contentrain_doctorA
Read-onlyIdempotent

Project health report (read-only). Returns structured checks: git, node, .contentrain/ structure, model parse, orphan content, branch pressure, SDK freshness. Pass usage: true for a deeper analysis of content-key references in source files (unused keys, duplicate dictionary values, locale coverage). Local-filesystem only — unavailable over remote providers.

Inputs: usage.

contentrain_initA

Initialize .contentrain/ structure. Changes are auto-committed to git — do NOT manually create .contentrain/ files.

Inputs: stack, domains, locales.

contentrain_mergeA
Destructive

Merge a review-mode branch into contentrain. Local git operation — no external platform needed. Merges the feature branch into the contentrain branch, advances the base branch via update-ref, selectively syncs .contentrain/ files to the working tree, and prunes the merged branch. Target by exact "branch" name, or resolve by "model" (+ optional "locale"/"latest").

Inputs: confirm (required), model, branch, latest, +1 more.

contentrain_model_deleteA
Destructive

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

Inputs: model (required), confirm (required).

contentrain_model_saveA
DestructiveIdempotent

Create or update a model definition. Changes are auto-committed to git — do NOT manually edit .contentrain/ files after calling this tool.

Inputs: id (required), i18n (required), kind (required), name (required), +7 more.

contentrain_reconcileA
Idempotent

Reconcile a diverged contentrain ↔ base-branch pair with a content-aware three-way merge. DRY RUN (default, dry_run:true): reports what would merge and which conflicts need a decision — touches nothing. EXECUTE (dry_run:false): performs the merge as a two-parent commit on contentrain and fast-forwards the base branch. Everything one side changed merges mechanically (entry-, key-, term+locale-level); only the same item changed differently on both sides becomes a conflict. Answer conflicts by passing resolutions (from the dry-run ids) and running again — a resolution whose values changed since the dry-run is dropped and the conflict re-reported. Recommended workflow: always run dry_run first, review the summary and conflicts, then execute.

Inputs: dry_run, resolutions.

contentrain_scaffoldB

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

Inputs: template (required), locales, with_sample_content.

contentrain_scanA
Read-onlyIdempotent

Scan project source code for content strings. Three modes: "graph" builds import/component graph for project intelligence, "candidates" extracts string literals with pre-filtering and pagination, "summary" provides quick overview stats. Read-only — no changes to disk or git. MCP finds strings deterministically; the agent decides what is content. Recommended workflow: start with "summary" or "graph" for orientation, then paginate through "candidates" to evaluate strings.

Inputs: mode, limit, paths, offset, +4 more.

contentrain_statusA
Read-onlyIdempotent

Get full project status (read-only). Returns config, models, context. Do NOT manually edit .contentrain/ based on this output.

Inputs: no named parameters.

contentrain_submitA
Idempotent

Push cr/* branches to remote. MCP is push-only — PR creation is handled by the platform. Do NOT manually push or create PRs.

Inputs: message, branches.

contentrain_validateA
Idempotent

Validate project content against model schemas. Detects required field violations, type mismatches, broken relations, secret leaks, i18n parity issues, and more. If fix:true, auto-fixes structural issues (canonical sort, orphan meta, missing locale files, stray non-i18n meta layout, scheduling keys an older content_save leaked into document frontmatter) and backfills a missing model title_field — do NOT manually edit .contentrain/ files. Content without meta gets meta with status published, matching what delivery already serves. A fix that would change whether an entry is delivered is listed in visibility_changes and left on its branch for review instead of auto-merged.

Inputs: fix, model.

contentrain_vocabulary_deleteA
Destructive

Remove canonical vocabulary terms by slug. Content already using a term is not touched — the vocabulary only advises. Changes are auto-committed to git.

Inputs: terms (required), confirm (required).

contentrain_vocabulary_saveA
Idempotent

Add or update canonical vocabulary terms. Terms nest as { "term-slug": { "en": "…", "tr": "…" } } — the OUTER key is the term, the INNER key is a locale. Merges with the existing vocabulary: a term you omit is untouched. Changes are auto-committed to git — do NOT manually edit .contentrain/vocabulary.json.

Inputs: terms (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 23 tools

    Disambiguation4/5

    Most tools target clearly distinct resources and actions (model vs content vs vocabulary vs branch), and descriptions clarify adjacent operations like merge (cr/* branch into contentrain) vs reconcile (diverged contentrain ↔ base three-way merge). A few pairs are mildly confusable: contentrain_status vs contentrain_doctor (project state vs health checks), contentrain_describe vs contentrain_describe_format (model schema vs file-format spec), and contentrain_bulk vs contentrain_content_delete (bulk delete overlaps single delete, though a cross-reference notes status changes belong elsewhere).

    Naming Consistency4/5

    All tools share a contentrain_ prefix and snake_case convention, and most follow a resource_action pattern (content_save, model_delete, branch_list, vocabulary_delete). A few deviate to bare verbs or nouns (init, scaffold, status, doctor, describe, apply), but the prefix and casing keep the set readable and predictable.

    Tool Count4/5

    At 23 tools the surface is on the heavy side, but the domain is genuinely broad—modeling, content lifecycle, vocabulary, git branch workflow, validation, scanning, and scaffolding—and each tool covers a distinct operation. Nothing looks redundant enough to trim, though a couple of read-only helpers could be consolidated.

    Completeness4/5

    Coverage is strong: init/scaffold, model save/delete (with describe and status exposing models), full content save/list/delete/status plus bulk, vocabulary save/delete, validation, scan/apply, and a complete branch lifecycle (submit/merge/reconcile/branch_list/branch_delete). Minor gaps exist—no explicit model_list or vocabulary_list—but these are workable via contentrain_status and describe.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server exposing content contract validators (SEO.md, PRODUCTHUNT.md, LINKEDIN.md) as tools so AI agents can verify generated content against concrete rules without maintaining linters. It provides linting and JSON-LD export tools with config and content passed as parameters, not file paths.
      4
      MIT