Troubleshooting Guide
This guide helps you resolve common issues when using the PayloadCMS MCP Integration Plugin.
Table of Contents
- Common Issues
- Authentication Problems
- Collection Issues
- Server Configuration
- Media Upload Issues
- Performance Issues
- Debugging
Common Issues
Plugin Not Loading
Symptoms:
- No MCP server output in console
- Plugin appears to be ignored
Solutions:
-
Check PayloadCMS version compatibility:
1npm list payloadbash2 linesEnsure you're using PayloadCMS 3.0.0 or higher.
-
Verify plugin installation:
1npm list payload-plugin-mcpbash2 lines -
Check configuration syntax:
1// Ensure proper import and usage2import { PayloadPluginMcp } from 'payload-plugin-mcp'34export default buildConfig({5plugins: [6PayloadPluginMcp({7apiKey: process.env.MCP_API_KEY,8collections: 'all',9}),10],11})typescript12 lines
Server Not Starting
Symptoms:
- MCP server fails to start
- Port already in use errors
Solutions:
-
Check port availability:
1lsof -i :3001bash2 lines -
Change server port:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3server: {4port: 3002,5},6})typescript7 lines -
Check environment variables:
1echo $MCP_API_KEYbash2 lines
Authentication Problems
Invalid API Key
Symptoms:
- 401 Unauthorized errors
- Authentication failed messages
Solutions:
-
Verify API key format:
1# Generate a new secure key2openssl rand -hex 32bash3 lines -
Check environment variable:
1# In your .env file2MCP_API_KEY=your-secret-api-key-herebash3 lines -
Restart the server after changing environment variables
Missing Authorization Header
Symptoms:
- 401 Unauthorized errors
- "Authorization header required" messages
Solutions:
-
Include Authorization header in requests:
1curl -H "Authorization: Bearer your-api-key" \2http://localhost:3000/api/plugin/mcpbash3 lines -
Check MCP client configuration:
1// Ensure proper header configuration2const headers = {3Authorization: `Bearer ${process.env.MCP_API_KEY}`,4'Content-Type': 'application/json',5}typescript6 lines
Collection Issues
Collections Not Exposed
Symptoms:
- Collections not appearing in MCP tools
- "Collection not found" errors
Solutions:
-
Check collection configuration:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3collections: ['posts', 'users'], // Explicit list4})typescript5 lines -
Verify collection names:
1// Ensure collection names match exactly2collections: [3{4name: 'posts', // Must match collection name5slug: 'posts',6},7]typescript8 lines -
Check collection permissions:
1// Ensure collections have proper access control2collections: [3{4name: 'posts',5access: {6read: () => true,7create: () => true,8},9},10]typescript11 lines
Field Access Issues
Symptoms:
- Fields not appearing in responses
- "Field not found" errors
Solutions:
-
Check field configuration:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3collections: [4{5name: 'posts',6mcp: {7fields: ['title', 'content', 'author'], // Explicit field list8},9},10],11})typescript12 lines -
Verify field names:
1// Ensure field names match collection schema2fields: [3{4name: 'title',5type: 'text',6},7]typescript8 lines
Server Configuration
Port Conflicts
Symptoms:
- "Port already in use" errors
- Server fails to bind to port
Solutions:
-
Find and kill process using port:
1lsof -ti:3001 | xargs kill -9bash2 lines -
Use different port:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3server: {4port: 3002,5host: '0.0.0.0',6},7})typescript8 lines -
Check for other services:
1netstat -tulpn | grep :3001bash2 lines
Host Binding Issues
Symptoms:
- Server not accessible from external clients
- Connection refused errors
Solutions:
-
Check host configuration:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3server: {4host: '0.0.0.0', // Bind to all interfaces5},6})typescript7 lines -
Check firewall settings:
1# Ubuntu/Debian2sudo ufw allow 300134# CentOS/RHEL5sudo firewall-cmd --add-port=3001/tcp --permanent6sudo firewall-cmd --reloadbash7 lines
Media Upload Issues
File Size Limits
Symptoms:
- "File too large" errors
- Upload failures
Solutions:
-
Increase file size limit:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3media: {4maxFileSize: 52428800, // 50MB5},6})typescript7 lines -
Check server limits:
1// Next.js configuration2const nextConfig = {3experimental: {4serverComponentsExternalPackages: ['sharp'],5},6}typescript7 lines
File Type Restrictions
Symptoms:
- "File type not allowed" errors
- Upload rejected
Solutions:
-
Configure allowed types:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3media: {4allowedTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf'],5},6})typescript7 lines -
Check MIME type detection:
1file --mime-type your-file.jpgbash2 lines
Performance Issues
Slow Response Times
Symptoms:
- Long response times
- Timeout errors
Solutions:
-
Enable caching:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3cache: {4enabled: true,5ttl: 300, // 5 minutes6},7})typescript8 lines -
Optimize database queries:
1// Use select to limit fields2collections: [3{4name: 'posts',5mcp: {6fields: ['title', 'slug', 'publishedAt'],7},8},9]typescript10 lines -
Check database indexes:
1// Ensure proper indexing2collections: [3{4name: 'posts',5fields: [6{7name: 'title',8type: 'text',9index: true,10},11],12},13]typescript14 lines
Memory Usage
Symptoms:
- High memory consumption
- Out of memory errors
Solutions:
-
Limit result sets:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3pagination: {4defaultLimit: 10,5maxLimit: 100,6},7})typescript8 lines -
Enable streaming for large datasets:
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3streaming: {4enabled: true,5chunkSize: 1000,6},7})typescript8 lines
Debugging
Enable Debug Logging
1PayloadPluginMcp({2apiKey: process.env.MCP_API_KEY,3debug: true,4logging: {5level: 'debug',6format: 'json',7},8})
Check Server Logs
1# Enable verbose logging2DEBUG=payload-plugin-mcp:* npm run dev
Test MCP Connection
1# Test basic connectivity2curl -v http://localhost:3000/api/plugin/mcp34# Test with authentication5curl -H "Authorization: Bearer your-api-key" \6-H "Content-Type: application/json" \7http://localhost:3000/api/plugin/mcp
Use MCP Inspector
1# Install and run MCP Inspector2npx @modelcontextprotocol/inspector http://localhost:3000/api/plugin/mcp
Common Debug Commands
1# Check if server is running2ps aux | grep node34# Check port usage5netstat -tulpn | grep :300067# Check environment variables8env | grep MCP910# Test API endpoint11curl -I http://localhost:3000/api/plugin/mcp
Getting Help
If you're still experiencing issues:
- Check the logs for detailed error messages
- Verify your configuration against the examples
- Test with minimal configuration to isolate the issue
- Check GitHub issues for similar problems
- Create a new issue with detailed information about your setup