Getting Started
Prerequisites
- Node.js 18.20.2+ or 20.9.0+ or 22.0.0+
- Payload CMS 3.0.0+
- pnpm 9+ (recommended) or npm
Installation
Install the plugin using your preferred package manager:
pnpm
1pnpm add payload-plugin-mcp
bash
2 lines
npm
1npm install payload-plugin-mcp
bash
2 lines
yarn
1yarn add payload-plugin-mcp
bash
2 lines
Environment Setup
Create or update your .env file with the required configuration:
1# Required: API key for MCP server authentication2MCP_API_KEY=your-secret-api-key-here
bash
3 lines
Tip: Generate a secure API key using a tool like
openssl rand -hex 32or use a UUID generator.
Basic Configuration
Add the plugin to your Payload configuration:
1// payload.config.ts2import { buildConfig } from 'payload'3import { PayloadPluginMcp } from 'payload-plugin-mcp'45export default buildConfig({6collections: [7// your existing collections8],9plugins: [10PayloadPluginMcp({11apiKey: process.env.MCP_API_KEY,12collections: 'all', // Expose all collections13defaultOperations: {14list: true, // Enable listing documents15get: true, // Enable getting single documents16create: false, // Disable creation (read-only by default)17update: false, // Disable updates (read-only by default)18delete: false, // Disable deletion (read-only by default)19},20}),21],22})
typescript
23 lines
Start Your Application
Start your Payload CMS application:
1pnpm dev
bash
2 lines
You should see output similar to:
1ā PayloadCMS MCP Plugin initialized2š§ Collections exposed: posts, users, media3š ļø Tools generated: 64š MCP HTTP server: http://0.0.0.0:3000/api/plugin/mcp5š Authentication: Enabled6š posts: list, get7š users: list, get8š media: list, get
bash
9 lines
Verify Installation
Test that the plugin is working by making a request to the MCP endpoint:
1curl -H "Authorization: Bearer your-api-key" http://localhost:3000/api/plugin/mcp
bash
2 lines
You should receive a response with information about available tools and the server status.
Test with MCP Inspector
Use the MCP Inspector to test your server:
1npx @modelcontextprotocol/inspector http://localhost:3000/api/plugin/mcp
bash
2 lines
This will open the MCP Inspector at http://localhost:6274 where you can:
- Enter your Authorization header (
Bearer your-api-key) - Test MCP tool execution
- Explore available tools and their schemas
- Debug connection issues
Next Steps
- Configure collections for more advanced setups (see README.md)
- Set up Claude Desktop integration (see README.md)
- Deploy to production (see examples/vercel/)
Important: Never commit your API key to version control. Always use environment variables for sensitive configuration.