Skip to main content
Glama

Contentrain AI

npm: contentrain npm: @contentrain/mcp npm: @contentrain/query npm: @contentrain/types npm: @contentrain/rules npm: @contentrain/skills GitHub

AI-generated content governance infrastructure.

Contentrain is for teams that want to use AI agents to produce content without giving up structure, reviewability, or runtime safety.

Instead of treating content generation as a loose prompt workflow, Contentrain turns it into a governed system:

  • the agent decides what content should exist

  • MCP and CLI enforce deterministic writes, validation, and git workflow

  • humans review the result

  • content is delivered as plain JSON/Markdown to any platform (optional TypeScript SDK for convenience)

In one sentence:

Agent produces. Human approves. System standardizes.

โœจ Why This Exists

AI is very good at producing copy, labels, docs, translations, and structured content.

AI is not good at protecting your repository from drift.

Without a governance layer, AI-assisted content work usually turns into one or more of these problems:

  • hardcoded strings spread through source files

  • schema drift between teams and environments

  • inconsistent locales and missing translations

  • direct edits with no review branch or audit trail

  • content that is easy to generate but hard to consume safely at runtime

  • IDE agents that each invent their own workflow

Contentrain exists to solve that gap.

It is not just "AI for content".

It is a system for AI-assisted content operations:

  • content modeling

  • content storage

  • validation

  • normalization

  • review workflow

  • runtime consumption

  • agent guidance

๐Ÿงฉ What Contentrain Is

Published packages:

Contentrain is a monorepo containing the open-source building blocks of the ecosystem:

Package

Name

Role

packages/mcp

@contentrain/mcp

local-first MCP server and deterministic content operations

packages/cli

contentrain

CLI, local review UI, stdio MCP entrypoint

packages/types

@contentrain/types

shared domain contracts

packages/rules

@contentrain/rules

agent policy, quality rules, IDE bundles

packages/skills

@contentrain/skills

workflow procedures and framework guides

packages/sdk/js

@contentrain/query

generated query SDK and runtime

Together, these packages form a single workflow:

  1. detect or model content

  2. write it into a governed .contentrain/ structure

  3. validate it

  4. review it through branches and UI

  5. deliver content as plain JSON/Markdown to any platform

๐Ÿ”„ Core Workflow

1. Initialize a project

contentrain init creates the .contentrain/ workspace, project config, vocabulary, context file, git-safe defaults, and project-level agent rules.

npx contentrain init

2. Model and write content

Content is stored in a deterministic JSON and markdown structure inside .contentrain/.

The MCP layer handles:

  • config

  • models

  • entries

  • metadata

  • validation

  • branch lifecycle

The agent decides what to write. The system decides how it is stored and reviewed.

3. Validate and review

contentrain validate
contentrain diff
contentrain serve

Write operations can flow through review branches instead of mutating the base branch directly.

That gives you:

  • auditability

  • safer collaboration with agents

  • cleaner merge flow

  • branch-pressure awareness

4. Use your content

Content is plain JSON and Markdown โ€” any platform that reads files can consume it directly.

For TypeScript projects, optionally generate a typed SDK client:

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

const hero = singleton('hero').locale('en').get()
const posts = query('blog-post').locale('en').all()

โš™๏ธ How It Works

MCP is deterministic infrastructure

@contentrain/mcp is the execution engine.

It manages:

  • filesystem writes

  • canonical serialization

  • schema-aware validation

  • git-backed branch workflow

  • normalize scan and apply flows

  • context tracking

It does not decide content semantics for you.

That boundary is deliberate.

The agent is the intelligence layer

The agent decides:

  • whether a string is user-facing

  • how to model content

  • what key or entry should be created

  • which replacement expression is correct for the current framework

This split matters.

Contentrain is designed around:

  • MCP = deterministic infra

  • Agent = intelligence

That is the reason the system stays predictable even when the content work itself is AI-assisted.

Rules and skills are first-class

Most tools stop at APIs.

Contentrain also packages how agents should behave:

  • @contentrain/rules defines policy and constraints

  • @contentrain/skills defines workflow playbooks and framework-specific guidance

This makes agent behavior part of the product surface instead of leaving it implicit.

๐Ÿง  Key Design Principles

  • JSON only
    Contentrain uses JSON and markdown. No YAML storage layer.

  • Git is mandatory
    Content work is part of the repository lifecycle, not a side channel.

  • Review is a product feature
    Branch-backed review is not an afterthought; it is part of the core workflow.

  • Platform-independent output Content is plain JSON and Markdown. Any language (Go, Python, Swift, Kotlin, Rust) can consume it. The TypeScript SDK is optional convenience, not a requirement.

  • Framework-agnostic core Stack-specific decisions belong to the agent and framework guides, not to the MCP engine.

  • Local-first
    The MCP layer works locally and does not depend on a hosted Git provider API.

๐Ÿš€ What Makes Contentrain Different

Contentrain is not best described as a CMS.

It is closer to a content governance operating layer for codebase-native teams.

It combines traits from several categories:

  • headless CMS: models, entries, locales

  • GitOps: review branches, merge flow, auditability

  • MCP tooling: agent-native local execution

  • code generation: typed runtime client

  • agent operations: rules and workflow skills

That combination is the point.

The problem Contentrain solves is not just "where should content live?"

It is:

How do we let AI agents work on content inside a real codebase without turning the repository into chaos?

๐Ÿš€ Quick Start

Requirements:

  • Node.js 22+

  • pnpm 9+

  • Git in PATH

Install dependencies:

pnpm install

Initialize a project:

contentrain init

Inspect state:

contentrain status
contentrain doctor

Generate the SDK:

contentrain generate

Open the local UI:

contentrain serve

Use MCP over stdio for IDE agents:

contentrain serve --stdio

๐Ÿ›  Example Use Cases

Normalize hardcoded strings

Scan a product codebase, extract user-facing strings into governed content, and patch source files through a two-phase normalize workflow.

Run AI-assisted docs or marketing workflows

Let an agent propose docs, landing page copy, or UI labels while keeping schema, locale coverage, and review flow intact.

Build app-facing content without a separate CMS

Store content in the repo as plain JSON. Consume from any platform โ€” Vue, React, Next, Nuxt, Astro, Node, Go, Python, Swift, Flutter, Expo, or React Native. Optionally use the TypeScript SDK for type-safe queries.

Standardize agent behavior across IDEs

Ship the same behavioral rules to Claude Code, Cursor, Windsurf, and generic agent setups.

๐Ÿ“ฆ Package Guide

If you want to go deeper package by package:

๐Ÿ“š Documentation

  • ai.contentrain.io โ€” full documentation site

  • Package READMEs for public package contracts

  • RELEASING.md for versioning and publish flow

  • packages/rules/ and packages/skills/ for agent-facing operational guidance

๐ŸŒ Contentrain Studio

For team collaboration, visual content review, and content CDN for non-web platforms โ€” Contentrain Studio extends the open-source tools with a hosted governance UI.

๐Ÿงช Development

From the monorepo root:

pnpm build
pnpm test
pnpm lint
pnpm typecheck

๐Ÿšข Release

Contentrain uses Changesets for package-specific versioning, changelogs, tags, and npm publishing.

pnpm changeset
pnpm version-packages
pnpm release:check
pnpm release

For the full release workflow, see RELEASING.md.

๐Ÿ“„ License

MIT

-
security - not tested
A
license - permissive license
-
quality - not tested

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