A comprehensive expert system for Payload CMS development, providing complete guidance on collections, fields, hooks, access control, queries, plugins, and advanced patterns.
This Kiro Power is your complete companion for Payload CMS development, offering:
- Complete Payload CMS guidance - Collections, fields, hooks, access control, queries
- Security best practices - Critical pitfalls and how to avoid them
- Advanced patterns - Multi-tenant, RBAC, plugin development, custom endpoints
- Type-safe development - TypeScript patterns and generated types
- Performance optimization - Query optimization, transaction handling, caching
- Collections & Fields - All field types, validation, conditional fields, relationships
- Access Control - Row-level security, role-based access, multi-tenant patterns
- Hooks & Lifecycle - Data transformation, validation, side effects
- Queries & APIs - Local API, REST, GraphQL with complex filtering
- Plugin Development - Creating reusable Payload plugins
- Database Adapters - MongoDB, PostgreSQL, SQLite with transactions
- Advanced Features - Jobs, custom endpoints, localization, storage
- Open Kiro IDE
- Open the Powers panel (Ctrl/Cmd + Shift + P β "Open Kiro Powers")
- Search for "Payload CMS Expert"
- Click "Install"
Add this to your .kiro/settings/mcp.json:
{
"mcpServers": {
"payload-cms-expert": {
"command": "uvx",
"args": ["payload-cms-expert-mcp-server@latest"],
"env": {
"FASTMCP_LOG_LEVEL": "ERROR"
},
"disabled": false,
"autoApprove": []
}
}
}Once installed, activate the power in Kiro:
@payload-cms-expert activate
Then ask questions like:
- "How do I create a collection with access control?"
- "Show me how to implement role-based permissions"
- "How do I create custom field components?"
- "What's the best way to handle file uploads?"
- "How do I optimize queries for performance?"
This power includes comprehensive steering files covering:
- Collections - Basic collections, auth, uploads, drafts, live preview
- Fields - All field types, validation, conditional fields, relationships
- Hooks - Collection hooks, field hooks, lifecycle management
- Access Control - Row-level security, RBAC, multi-tenant patterns
- Queries - Local API, REST, GraphQL with complex filtering
- Endpoints - Custom API routes, authentication, webhooks
- Adapters - Database, storage, email adapters with transactions
- Plugin Development - Creating and publishing Payload plugins
- Critical Security Patterns - Access control pitfalls and solutions
- Transaction Safety - Proper
reqthreading in hooks - Query Optimization - Performance best practices
The power emphasizes these essential security patterns:
// β SECURITY BUG: Bypasses access control even with user
await payload.find({
collection: 'posts',
user: someUser, // Access control is IGNORED!
})
// β
SECURE: Actually enforces user permissions
await payload.find({
collection: 'posts',
user: someUser,
overrideAccess: false, // REQUIRED for security
})// β
CORRECT: Thread req through nested operations
const afterChange: CollectionAfterChangeHook = async ({ doc, req }) => {
await req.payload.create({
collection: 'audit-log',
data: { docId: doc.id },
req, // Maintains transaction atomicity
})
}Here's what the power can help you build:
// Enhanced Posts collection with access control
export const Posts: CollectionConfig = {
slug: 'posts',
access: {
read: ({ req: { user } }) => {
if (user) return true
return { status: { equals: 'published' } }
},
create: ({ req: { user } }) => Boolean(user),
update: ({ req: { user } }) => {
if (!user) return false
if (user.roles?.includes('admin')) return true
return { author: { equals: user.id } }
},
},
hooks: {
beforeChange: [
async ({ data, req, operation }) => {
if (operation === 'create' && req.user) {
data.author = req.user.id
}
return data
},
],
},
fields: [
{ name: 'title', type: 'text', required: true },
slugField({ name: 'slug', useAsSlug: 'title' }),
{ name: 'content', type: 'richText', required: true },
{ name: 'author', type: 'relationship', relationTo: 'users' },
{
name: 'readingTime',
type: 'number',
virtual: true,
hooks: {
afterRead: [
({ siblingData }) => {
const wordCount = siblingData.content?.toString().split(' ').length || 0
return Math.ceil(wordCount / 200)
},
],
},
},
],
}This power also includes comprehensive guidance for Payload's MCP (Model Context Protocol) plugin, enabling AI integration with your CMS.
pnpm add @payloadcms/plugin-mcpimport { buildConfig } from 'payload'
import { mcpPlugin } from '@payloadcms/plugin-mcp'
const config = buildConfig({
collections: [{
slug: 'posts',
fields: [],
}],
plugins: [
mcpPlugin({
collections: {
posts: {
enabled: true,
description: 'Blog posts with content about technology and development',
},
},
}),
],
}){
"mcp.servers": {
"Payload": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://127.0.0.1:3000/api/mcp",
"--header",
"Authorization: Bearer YOUR-API-KEY"
]
}
}
}{
"mcpServers": {
"Payload": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://localhost:3000/api/mcp",
"--header",
"Authorization: Bearer YOUR-API-KEY"
]
}
}
}mcpPlugin({
mcp: {
tools: [{
name: 'getPostStats',
description: 'Get statistics about posts',
handler: async (args, req) => {
const stats = await req.payload.find({
collection: 'posts',
where: {
createdAt: { greater_than: args.since },
},
})
return {
content: [{
type: 'text',
text: `Found ${stats.totalDocs} posts since ${args.since}`,
}],
}
},
parameters: z.object({
since: z.string().describe('ISO date string'),
}).shape,
}],
},
})- Start your Payload server
- Navigate to
/admin - Go to MCP β API Keys
- Create new API key with appropriate permissions
- Use the key in your MCP client configuration
- Start with basic collections and fields
- Learn about access control fundamentals
- Understand hooks and lifecycle events
- Practice with simple queries
- Implement role-based access control
- Create custom field components
- Build custom API endpoints
- Work with file uploads and storage
- Develop custom plugins
- Implement multi-tenant architecture
- Optimize for performance
- Integrate with external services
This power is designed to be comprehensive and up-to-date. If you find areas for improvement:
- Fork this repository
- Add or update steering files in the appropriate sections
- Test your changes with real Payload projects
- Submit a pull request with detailed descriptions
steering/
βββ collections.md # Collection configurations
βββ fields.md # All field types and patterns
βββ hooks.md # Lifecycle hooks and patterns
βββ access-control.md # Security and permissions
βββ queries.md # Database queries and APIs
βββ endpoints.md # Custom API endpoints
βββ adapters.md # Database and storage adapters
βββ advanced.md # Jobs, auth, localization
βββ plugin-development.md # Creating Payload plugins
- Payload CMS Documentation
- Payload GitHub Repository
- Payload Examples
- Payload Templates
- Model Context Protocol
This Kiro Power is open source and available under the MIT License.
Made with β€οΈ for the Payload CMS community
Get started by asking: "How do I create a secure blog with Payload CMS?"