What is Graft

What Graft does, how it works, and where to start reading.

Get started3 min read

Most sites need content that someone other than the developer edits: pages, docs, product listings. The usual answer is a hosted CMS, which moves that content out of your repository and into someone else's database. You lose diffs, review, and branches, and your app reads it back through an API with no types.

Graft keeps the content in your repository as Markdown files. It checks every file against a schema you write in TypeScript, builds an index your app can query, and gives your components fully typed results. AI agents can edit the same files through the Model Context Protocol (MCP), the open standard that lets agents use tools, within limits you set.

How it works

┌────────────────────────┐      ┌────────────────────────┐      ┌────────────────────────┐
│   Markdown in Git      │ ───► │     graft compile      │ ───► │   Typed reads in app   │
│  content/pages/*.mdx   │      │  check + build index   │      │  Next.js, Astro, React │
└────────────────────────┘      └────────────────────────┘      └────────────────────────┘
            ▲                                                                │
            │                                                                │
            └─────────── You (editor, Git, CLI) and agents (MCP) ────────────┘
  1. You write content as files. Markdown, or MDX (Markdown that can include components), in your project's content/ folder. You commit, branch, and review it like code.
  2. graft compile checks it and builds an index. Every file is checked against your schema, and a bad file stops the compile with a message saying what to fix. The index is a searchable copy of your content. Your files stay the source of truth, so the index can be deleted and rebuilt at any time.
  3. Your app reads typed content. Graft has a package for each major framework. A read returns the document with types taken from your schema, so your editor knows every field.
  4. Agents work the same loop. An agent connected over MCP can draft pages, search content, and read your schema. It uses the same operations you do, so the same checks apply.

Static or Postgres?

The index lives in one of two storage engines. You write and read content the same way on both.

Storage engineUse it forWhat you run
Static (what graft init sets up)Blogs, documentation, marketing sites, portfoliosNothing. The index is a SQLite file built by graft compile.
PostgresSites where users write data at runtime, such as form submissions, comments, and orders. Also preview branches.A Postgres database.

Start with static. Switching later is one line in graft.config.ts, and Storage engines explains when to switch and how.

How these docs are organized

  • Get started explains what Graft is and walks you through a first project.
  • Frameworks has one guide per framework, from install to a rendered page.
  • Content covers the schema, reading, search, assets, and the editing UI.
  • Runtime data covers data your users write, such as form submissions and orders, and who may write it. This needs the Postgres engine.
  • Agents & MCP covers connecting agents and every tool they can call.
  • Deploy & operate covers hosting, security, previews, and migrations.
  • Reference lists every command, setting, API, and error code, plus a glossary of Graft's terms.

You should be comfortable with TypeScript and with one of the frameworks below. You do not need to know Zod, MCP, or Postgres before you start. Each one is introduced where you first need it.

Where to go next

New to Graft? Read Getting started next. It takes about ten minutes and ends with your content rendered in your app. If you already know what you are building, jump straight to it: