Payload MCP
Provides integration with Payload CMS 3.0, generating tools for creating collections, globals, fields, authentication, and configuration from TypeScript type definitions.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Payload MCPcreate a posts collection with title and content fields"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Payload MCP
A Model Context Protocol (MCP) server for Payload CMS 3.0 that auto-generates tools from Payload's TypeScript type definitions.
Features
Auto-generates MCP tools from Payload CMS 3.0 TypeScript definitions
Provides an HTTP endpoint for LLMs to generate up-to-date Payload code
Bridges the gap between LLM training cutoff and current Payload CMS API
Supports all major Payload CMS features:
Collections
Globals
Fields
Authentication
Configuration
Related MCP server: MCP-Typescribe
How It Works
Parse Type Definitions: Uses ts-morph to analyze Payload's .d.ts files
Generate Tools: Converts types into MCP tools with parameters and code-gen logic
Serve Endpoint: Provides an /api/v1/payload-mcp endpoint for LLMs to query
Generate Code: Returns properly formatted Payload CMS 3.0 code
Getting Started
Prerequisites
Node.js (v18 or higher)
pnpm (v8 or higher)
Installation
# Clone the repository
git clone https://github.com/yourusername/payload-mcp.git
cd payload-mcp
# Install dependencies
pnpm install
# Generate tools from Payload CMS type definitions
pnpm generate-tools
# Start the development server
pnpm devUsage
The MCP server exposes an endpoint at /api/v1/payload-mcp that accepts POST requests with the following structure:
{
"model": "claude-3-opus-20240229",
"tools": [
{
"name": "createCollection",
"parameters": {
"slug": "posts",
"fields": [
{
"name": "title",
"type": "text",
"required": true
}
],
"admin": {
"useAsTitle": "title"
}
}
}
]
}The server will respond with generated Payload CMS 3.0 code:
{
"id": "uuid",
"context": [
{
"id": "uuid",
"data": {
"code": "import { CollectionConfig } from 'payload/types';\n\nexport const postsCollection: CollectionConfig = {\n slug: 'posts',\n fields: [\n {\n \"name\": \"title\",\n \"type\": \"text\",\n \"required\": true\n }\n],\n // Add other properties as needed from params\n ...{\n \"admin\": {\n \"useAsTitle\": \"title\"\n }\n}\n};\n",
"message": "Collection 'posts' created successfully"
}
}
],
"tool_results": [
{
"tool_name": "createCollection",
"output": {
"code": "import { CollectionConfig } from 'payload/types';\n\nexport const postsCollection: CollectionConfig = {\n slug: 'posts',\n fields: [\n {\n \"name\": \"title\",\n \"type\": \"text\",\n \"required\": true\n }\n],\n // Add other properties as needed from params\n ...{\n \"admin\": {\n \"useAsTitle\": \"title\"\n }\n}\n};\n",
"message": "Collection 'posts' created successfully"
}
}
]
}Available Tools
The following tools are auto-generated from Payload CMS 3.0 type definitions:
createCollection: Creates a collection configuration
createGlobal: Creates a global configuration
createField: Creates a field configuration
createAuth: Creates authentication configuration
createConfig: Creates the main Payload CMS configuration
Development
Regenerating Tools
If you update Payload CMS or want to regenerate the tools:
# Update Payload
pnpm add payload@latest
# Regenerate tools
pnpm generate-toolsLogging
The server uses Winston for logging. By default, logs are written to the logs directory with the following files:
combined.log: All logs (info level and above)error.log: Error logs onlyexceptions.log: Uncaught exceptionsrejections.log: Unhandled promise rejections
The server uses npm logging levels (from highest to lowest priority):
error: 0,
warn: 1,
info: 2,
http: 3,
verbose: 4,
debug: 5,
silly: 6By default, the log level is set to info, which means only logs with level info, warn, and error will be recorded. To see more detailed logs:
Set to
verboseto see tool registration detailsSet to
debugfor even more detailed debugging informationSet to
sillyfor the most verbose output
You can change the log level by setting the LOG_LEVEL environment variable:
# Run with verbose logging (shows tool registration)
LOG_LEVEL=verbose pnpm start
# Run with debug logging (more detailed)
LOG_LEVEL=debug pnpm start
# Or set in .env file
# LOG_LEVEL=verboseTesting
To test the auto-generated tools:
# Start the server
pnpm dev
# In another terminal, run the test script
node test-generated-tools.mjsLicense
ISC
Sponsor
Govcraft is a one-person shop—no corporate backing, no investors, just me building useful tools. If this project helps you, sponsoring keeps the work going.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Govcraft/payload-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server