带含量MCP
](https://www.npmjs.com/package/strapi-content-mcp) 
Strapi v5插件,通过 模型上下文协议(MCP),使像Claude这样的人工智能助手能够直接与您的Strapi内容进行交互。
特性
- Strapi直接集成 -使用Strapi的内部文档服务API进行全面消毒
- HTTP/SSE传输 -MCP通信的标准HTTP端点
- 8个MCP工具 -完整的CRUD操作和媒体上传
- 安全第一 -输入/输出净化,通过Strapi策略进行路由级身份验证
- Strapi v5兼容 -专为最新Strapi版本打造
安装
# Using npm
npm install strapi-content-mcp
# Using yarn
yarn add strapi-content-mcp配置
添加到您的Strapi config/plugins.ts (或 config/plugins.js):
export default {
'strapi-content-mcp': {
enabled: true,
config: {
// Optional: Set log level (default: 'info')
logLevel: 'info', // 'error' | 'warn' | 'info' | 'debug' | 'trace'
},
},
};然后重建并启动Strapi:
yarn build
yarn develop连接克劳德桌面
编辑您的Claude Desktop配置文件:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 窗户: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"strapi-content": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:1337/api/strapi-content-mcp/mcp"
]
}
}
}重新启动Claude Desktop,开始与您的Strapi内容聊天!
可用工具
| 工具 | 说明 |
|---|---|
list_content_types | 列出所有内容类型及其模式 |
list_components | 列出带分页的组件 |
find_many | 使用过滤器、排序、分页查询文档 |
find_one | 按documentId获取单个文档 |
create | 创建新文档 |
update | 更新现有文档 |
delete | 删除文档 |
upload_media | 从URL上传媒体 |
示例用法
连接后,问克劳德:
- “列出Strapi中的所有内容类型”
- “查找所有已发表的文章”
- “创建一篇题为“Hello World”的新博客文章”
- “更新文章abc123以更改标题”
- “将此图像上传到Strapi”
工具示例
查找文档
find_many with uid: "api::article.article"
- filters: { publishedAt: { $notNull: true } }
- sort: "createdAt:desc"
- pagination: { page: 1, pageSize: 10 }
- populate: ["author", "category"]创建文档
create with uid: "api::article.article"
- data: { title: "My Article", content: "Hello world" }
- status: "published"安全
此插件包括几个安全措施:
- 输出消毒:所有返回的数据都经过清理,以删除私有字段
- 输入消毒:在数据库写入之前,所有传入数据都会经过清理
- 故障关闭:如果消毒失败,操作将被拒绝(没有未消毒的数据暴露)
对于生产使用,考虑添加身份验证:
// config/plugins.ts
export default {
'strapi-content-mcp': {
enabled: true,
config: {
// Add route middleware for authentication
},
},
};需求
- Strapi v5.x
- Node.js 18+(包括Node.js 22,24+)
API端点
MCP端点位于:
POST/GET/DELETE http://localhost:1337/api/strapi-content-mcp/mcp故障排除
内存问题
如果在Strapi构建过程中遇到堆内存错误:
NODE_OPTIONS='--max-old-space-size=8192' yarn build
NODE_OPTIONS='--max-old-space-size=8192' yarn develop连接问题
- 确保Strapi在预期端口上运行
- 检查Claude Desktop配置文件语法(有效的JSON)
- 配置更改后重新启动Claude Desktop
- 检查Strapi日志中与MCP相关的错误
贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支
- 进行更改
- 提交拉取请求
许可证
麻省理工学院-见 许可证 了解详情。
作者
保罗·布拉茨拉夫斯基(@保罗·布拉茨拉夫斯基)
