This specialized MCP server enhances your Payload CMS 3.0 development experience with code validation, template generation, and project scaffolding capabilities. It helps you build better applications by following best practices.
Before getting started, make sure you have:
railway run --service=YOUR_SERVICE_ID
You can also run the MCP server locally:
# Install globally
npm install -g payload-cms-mcp
# Run the server
payload-cms-mcp
The easiest deployment option is using Railway's one-click deployment:
After deployment, use these CLI commands to configure:
npm install -g @railway/cli
railway login
railway link
In Cursor Settings > MCP Servers, set Command to: railway run
Once configured, you can use these tools in your AI prompts:
Can you validate this Payload CMS collection code?
```typescript
export const Posts = {
slug: 'posts',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'content',
type: 'richText',
}
],
admin: {
useAsTitle: 'title',
}
}
What are the best practices for implementing access control in Payload CMS collections?
Generate a Payload CMS collection for a blog with title, content, author, and published date fields. Include timestamps and versioning.
Generate a Payload CMS image field with validation that requires alt text and has a description in the admin panel.
Scaffold a Payload CMS project called "blog-platform" with MongoDB, authentication, and collections for posts, categories, and users. Include a global for site settings.
Here's a typical workflow with the MCP server:
For example:
User: I need to create a Payload CMS collection for a product catalog.
AI: [Uses generate_collection tool]
Here's a collection template for your product catalog:
```typescript
import { CollectionConfig } from 'payload/types';
export const Products: CollectionConfig = {
slug: 'products',
admin: {
useAsTitle: 'name',
defaultColumns: ['name', 'price', 'category', 'inStock'],
group: 'Shop',
},
access: {
read: () => true,
},
fields: [
{
name: 'name',
type: 'text',
required: true,
},
{
name: 'description',
type: 'richText',
},
{
name: 'price',
type: 'number',
required: true,
},
{
name: 'category',
type: 'relationship',
relationTo: 'categories',
required: true,
},
{
name: 'images',
type: 'array',
fields: [
{
name: 'image',
type: 'upload',
relationTo: 'media',
required: true,
},
{
name: 'altText',
type: 'text',
required: true,
}
]
},
{
name: 'inStock',
type: 'checkbox',
defaultValue: true,
},
],
timestamps: true,
}
For best results with the MCP server:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "payload-cms-mcp" '{"command":"npx","args":["-y","payload-cms-mcp"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"payload-cms-mcp": {
"command": "npx",
"args": [
"-y",
"payload-cms-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"payload-cms-mcp": {
"command": "npx",
"args": [
"-y",
"payload-cms-mcp"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect