Payload CMS MCP server

Provides validation, query, and code generation services for Payload CMS 3.0 development, enabling developers to validate collections, execute SQL-like queries against validation rules, and scaffold complete projects with Redis integration for persistence.
Back to servers
Setup instructions
Provider
MATMAX WORLDWIDE
Release date
Mar 15, 2025
Language
TypeScript
Package
Stats
864 downloads
70 stars

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.

Prerequisites

Before getting started, make sure you have:

  • Node.js 18+ (required for Payload CMS 3.0)
  • An active Railway account
  • A Railway API token (create one at railway.app/account/tokens)
  • Basic familiarity with Payload CMS 3.0 concepts

Installation

Configure with Cursor IDE

  1. Open Cursor Settings
  2. Go to MCP Servers section
  3. Add a new MCP server
  4. Name it "Payload CMS 3.0 MCP"
  5. Set Transport Type to "Command"
  6. Set Command to: railway run --service=YOUR_SERVICE_ID
  7. Save the configuration

Run Locally

You can also run the MCP server locally:

# Install globally
npm install -g payload-cms-mcp

# Run the server
payload-cms-mcp

Deploy to Railway

The easiest deployment option is using Railway's one-click deployment:

  1. Go to Railway.app
  2. Select "Deploy from GitHub repo"
  3. Search for "Matmax-Worldwide/payloadcmsmcp"
  4. Click "Deploy Now"

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

Using the MCP Server

Once configured, you can use these tools in your AI prompts:

Validation Tools

Validate Payload CMS Code

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',
  }
}

Query Best Practices

What are the best practices for implementing access control in Payload CMS collections?

Code Generation

Generate Collection Template

Generate a Payload CMS collection for a blog with title, content, author, and published date fields. Include timestamps and versioning.

Generate Field

Generate a Payload CMS image field with validation that requires alt text and has a description in the admin panel.

Project Scaffolding

Scaffold a Payload CMS project called "blog-platform" with MongoDB, authentication, and collections for posts, categories, and users. Include a global for site settings.

Example Workflow

Here's a typical workflow with the MCP server:

  1. Generate a collection template with specific fields
  2. Validate the generated code for best practices
  3. Query for specific validation rules to improve the code
  4. Generate additional components like hooks or endpoints
  5. Scaffold a complete project structure when ready

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,
}

Effective Prompt Tips

For best results with the MCP server:

  1. Be specific about requirements: The more details you provide, the more tailored the output will be.
  2. Specify relationships: Clearly indicate how collections relate to each other.
  3. Include validation needs: Mention any validation rules or constraints for fields.
  4. Describe admin UI preferences: Specify how you want the collection to appear in the admin panel.
  5. Mention hooks and access control: Include any specific business logic or security rules you need.

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later