Building BrewCMS: An Agent-Ready Content Operating System for Next.js
Why we moved beyond traditional headless CMS SaaS platforms toward a local-first content operating system with deterministic Content IR, immutable revision trees, Model Context Protocol (MCP) governance, and sub-millisecond in-process SQLite evaluation.
Modern web architecture has spent the last decade migrating content management from legacy monolithic CMS installations to API-first headless SaaS platforms. While decoupling presentation from content was a necessary evolution, it created an unintended new problem: content infrastructure became expensive, fragile, and bound to remote HTTP network round-trips.
Every page load on an edge-rendered or server-rendered website was suddenly forced to make 20ms to 80ms HTTP network round-trips to remote SaaS endpoints (Contentful, Sanity, Strapi Cloud). Worse, teams were paying hundreds to thousands of dollars per month in SaaS subscription fees just to store markdown and relational taxonomy data that easily fits on high-speed NVMe storage.
With the emergence of autonomous AI coding assistants and agentic engineering workflows, a second crisis emerged: developers want AI agents to query, inspect, and draft content directly. But giving LLM agents direct, unconstrained write permissions to production databases or headless APIs introduces catastrophic risks of hallucinations and brand drift.
To resolve both dilemmas, I created BrewCMS: an open-source, agent-ready Content Operating System built specifically for Next.js 15 applications.
BrewCMS is engineered around four core architectural principles:
1. Pure Domain Kernel: At the center is a zero-dependency domain core. Business logic, document lifecycles, and revision histories are completely isolated from web frameworks and database drivers.
2. Local-First In-Process Storage: Instead of forcing an external database daemon or remote API, BrewCMS leverages Node.js 22 native node:sqlite with Write-Ahead Logging (WAL). When embedded directly in Next.js, Server Components query the SQLite B-tree in <0.2ms-two orders of magnitude faster than any remote HTTP CMS-with zero native C++ compilation dependencies.
3. Deterministic Content IR: Raw markdown is never trusted as a mutable database blob. Instead, every document is compiled into a deterministic Content Intermediate Representation (AST) accompanied by a cryptographic SHA-256 content hash, enabling immutable revision trees and zero-risk rollbacks.
4. Bounded Agent Autonomy via MCP: Rather than unstructured chatbot prompts, BrewCMS provides a first-class Model Context Protocol (MCP) server. AI agents in Cursor, Claude Desktop, or custom agent loops call typed tools (brew_create_draft, brew_request_publish). Crucially, high-risk operations (publishing and unpublishing) are governed by strict human approval policy gates.
BrewCMS is now running in production as the native content engine for CoffeeDiscussions and this developer portfolio. Both sites run with 100% self-contained content pipelines, sub-millisecond query response, zero SaaS bills, and full AI agent interoperability.
- ▪Headless CMS SaaS creates unnecessary network latency and recurring vendor bills for content that easily lives on local disk.
- ▪Node.js 22 native node:sqlite enables zero-dependency in-process B-tree evaluation in <0.2ms.
- ▪AI agents operating on content require deterministic AST validation and strict human policy gates before publishing.