Scaffolding Collection Types, seeding realistic test entries, and refactoring schemas across a growing Strapi project eats hours you'd rather spend shipping features. The repetitive cycle of defining fields in the Admin Panel, writing seed scripts, and manually updating entries after a schema change is familiar to anyone who's managed content infrastructure at scale.
The Model Context Protocol (MCP) offers a way out: it's an MCP intro that lets AI coding assistants invoke external tools through a unified interface. This guide shows how to use Claude Code with Strapi, a headless CMS, to speed up schema work and test-data generation.
One thing to know upfront: an MCP RFC is actively in development, with an open RFC on GitHub. It hasn't shipped yet. This guide uses the community @sensinum/strapi-plugin-mcp plugin from the Market, which is available now and is intended for development and local use. By the end, you'll have a foundation for using Claude Code alongside Strapi 5 that you can adapt to your own projects.
In brief:
- Install a community MCP plugin and connect it to Claude Code in under ten minutes
- Generate Content-Types, seed entries, and refactor schemas from plain-language prompts
- Scope API tokens and environment variables so production stays safe
- Troubleshoot the three failure modes that catch most first-time setups
What You Need Before You Start
Required Versions and Tools
- Node.js v18+ (with active LTS or maintenance LTS versions such as v20 and v22 recommended for Strapi 5)
- Strapi 5 (v5.0.0 or higher)
- Claude Code CLI installed and authenticated
- npm v6+, yarn, or pnpm
- Python if using SQLite (required by some native build dependencies in install docs)
Assumed Knowledge
You should be comfortable with REST basics, running a local Node.js project, and setting environment variables via .env files. Familiarity with the Admin Panel docs helps, but isn't strictly required since every step includes the exact navigation path.
Install and Configure the Strapi MCP Plugin
This section uses the community @sensinum/strapi-plugin-mcp plugin (v1.1.0 at the time of writing) since the native server isn't shipped yet. The plugin exposes a streamable HTTP endpoint that Claude Code connects to, giving it access to schema introspection, service discovery, and component details from your running Strapi instance.
Security warning: This plugin exposes internal Strapi functionality and should never be enabled in production. It's designed for development and local use only.
Spin Up a Strapi 5 Project
If you already have a Strapi 5 project, skip ahead. Otherwise, create one:
npx create-strapi@latest my-strapi-project --skip-cloudThe interactive prompts walk you through language choice, database selection, and package manager. SQLite is fine for following along. Once installation completes:
cd my-strapi-project
npm run developRegister your admin account at http://localhost:1337/admin when the browser opens. This account is what you'll use to generate API tokens in the next step.
Install the MCP Plugin
From your Strapi project root, install the plugin:
npm install @sensinum/strapi-plugin-mcpNext, create or update your plugin configuration. Add the following to config/plugins.js (or config/plugins.ts for TypeScript docs projects):
// config/plugins.js
module.exports = {
mcp: {
enabled: true,
config: {
session: {
type: "memory",
},
},
},
};The plugin docs note that the memory session type stores MCP sessions in-process with a default TTL of ten minutes and a maximum of 20 concurrent sessions. That's more than enough for local development. Restart Strapi to pick up the new plugin:
npm run developStrapi 5 auto-discovers installed plugins, so no additional registration step is needed. The MCP endpoint is now live at http://localhost:1337/api/mcp/streamable.
Generate a Scoped API Token
Navigate to Settings → Global settings → API Tokens in the Admin Panel, then click Create new API Token.
| Field | Recommended Value |
|---|---|
| Name | mcp-dev-token |
| Description | Local MCP development access |
| Token duration | Unlimited (for local dev) |
| Token type | Full access |
For a tighter setup, choose Custom and enable only the Content-Types you need Claude Code to interact with. This follows the principle of least privilege outlined in Strapi's best practices.
After clicking Save, the token appears once at the top of the page with a copy button. Copy it immediately. Without an encryption key configured, you won't be able to view it again.
Configure Environment Variables
Store the token in a .env file at the project root:
# .env
STRAPI_API_TOKEN=your-generated-token-hereMake sure your .gitignore includes:
.env
.env.local
.env.*.localThis keeps tokens out of version control. For team setups, maintain a .env.example file with placeholder values so collaborators know which variables to set.
Connect Claude Code to Your Strapi Instance
Register the MCP Server in Claude Code
The fastest path is the CLI. From your Strapi project directory, run:
claude mcp add --transport http strapi http://localhost:1337/api/mcp/streamableThis writes the configuration to the correct file automatically, which matters more than you'd think. Claude Code reads MCP config from MCP docs. Editing ~/.claude/settings.json instead, which is a common mistake, means the server is silently ignored and just doesn't appear.
If you prefer to configure manually, create a .mcp.json file in your project root:
{
"mcpServers": {
"strapi": {
"type": "http",
"url": "http://localhost:1337/api/mcp/streamable"
}
}
}Here's what each field does:
type: For streamable HTTP transport, settypeto"http"if required by your plugin configuration.url: The MCP endpoint exposed by the plugin. This matches the route the plugin registers in Strapi.
Note: The .mcp.json file can live either at the project root directory or inside a .claude/ subdirectory, though some current behavior suggests better support at the root in practice.
Verify the Connection
Start Claude Code in your project directory and run the /mcp slash command. You should see strapi listed with a status indicator. Then test with a natural-language prompt:
List the Content-Types in my Strapi project.Claude Code calls the plugin's content-types tool and returns something like:
Found the following content types in your Strapi instance:
- plugin::users-permissions.user (Collection Type)
- admin::user (Collection Type)If you see Content-Types listed, the connection is working. If Claude responds without referencing MCP tools, check the troubleshooting section below.
Build AI-Powered Content Workflows with Claude Code
The plugin ships with seven built-in tools focused on introspection: listing Content-Types, inspecting schemas, discovering services, and examining components. Claude Code combines these with its ability to read and write files in your project.
That's where this setup becomes practical for day-to-day work. Rather than just querying your Strapi instance, Claude can introspect your schemas via MCP and then generate the exact files your project needs for this headless CMS workflow.
Scaffold a Collection Type from a Plain-Language Spec
Here's a prompt that creates a Product Collection Type with fields and relations docs:
Using the Strapi MCP tools, first call list_content_types to see what already exists and avoid naming conflicts.
Then generate a Product collection type for Strapi 5 with:
- name (string, required, max 150 chars)
- slug (uid, targetField: name, required)
- description (richtext)
- price (decimal, required, min: 0)
- sku (string, unique, required)
- category (relation, manyToOne to api::category.category)
- images (media, multiple images)
- inStock (boolean, default: true)
Output the schema.json file for src/api/product/content-types/product/schema.json and the scaffolding for controllers, routes, and services.
Claude Code calls content-types via MCP, confirms no naming conflict, and generates the complete directory structure:
src/api/product/
├── content-types/
│ └── product/
│ └── schema.json
├── controllers/
│ └── product.ts
├── routes/
│ └── product.ts
└── services/
└── product.tsThe resulting schema.json follows Strapi 5 models with the correct kind, collectionName, info, and attributes structure. After Claude writes the files, restart Strapi and the new Content-Type appears in the Content-Type Builder.
What just happened: Claude used MCP to inspect your existing schemas, then used that context to generate conflict-free files that Strapi picks up on restart. That cuts out repeated Admin Panel clicks and manual JSON authoring.
Note: Content-Type creation modifies your project's source files, so this runs against your local dev instance. The Content-Type Builder is disabled in production by design.
Seed Entries at Scale Without Writing a Seed Script
Once your Content-Types exist, populating them with realistic test data is the next time sink. Instead of writing a custom seed script, try this:
I need to seed 20 Product entries into my Strapi 5 instance.
First, call content-type-by-name for "api::product.product" to confirm the exact field structure.
Then generate a seed script that uses the Strapi REST API to create 20 realistic products across categories like electronics, clothing, and home goods.
Each product should have:
- A unique, realistic name and auto-derived slug
- Price between 9.99 and 299.99
- A unique SKU format like "ELEC-001", "CLTH-001"
- inStock: true for 15 entries, false for 5
- Realistic description text (2-3 sentences)
The script should use STRAPI_API_TOKEN from environment variables and output a summary table of created entries with documentId, name, sku, and price.Claude can generate a Node.js script that calls the REST API with proper authentication headers:
// seed-products.js
const STRAPI_URL = process.env.STRAPI_URL || "http://localhost:1337";
const API_TOKEN = process.env.STRAPI_API_TOKEN;
const headers = {
Authorization: `Bearer ${API_TOKEN}`,
"Content-Type": "application/json",
};
// ... product data array and creation loopEach successful POST /api/products returns a response with the new entry's documentId (used instead of numeric id in Strapi 5 API responses, per Strapi 5 changes). Strapi 5 also returns flattened response data with fields at the top level, not nested under data.attributes.
What just happened: MCP gave Claude the exact field names and types, so the generated seed script matches your schema without guesswork. You run the script once and move on.
Refactor Existing Content Safely
Schema refactoring is where things get risky. Renaming a field, adding a Dynamic Zone, or restructuring relations can leave orphaned data behind. Here's a three-phase approach with a safety gate:
I need to refactor the Product content type. This is a DESTRUCTIVE operation, so follow these phases:
PHASE 1: AUDIT (read-only)
1. Call content-type-by-name("api::product.product") — capture current schema
2. Report the current field list and types
PHASE 2: GENERATE MIGRATION PLAN (output only, no execution)
Produce:
a) Updated schema.json that renames "body" to "legacyBody" and adds a new "content" dynamic zone with text-block and image-block components
b) A migration script that copies existing legacyBody data into text-block components in the new content field
c) A backup command I should run first
PHASE 3: CONFIRMATION GATE
Show me the schema diff and wait for explicit confirmation before writing any files.Claude responds with the audit results, the updated schema, a migration script, and a clear gate:
⚠️ READY TO APPLY
Schema diff:
~ body (richtext) → legacyBody (richtext)
+ content (dynamiczone): new field
+ author (relation → api::author.author): new field
+ seoMeta (component → shared.seo-meta): new field
Recommended backup before proceeding:
yarn strapi export --no-encrypt -f backup-pre-refactor
Reply 'CONFIRM APPLY' to write files, or 'ABORT' to cancel.The backup command uses Strapi's data management export, which creates an archive of your content, schemas, and configuration. If the migration goes sideways, restore with yarn strapi import -f ./backup-pre-refactor.tar.gz. One important constraint: Strapi 5 doesn't support down migrations, so if you need to roll back a migration, you'll need to revert it manually before restoring or importing a backup.
What just happened: Claude combined MCP introspection with a structured prompt pattern to produce an audited, reversible migration plan. The confirmation gate helps prevent accidental destructive changes.
Tip: Add a CLAUDE.md file to your project root noting that your project uses Strapi 5, the documentId field (UUID) instead of numeric id, and the directory guide for Content-Types. This helps prevent Claude from generating v4-style code.
Troubleshoot Common Issues with Claude Code and Strapi
MCP Server Not Appearing in Claude Code
This is the most common first-time issue, and it's frustratingly silent. Claude Code shows "No MCP servers configured" with no indication that a config file was found but ignored.
Most likely cause: The configuration landed in the wrong file. Claude Code reads MCP servers from MCP config. Files like ~/.claude/settings.json are ignored, so the server simply doesn't appear.
Fix: Use claude mcp add instead of manual JSON editing. Then verify:
claude mcp listIf you see your server listed here but not inside Claude Code, check for scope shadowing. A broken local-scoped entry overrides a working user-scoped entry. The hierarchy is: local > project > user.
401 or 403 Errors from the Plugin
| Error | Cause | Fix |
|---|---|---|
| 401 | Token missing, expired, or malformed | Regenerate in Admin Panel → Settings → API Tokens; verify the Authorization: Bearer <token> header format |
| 403 | Token valid but lacks permission for the requested Content-Type | Edit the token settings in the Admin Panel to grant access |
| 403 | Request from non-allowlisted IP | Check the plugin's allowedIPs config; default is ["127.0.0.1", "::1"] (localhost only) |
If permissions look correct but errors persist, restart Strapi. Permission changes aren't always hot-reloaded.
Slow Responses or Timeouts
If Claude Code hangs for 60 seconds and then fails with a timeout, the issue is usually transport-level, not Strapi performance.
Check the endpoint path first. In some MCP HTTP setups, clients connect to a /sse endpoint. Verify that the MCP endpoint responds to the expected HTTP methods by testing with curl:
curl -s http://localhost:1337/api/mcpFor general slowness, scope your prompts to single Content-Types rather than asking Claude to operate across your entire schema at once. Batch large seeding operations into groups of five to ten entries per prompt rather than requesting 50 at once. Run /doctor inside Claude Code to check for configuration issues that might cause intermittent failures.
Where to Take This Next
You now have a working Claude Code and Strapi loop: introspect schemas, scaffold Content-Types, seed data, and refactor content from conversational prompts. Three directions from here:
Watch for the native Strapi MCP server. The open RFC at GitHub Discussions describes a built-in /mcp endpoint with bearer token auth and capability-level scoping. The March 2026 call confirmed active development alongside features like FlowGine and Better Auth. When it ships, it will provide a native integration option.
Wire the plugin into a CI job for automated content seeding. The seed scripts Claude generates run standalone with node seed-products.js, which slots into any CI pipeline for staging environment setup.
Pair this with a frontend framework like Next.js for end-to-end AI-assisted development. Claude Code can scaffold your Strapi content model, seed it, and then generate the corresponding frontend components that consume the REST API. Deploying to Strapi Cloud gets the backend side handled, while the frontend deploys wherever you prefer.
For more on how MCP works under the hood, Strapi's What is MCP blog post covers the protocol architecture and why it matters for content workflows.
Get Started in Minutes
npx create-strapi-app@latest in your terminal and follow our Quick Start Guide to build your first Strapi project.Theodore is a Technical Writer and a full-stack software developer. He loves writing technical articles, building solutions, and sharing his expertise.