Strapi CMS MCP server

Integrates Strapi CMS content into workflows, enabling manipulation of data for content management and querying in Strapi-powered applications.
Back to servers
Provider
bschauer
Release date
Jan 08, 2025
Language
TypeScript
Package
Stats
1.4K downloads
30 stars

The Strapi MCP Server provides a Model Context Protocol interface for interacting with Strapi CMS instances. It allows AI assistants to communicate with your Strapi content through a standardized interface, supporting content types and various REST API operations.

Installation

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

{
  "mcpServers": {
    "strapi": {
      "command": "npx",
      "args": ["-y", "@bschauer/[email protected]"]
    }
  }
}

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.*" 
  }
}

You can configure multiple Strapi instances by adding them to this file.

Version Configuration

The server supports various version formats:

  • Wildcard: "5.", "4."
  • Specific: "4.1.5", "5.0.0"
  • Simple: "v4", "v5"

This helps the server provide version-specific guidance and handle API differences.

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();
// Shows version information and differences between v4 and v5

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 comprehensive 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",
});

Media Upload

// Upload image with automatic optimization
strapi_upload_media({
  server: "myserver",
  url: "https://example.com/image.jpg",
  format: "webp",
  quality: 80,
  metadata: {
    name: "My Image",
    caption: "Image Caption",
    alternativeText: "Alt Text",
  },
});

Version Differences (v4 vs v5)

Key differences between Strapi versions that the server handles automatically:

v4

  • Uses numeric IDs
  • Nested attribute structure
  • Data wrapper in responses
  • Traditional REST patterns
  • External i18n plugin

v5

  • Document-based IDs
  • Flat data structure
  • Direct attribute access
  • Enhanced JWT security
  • Integrated i18n support
  • New Document Service API

Security Features

Write Protection Policy

The server implements a strict write protection policy:

  • All write operations require explicit authorization
  • Protected operations include:
    • POST (Create)
    • PUT (Update)
    • DELETE
    • Media Upload
  • Each operation is 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. Start with minimal queries and add population only when needed
  6. Always include the complete data object when updating
  7. Use filters to optimize query performance
  8. Leverage built-in schema validation
  9. Check version compatibility for your operations
  10. Follow the write protection policy guidelines

REST API Tips

Filtering

// Filter by field value
params: {
  filters: {
    title: "Exact Match";
  }
}

// Contains filter
params: {
  filters: {
    title: {
      $contains: "partial";
    }
  }
}

// Multiple conditions
params: {
  filters: {
    $and: [{ category: "news" }, { published: true }];
  }
}

Sorting

params: {
  sort: ["createdAt:desc"];
}

Pagination

params: {
  pagination: {
    page: 1,
    pageSize: 25
  }
}

Population

// Basic request without population
params: {
}

// Selective population when needed
params: {
  populate: ["category"];
}

// Detailed population with field selection
params: {
  populate: {
    category: {
      fields: ["name", "slug"];
    }
  }
}

Troubleshooting

Common issues and solutions:

  1. 404 Errors

    • Check endpoint plural/singular form
    • Verify content type exists
    • Ensure correct API URL
    • Check if using correct ID format (numeric vs document-based)
  2. Authentication Issues

    • Verify JWT token is valid
    • Check token permissions
    • Ensure token hasn't expired
  3. Version-Related Issues

    • Verify version specification in config
    • Check data structure matches version
    • Review version differences documentation
  4. Write Protection Errors

    • Ensure operation is authorized
    • Check if operation is protected
    • Verify request follows security policy

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later