|
| 1 | +# Strapi MCP Server |
| 2 | + |
| 3 | +A Model Context Protocol server for interacting with Strapi CMS. This server enables AI assistants to interact with your Strapi instance through a standardized interface, supporting content types, REST API, and GraphQL queries. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- 🔍 Schema introspection |
| 8 | +- 🔄 REST API support |
| 9 | +- 📊 GraphQL support |
| 10 | +- 📸 Media upload handling |
| 11 | +- 🔐 JWT authentication |
| 12 | +- 📝 Content type management |
| 13 | +- 🖼️ Image processing with format conversion |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +You can use this server directly with npx in your Claude Desktop configuration: |
| 18 | + |
| 19 | +```json |
| 20 | +{ |
| 21 | + "mcpServers": { |
| 22 | + "strapi": { |
| 23 | + "command": "npx", |
| 24 | + "args": [ |
| 25 | + "-y", |
| 26 | + "@bschauer/strapi-mcp-server" |
| 27 | + ], |
| 28 | + "env": { |
| 29 | + "API_URL": "http://localhost:1337", |
| 30 | + "JWT": "your-jwt-token" |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +## Configuration |
| 38 | + |
| 39 | +### Environment Variables |
| 40 | + |
| 41 | +- `API_URL`: Your Strapi instance URL (e.g., `http://localhost:1337`) |
| 42 | +- `JWT`: Your Strapi JWT token for authentication |
| 43 | + |
| 44 | +### Getting a JWT Token |
| 45 | + |
| 46 | +1. Log in to your Strapi admin panel |
| 47 | +2. Create an API token with appropriate permissions |
| 48 | +3. Use this token as the `JWT` environment variable |
| 49 | + |
| 50 | +## Features |
| 51 | + |
| 52 | +### Content Type Management |
| 53 | +- Automatic schema introspection |
| 54 | +- Support for both Strapi 4 and 5 |
| 55 | +- Handles collection types and single types |
| 56 | + |
| 57 | +### REST API |
| 58 | +- Full CRUD operations |
| 59 | +- Pagination support |
| 60 | +- Relation population |
| 61 | +- Field selection |
| 62 | + |
| 63 | +### GraphQL Support |
| 64 | +- Complex queries |
| 65 | +- Field selection |
| 66 | +- Pagination |
| 67 | +- Error handling |
| 68 | + |
| 69 | +### Media Handling |
| 70 | +- Image upload from URLs |
| 71 | +- Format conversion (JPEG, PNG, WebP) |
| 72 | +- Quality control |
| 73 | +- Metadata management |
| 74 | + |
| 75 | +## Usage Examples |
| 76 | + |
| 77 | +### Content Types |
| 78 | +```javascript |
| 79 | +// Get all content types |
| 80 | +strapi_get_content_types() |
| 81 | + |
| 82 | +// Get components |
| 83 | +strapi_get_components() |
| 84 | +``` |
| 85 | + |
| 86 | +### REST API |
| 87 | +```javascript |
| 88 | +// Query content |
| 89 | +strapi_rest({ |
| 90 | + endpoint: 'api/articles', |
| 91 | + method: 'GET', |
| 92 | + params: { populate: '*' } |
| 93 | +}) |
| 94 | +``` |
| 95 | + |
| 96 | +### Media Upload |
| 97 | +```javascript |
| 98 | +// Upload image |
| 99 | +strapi_upload_media({ |
| 100 | + url: "https://example.com/image.jpg", |
| 101 | + format: "webp", |
| 102 | + quality: 80, |
| 103 | + metadata: { |
| 104 | + name: "My Image", |
| 105 | + caption: "Image Caption", |
| 106 | + alternativeText: "Alt Text" |
| 107 | + } |
| 108 | +}) |
| 109 | +``` |
| 110 | + |
| 111 | +## Best Practices |
| 112 | + |
| 113 | +1. Always check schema first with `strapi_get_content_types` |
| 114 | +2. Use proper plural/singular forms for endpoints |
| 115 | +3. Include error handling in your queries |
| 116 | +4. Validate URLs before upload |
| 117 | +5. Use appropriate content population strategies |
| 118 | + |
| 119 | +## Troubleshooting |
| 120 | + |
| 121 | +Common issues and solutions: |
| 122 | + |
| 123 | +1. 404 Errors |
| 124 | + - Check endpoint plural/singular form |
| 125 | + - Verify content type exists |
| 126 | + - Ensure correct API URL |
| 127 | + |
| 128 | +2. Authentication Issues |
| 129 | + - Verify JWT token is valid |
| 130 | + - Check token permissions |
| 131 | + - Ensure proper environment variable setup |
| 132 | + |
| 133 | +3. GraphQL Issues |
| 134 | + - Verify GraphQL is enabled in Strapi |
| 135 | + - Check query syntax |
| 136 | + - Ensure proper field selection |
| 137 | + |
| 138 | +## License |
| 139 | + |
| 140 | +MIT License - see LICENSE file for details |
| 141 | + |
| 142 | +## Contributing |
| 143 | + |
| 144 | +Contributions are welcome! Please feel free to submit a Pull Request. |
0 commit comments