Getting Started
Contentrain AI is an open-source content governance infrastructure. Your AI agent creates and manages content through Model Context Protocol (MCP) tools — Contentrain ensures that content is structured, validated, reviewed, and deliverable to any platform.
Prerequisites
- Node.js 22+
- Git
- An MCP-compatible AI agent (Claude Code, Cursor, Windsurf, or similar)
Choose Your Path
# Start with structured content from day one
npx contentrain init# Already have hardcoded strings? Extract them
npx contentrain init
# Then tell your agent: "Scan my project and extract all hardcoded strings"Quick Start: New Project
1. Initialize
npx contentrain initThis creates .contentrain/ in your project root with configuration, model definitions, and content directories. If the directory is not a git repo, it runs git init automatically.
2. Connect your AI agent
Add the Contentrain MCP server to your IDE:
{
"mcpServers": {
"contentrain": {
"command": "npx",
"args": ["contentrain", "serve", "--stdio"]
}
}
}{
"mcpServers": {
"contentrain": {
"command": "npx",
"args": ["contentrain", "serve", "--stdio"]
}
}
}{
"mcpServers": {
"contentrain": {
"command": "npx",
"args": ["contentrain", "serve", "--stdio"]
}
}
}3. Create a content model
Tell your agent:
Create a hero section model with title, subtitle, and CTA fieldsThe agent calls contentrain_model_save and creates:
.contentrain/
models/hero-section.json
content/marketing/hero-section/en.json4. Add content
Add content to the hero section: title is "Build faster with AI",
subtitle is "Content governance for any platform"5. Use your content
The content is plain JSON — you can read it directly from any language or platform:
{
"title": "Build faster with AI",
"subtitle": "Content governance for any platform"
}For TypeScript projects, generate a typed SDK client for convenience:
npx contentrain generateimport { singleton } from '#contentrain'
const hero = singleton('hero-section').locale('en').get()
console.log(hero.title) // "Build faster with AI"SDK is optional
The generated TypeScript SDK provides type-safe queries, but the content files are plain JSON and Markdown. Any platform that reads JSON — Go, Python, Swift, Kotlin, Rust — can consume your content directly.
6. Review with the local UI
npx contentrain serveOpen http://localhost:3333 to browse models, content, validation results, and pending branches.
Quick Start: Existing Project
Already have hardcoded strings scattered across your codebase? The Normalize Flow extracts them into structured content:
You: "Scan my project and extract all hardcoded strings"
Agent: scans 47 files → finds 523 strings → classifies → creates models → patches source
You: review in UI → approve → structured content, ready for any languageSee the Normalize Flow guide for the complete walkthrough.
The Content Pipeline
Every operation follows the same governance pipeline:
Agent generates → MCP validates → Human reviews → Git commits → Content delivered- Agent decides what to create (your AI, your choice — BYOA)
- MCP enforces structure, validation, and canonical serialization
- Human reviews and approves through the local UI or Studio
- Git stores everything — full history, rollback, audit trail
- Content is delivered as plain JSON/Markdown to any platform
Packages
All packages are published on npm:
| Package | Description | Install |
|---|---|---|
contentrain | CLI (init, serve, generate, validate) | npx contentrain init |
@contentrain/mcp | 13 MCP tools for AI agents | pnpm add @contentrain/mcp |
@contentrain/query | TypeScript query SDK (optional) | pnpm add @contentrain/query |
@contentrain/types | Shared TypeScript types | pnpm add @contentrain/types |
@contentrain/rules | AI agent quality rules | pnpm add @contentrain/rules |
@contentrain/skills | AI agent workflow procedures | pnpm add @contentrain/skills |
What's Next?
- Core Concepts — Models, content kinds, domains, and the governance architecture
- MCP Tools — All 13 tools available to your agent
- Normalize Flow — Extract hardcoded strings from existing code
- i18n Workflow — Add languages to your content
- Framework Integration — Platform-specific setup patterns
Contentrain Studio
When you need team collaboration, visual diff review, and content CDN for non-web platforms — Contentrain Studio extends everything with a hosted governance UI.