Strapi MCP Server
Strapi MCP 服务器
用于与 Strapi CMS 交互的模型上下文协议服务器。该服务器使 AI 助手能够通过标准化接口与您的 Strapi 实例进行交互,支持内容类型和 REST API 操作。
⚠️重要免责声明:本软件是在人工智能技术的帮助下开发的。它按原样提供,未经彻底测试和验证,请勿在生产环境中使用。代码可能包含错误、安全漏洞或意外行为。仅供研究、学习或开发用途使用,风险自负。
变更日志
版本 2.3.0 - 文档和配置增强
📚 在 CLAUDE.md 中添加了全面的项目文档
⚙️ 扩展配置选项,提供更好的版本检测
🛠️ 增强常见问题的故障排除指南
🔄 详细的 REST API 文档和实际示例
📝 内容管理最佳实践指南
🐛 修复了不同格式模式的版本解析
🔍 使用特定于版本的指导改进错误消息
版本 2.2.0 - 安全和版本处理更新
🔒 添加了严格的写保护策略
🔄 增强版本格式支持(5.*、4.1.5、v4 等)
📚 将文档集成到服务器功能中
🚫 删除了连接提示(现在在功能中)
⚡ 改进的错误处理和验证
🔍 添加了特定版本差异指南
📋 增强服务器功能文档
版本 2.1.0
改进了与 Strapi v4 和 v5 的兼容性
删除自动验证以支持版本之间的不同数据结构
使用特定于版本的提示增强错误消息
简化请求处理,为客户提供更多控制权
更新了两个版本的文档,其中包含清晰的示例
Related MCP server: Directus MCP Server
特征
🔍 Schema 自省
🔄 REST API 支持验证
📸 媒体上传处理
🔐 JWT 身份验证
📝 内容类型管理
🖼️ 图像处理与格式转换
🌐 多服务器支持
✅ 自动模式验证
🔒 写保护策略
📚 集成文档
🔄 版本兼容性管理
安装
您可以在 Claude Desktop 配置中直接将此服务器与 npx 一起使用:
{
"mcpServers": {
"strapi": {
"command": "npx",
"args": ["-y", "@bschauer/strapi-mcp-server@2.5.0"]
}
}
}配置
在~/.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 (e.g., "5.*", "4.1.5", "v4")
}
}您可以通过将多个 Strapi 实例添加到此文件来配置它们。
版本配置
服务器现在支持多种版本格式:
通配符:“5. ”、“4. ”
具体:“4.1.5”,“5.0.0”
简单:“v4”,“v5”
这有助于服务器提供特定版本的指导并适当地处理 API 差异。
获取 JWT 令牌
登录您的 Strapi 管理面板
创建具有适当权限的 API 令牌
将令牌添加到配置文件中相应的服务器名称下
用法
列出可用服务器
strapi_list_servers();
// Now includes version information and differences between v4 and v5内容类型
// 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
REST API 提供了全面的 CRUD 操作,具有内置验证和特定于版本的处理:
// 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",
});媒体上传
// 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",
},
});版本差异(v4 与 v5)
服务器自动处理的 Strapi 版本之间的主要区别:
v4
使用数字 ID
嵌套属性结构
响应中的数据包装器
传统的 REST 模式
外部 i18n 插件
v5
基于文档的身份证件
扁平数据结构
直接属性访问
增强的 JWT 安全性
集成 i18n 支持
新的文档服务 API
安全功能
写保护策略
服务器实施严格的写保护策略:
所有写入操作都需要明确授权
受保护的操作包括:
POST(创建)
PUT(更新)
删除
媒体上传
每个操作都经过记录和验证
最佳实践
始终先使用
strapi_get_content_types检查架构对端点使用适当的复数/单数形式
在查询中包含错误处理
上传前验证 URL
从最少的查询开始,仅在需要时添加人口
更新时始终包含完整的数据对象
使用过滤器优化查询性能
利用内置架构验证
检查操作的版本兼容性
遵循写保护策略指南
REST API 技巧
过滤
// 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 }];
}
}排序
params: {
sort: ["createdAt:desc"];
}分页
params: {
pagination: {
page: 1,
pageSize: 25
}
}人口
// Basic request without population
params: {
}
// Selective population when needed
params: {
populate: ["category"];
}
// Detailed population with field selection
params: {
populate: {
category: {
fields: ["name", "slug"];
}
}
}故障排除
常见问题及解决方案:
404 错误
检查端点复数/单数形式
验证内容类型是否存在
确保 API URL 正确
检查是否使用正确的 ID 格式(数字或基于文档)
身份验证问题
验证 JWT 令牌是否有效
检查令牌权限
确保令牌未过期
版本相关问题
验证配置中的版本规范
检查数据结构是否匹配版本
查看版本差异文档
写保护错误
确保操作已获得授权
检查操作是否受到保护
验证请求是否符合安全策略
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
执照
麻省理工学院
Available Tools
5 toolsstrapi_get_componentsA
Get all components from Strapi with pagination support. Returns both component data and pagination metadata (page, pageSize, total, pageCount).
Inputs: server (required), page, pageSize.
strapi_get_content_typesB
Get all content types from Strapi. Returns the complete schema of all content types.
Initialization Steps (ALWAYS DO FIRST)
Get schema and analyze with this tool
Capture Content Types and structures
Remember endpoint names (pluralName/singularName)
Document fields and types
Identify relations
Consider required fields and validations
Schema Conventions
singularName: Used for single item queries (e.g., "article")
pluralName: Used for collection endpoints (e.g., "articles")
collectionName: Database collection name
Endpoint Patterns
Collection: GET /api/{pluralName}
Single: GET /api/{pluralName}/{id}
Create: POST /api/{pluralName}
Update: PUT /api/{pluralName}/{id}
Delete: DELETE /api/{pluralName}/{id}
Inputs: server (required).
strapi_list_serversC
List all available Strapi servers from the configuration.
Security Policy
STRICT_USER_AUTHORIZATION_REQUIRED: No write operations without explicit user authorization. Protected operations: POST (Create), PUT (Update), DELETE (Delete), Media Upload. All write operations require userAuthorized: true parameter.
Strapi Version Support
Supports both Strapi v4 and v5 with automatic version detection.
Version Differences
v4: Numeric IDs, nested attributes under 'attributes', data wrapper in responses
v5: Document-based IDs (documentId), flat structure, direct attribute access
Common Errors
404: Using numeric ID instead of documentId, wrong plural/singular form
405: Incorrect endpoint (/article instead of /articles)
400: Missing data wrapper in request body
Best Practices
Always check schema first with strapi_get_content_types
Use documentId (not numeric id) for Strapi v5
Always use data wrapper for updates: { data: { field: value } }
Use pluralName for collection endpoints (api/articles)
Validate URLs with webtools before using them
Inputs: no named parameters.
strapi_restA
Execute REST API requests against Strapi endpoints. IMPORTANT: All write operations (POST, PUT, DELETE) require explicit user authorization via the userAuthorized parameter.
Reading Data
params: { populate: ['SEO'] } // Populate a component params: { populate: { SEO: { fields: ['Title', 'seoDescription'] } } } // With field selection params: { filters: { title: { $contains: 'search' } } } // Filter results params: { sort: ['createdAt:desc'] } // Sort results params: { pagination: { page: 1, pageSize: 10 } } // Pagination
Writing Data (REQUIRES userAuthorized: true)
body: { data: { componentName: { Title: 'value' }, // Single component componentName: [{ field: 'value' }] // Repeatable component } }
Debugging Guide
404 Error: Check plural/singular form, use documentId not numeric id
400 Error: Check if data wrapper is present in body
405 Error: Check endpoint format (/articles not /article)
URL Errors: Validate URLs with webtools first
ID Problems: Use documentId for Strapi v5
Strapi v5 Specifics
Use documentId instead of numeric id
Direct attribute access (no nested attributes)
No data wrapper in GET responses
Inputs: server (required), endpoint (required), body, method, +2 more.
strapi_upload_mediaA
Upload media to Strapi's media library from a URL with format conversion, quality control, and metadata options. IMPORTANT: This is a write operation that REQUIRES explicit user authorization via the userAuthorized parameter.
Upload Steps
Upload via strapi_upload_media with URL and metadata
Get image ID from response
Link to content using strapi_rest PUT request
Linking Images to Content (Strapi v5)
After upload, use PUT request to link: { "method": "PUT", "endpoint": "api/articles/{documentId}", "body": { "data": { "images": ["imageId"] } }, "userAuthorized": true }
Inputs: url (required), server (required), format, quality, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct function: schema introspection (components vs content types), server listing, generic REST execution, and media upload. No overlap in purposes.
Tools follow a strapi_verb_noun pattern mostly (get_components, get_content_types, list_servers, upload_media), but 'strapi_rest' deviates by using an acronym instead of a verb. Overall consistent.
5 tools is well-scoped for a Strapi MCP server, covering schema discovery, generic API access, media upload, and server management without superfluous tools.
The tool set provides schema introspection and a generic REST tool for all CRUD operations, plus media upload. Minor gap: no dedicated tool for content entry listing, but the REST tool covers it with schema guidance.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
The Telnyx MCP server is an official implementation of the Model Context Protocol that enables AI clients (like Claude Desktop, Cursor, and OpenAI Agents) to interact with Telnyx's telephony, messaging, and AI assistant APIs. It provides comprehensive capabilities including making and managing phone calls, sending SMS/MMS messages, purchasing and configuring phone numbers, creating AI assistants with custom instructions, managing cloud storage buckets, scraping and embedding website content, and handling integration secrets. The server exists as both a local implementation and a remotely hosted version, allowing developers to integrate real-world communication infrastructure directly into AI applications.
Related MCP Servers
- AlicenseAqualityFmaintenanceA Model Context Protocol server that enables AI assistants to interact with Confluence content, supporting operations like retrieving, searching, creating, and updating pages and spaces.913MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows AI tools to connect to and interact with your Directus API, enabling automated access to collections, items, and user data.27MIT
- AlicenseNot gradedqualityDmaintenanceA server that implements the Model Context Protocol, providing a standardized way to connect AI models to different data sources and tools.12MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides AI models with structured access to external data and services, acting as a bridge between AI assistants and applications, databases, and APIs in a standardized, secure way.2-