home / mcp / apostrophe code generator mcp server

Apostrophe Code Generator MCP Server

Provides an MCP server to generate Apostrophe CMS modules via Claude AI, returning ready-to-save code for pieces, pages, widgets, and bundles.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "andrewmat32-apostrophe-cms-generator": {
      "command": "node",
      "args": [
        "/absolute/path/to/apostrophe-code-generator/mcp-server/index.js"
      ]
    }
  }
}

You can extend Apostrophe CMS with AI-assisted code generation through an MCP server. This MCP server acts as a bridge between Claude Code and your local generator, enabling you to issue generation requests and receive ready-to-save module code for pieces, pages, widgets, and bundles. It is designed to streamline your workflow by handling AI-driven module creation, design token extraction, and automatic registration within your Apostrophe project.

How to use

Interact with the MCP server using your MCP client or Claude Code integration. You initiate a generation request for a specific module type (piece, page, widget, or bundle), provide a name and description, configure fields and relationships, and decide on styling options like design token integration and BEM-style SCSS. The MCP server processes your request, returns the generated module code, and optionally auto-registers the module in your project’s modules.js. You can then save the generated code to your Apostrophe project and review it in your IDE.

How to install

Prerequisites to run the MCP server include Node.js and npm, plus Claude Code for AI-powered generation. You will also need an Anthropic API key to access Claude Code.

Key steps to get started on a typical system are:

  • Install Node.js (version 18.x or newer)
  • Install npm (comes with Node.js)
  • Install Claude Code globally: npm install -g @anthropic-ai/claude-code
  • Configure Claude Code with your API key: claude configure
  • Ensure your project uses ES Modules: set "type": "module" in your project’s package.json
  • Install dependencies for the MCP server (from within the generator directory): npm install

Available tools

list_apostrophe_projects

List all discovered Apostrophe projects in the parent directory that contain an app.js with a shortName property.

generate_piece

Generate a piece module, including its schema and fields, to be saved in the project's modules.

generate_page

Generate a page module, including its schema and any related piece-page configuration and views.

generate_widget

Generate a reusable widget module with fields, relationships, and a corresponding frontend template.

generate_bundle

Generate a complete bundle consisting of a piece, a piece-page, and a widget in one operation.

save_generated_code

Save the generated files from the history or current generation to your Apostrophe project.