MCP HubMCP Hub
misterboe

strapi-mcp-server

by: misterboe

strapi mcp server

20created 19/12/2024
Visit
strapi

📌Overview

Purpose: The Strapi MCP Server serves as a Model Context Protocol server that allows AI assistants to interact seamlessly with the Strapi CMS through a standardized interface for content management.

Overview: This server provides a framework for performing REST API operations and handling various content types in Strapi, while ensuring a robust set of features including security, schema validation, and multi-version support.

Key Features:

  • Schema Introspection: Automatically retrieves and validates the structure of data models, ensuring accurate interactions with the CMS.

  • REST API Support: Facilitates CRUD operations with built-in validation and version handling, enhancing efficiency in managing content.


Strapi MCP Server

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 and REST API operations.

⚠️ IMPORTANT DISCLAIMER: This software is provided as-is and should NOT be used in production environments without thorough testing and validation. Use at your own risk for research, learning, or development purposes only.

Changelog

Version 2.3.0 - Documentation & Configuration Enhancement

  • Added comprehensive project documentation.
  • Expanded configuration options with better version detection.
  • Enhanced troubleshooting guides for common issues.
  • Detailed REST API documentation with practical examples.
  • Best practices guide for content management.
  • Fixed version parsing from different format patterns.
  • Improved error messaging with version-specific guidance.

Version 2.2.0 - Security & Version Handling Update

  • Added strict write protection policy.
  • Enhanced version format support.
  • Integrated documentation into server capabilities.
  • Improved error handling and validation.

Version 2.1.0

  • Improved compatibility with both Strapi v4 and v5.
  • Enhanced error messages with version-specific hints.
  • Updated documentation with clear examples for both versions.

Features

  • Schema introspection
  • REST API support with validation
  • JWT authentication
  • Content type management
  • Multiple server support
  • Automatic schema validation
  • Write protection policy
  • Integrated documentation

Installation

You can use this server directly with npx in your Claude Desktop configuration:

{
  "mcpServers": {
    "strapi": {
      "command": "npx",
      "args": ["-y", "@bschauer/strapi-mcp-server@2.4.0"]
    }
  }
}

Configuration

Create a configuration file at ~/.mcp/strapi-mcp-server.config.json:

{
  "myserver": {
    "api_url": "http://localhost:1337",
    "api_key": "your-jwt-token-from-strapi-admin",
    "version": "5.*" // Optional: Specify Strapi version
  }
}

Getting a JWT Token

  1. Log in to your Strapi admin panel.
  2. Create an API token with appropriate permissions.
  3. Add the token to your config file under the appropriate server name.

Usage

List Available Servers

strapi_list_servers();

Content Types

// Get all content types from a specific server
strapi_get_content_types({
  server: "myserver",
});

// Get components with pagination
strapi_get_components({
  server: "myserver",
  page: 1,
  pageSize: 25,
});

REST API

The REST API provides CRUD operations with built-in validation:

// Query content with filters
strapi_rest({
  server: "myserver",
  endpoint: "api/articles",
  method: "GET",
  params: {
    filters: {
      title: {
        $contains: "search term",
      },
    },
  },
});

// Create new content
strapi_rest({
  server: "myserver",
  endpoint: "api/articles",
  method: "POST",
  body: {
    data: {
      title: "New Article",
      content: "Article content",
      category: "news",
    },
  },
});

// Update content
strapi_rest({
  server: "myserver",
  endpoint: "api/articles/123",
  method: "PUT",
  body: {
    data: {
      title: "Updated Title",
      content: "Updated content",
    },
  },
});

// Delete content
strapi_rest({
  server: "myserver",
  endpoint: "api/articles/123",
  method: "DELETE",
});

Version Differences (v4 vs v5)

v4

  • Uses numeric IDs
  • Nested attribute structure

v5

  • Document-based IDs
  • Flat data structure
  • Enhanced JWT security

Security Features

Write Protection Policy

  • All write operations require explicit authorization.
  • Protected operations are logged and validated.

Best Practices

  1. Always check schema first with strapi_get_content_types.
  2. Use proper plural/singular forms for endpoints.
  3. Include error handling in your queries.
  4. Validate URLs before upload.
  5. Always include the complete data object when updating.
  6. Use filters to optimize query performance.

Troubleshooting

Common issues and solutions:

  1. 404 Errors: Check endpoint format and existence.
  2. Authentication Issues: Verify JWT token validity.
  3. Version-Related Issues: Ensure correct version specification in config.
  4. Write Protection Errors: Confirm operation authorization.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT