Directus MCP Server
Directus MCP 服务器
一个为 Directus CMS 实现模型上下文协议 (MCP) 的 Node.js 服务器。使 AI 客户端能够通过模型上下文协议 (MCP) 与 Directus API 进行交互。
ℹ 先决条件
Related MCP server: Directus MCP Server
▶️ 快速开始
获取您的 Directus API 凭据
前往您的 Directus 实例
创建一个静态访问令牌,或者获取您的电子邮件和密码
请妥善保管这些凭据
添加到您的 AI 编辑器
{ "mcpServers": { "directus": { "command": "npx", "args": ["-y", "@pixelsock/directus-mcp@latest"], "env": { "DIRECTUS_URL": "https://your-directus-instance.com", "DIRECTUS_ACCESS_TOKEN": "YOUR_ACCESS_TOKEN" } } } }或者,您可以使用电子邮件/密码进行身份验证:
{ "mcpServers": { "directus": { "command": "npx", "args": ["-y", "@pixelsock/directus-mcp@latest"], "env": { "DIRECTUS_URL": "https://your-directus-instance.com", "DIRECTUS_EMAIL": "your-email@example.com", "DIRECTUS_PASSWORD": "your-password" } } } }对于 Cursor:
前往 Settings → Cursor Settings → MCP
点击
+ Add New Global MCP Server粘贴配置
将占位符值替换为您的 Directus 凭据
保存并重启 Cursor
对于 Claude Desktop:
打开 Settings → Developer
点击
Edit Config在代码编辑器中打开
claude_desktop_config.json并粘贴配置将占位符值替换为您的 Directus 凭据
保存并重启 Claude
❓ 故障排除
如果您在 MCP 客户端(例如 Cursor 或 Claude Desktop)中启动服务器时遇到问题,请尝试以下操作。
确保您拥有有效的 Directus 凭据
验证您的 Directus URL 是否正确且可访问
检查您的访问令牌或电子邮件/密码凭据是否有效
在您的 MCP 客户端配置中替换凭据
保存并重启您的 MCP 客户端
确保已安装 Node 和 NPM
运行以下命令以确认您已安装 Node 和 NPM:
node -v
npm -v清除 NPM 缓存
有时清除 NPM 缓存 可以解决 npx 相关的问题。
npm cache clean --force🛠️ 可用工具
集合与项目
getItems // Get items from a collection
getItem // Get a single item from a collection by ID
createItem // Create a new item in a collection
updateItem // Update an existing item in a collection
deleteItem // Delete an item from a collection
getCollections // Get all collection schemas
getFields // Get fields for a collection
getRelations // Get relations for a collection文件
getFiles // Get files from Directus
uploadFile // Upload a file to Directus用户与权限
login // Login to Directus and get an access token
getUsers // Get users from Directus
getCurrentUser // Get the current user info
getRoles // Get roles from Directus
getPermissions // Get permissions from Directus系统
getSystemInfo // Get system information from Directus
getActivity // Get activity logs from Directus
getConfig // Get current configuration information🚧 开发模式
如果您想在开发模式下运行服务器:
克隆并安装:
git clone https://github.com/pixelsock/directus-mcp.git cd directus-mcp npm install将您的凭据添加到
.env:# .env DIRECTUS_URL=https://your-directus-instance.com DIRECTUS_ACCESS_TOKEN=your_token_here # Or use email/password DIRECTUS_EMAIL=your-email@example.com DIRECTUS_PASSWORD=your-password启动开发服务器:
npm run dev
🌐 HTTP 传输(多用户 / 远程部署)
默认情况下,服务器使用 stdio 传输,这非常适合单用户本地 AI 编辑器(Cursor、Claude Desktop 等)。
对于多用户或远程环境,您可以通过设置 MCP_TRANSPORT 环境变量切换到 Streamable HTTP 传输。
配置
环境变量 | 默认值 | 描述 |
|
| 传输模式: |
|
| HTTP 服务器监听的 TCP 端口 |
|
| 要绑定的主机/接口。使用 |
您也可以传递 --transport=http 作为 CLI 参数,而不是设置环境变量。
运行 HTTP 服务器
# Via environment variable
MCP_TRANSPORT=http MCP_PORT=3000 MCP_HOST=0.0.0.0 node dist/index.js
# Via CLI argument
node dist/index.js --transport=httpDocker 示例
docker run -p 3000:3000 \
-e DIRECTUS_URL=https://your-directus-instance.com \
-e DIRECTUS_ACCESS_TOKEN=your_token_here \
-e MCP_TRANSPORT=http \
-e MCP_HOST=0.0.0.0 \
ghcr.io/pixelsock/directus-mcp将 MCP 客户端连接到 HTTP 服务器
服务器运行后,将您的 MCP 客户端配置为连接到:
http://<host>:<port>/mcp例如,对于支持 Streamable HTTP 传输的客户端:
{
"mcpServers": {
"directus": {
"url": "http://localhost:3000/mcp"
}
}
}📄 Directus 开发者资源
Available Tools
18 toolscreateItemC
Create a new item in a collection
Inputs: collection (required), data (required), token, url.
deleteItemC
Delete an item from a collection
Inputs: collection (required), id (required), token, url.
getActivityC
Get activity logs from Directus
Inputs: query, token, url.
getCollectionsC
Get all collection schemas from Directus
Inputs: token, url.
getConfigB
Get current configuration information (without secrets)
Inputs: no named parameters.
getCurrentUserC
Get the current user info
Inputs: token, url.
getFieldsC
Get fields for a collection
Inputs: collection (required), token, url.
getFilesC
Get files from Directus
Inputs: query, token, url.
getItemC
Get a single item from a collection by ID
Inputs: collection (required), id (required), query, token, +1 more.
getItemsC
Get items from a collection in Directus
Inputs: collection (required), query, token, url.
getPermissionsC
Get permissions from Directus
Inputs: query, token, url.
getRelationsC
Get relations for a collection
Inputs: collection, token, url.
getRolesC
Get roles from Directus
Inputs: query, token, url.
getSystemInfoC
Get system information from Directus
Inputs: endpoint (required), token, url.
getUsersC
Get users from Directus
Inputs: query, token, url.
loginC
Login to Directus and get an access token
Inputs: email, password, url.
updateItemC
Update an existing item in a collection
Inputs: collection (required), data (required), id (required), token, +1 more.
uploadFileC
Upload a file to Directus
Inputs: fileName (required), fileData, fileUrl, mimeType, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Every tool has a clearly distinct purpose targeting specific resources and actions in the Directus ecosystem. There is no overlap between tools like getItem (single item retrieval), getItems (multiple items), and getCollections (schema information), making misselection unlikely.
All tools follow a consistent verb_noun naming pattern (e.g., createItem, getItem, updateItem, deleteItem). The pattern is maintained across all 18 tools with no deviations in style or convention.
With 18 tools, the count is slightly high but reasonable for a comprehensive CMS/backend server like Directus. It covers core operations without being overwhelming, though it borders on the upper limit of ideal scope.
The tool set provides complete CRUD coverage for items (create, get, update, delete), along with essential administrative functions (users, roles, permissions, files, activity, config). No obvious gaps exist for the Directus domain, enabling full agent workflows.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
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
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseAqualityBmaintenanceA Model Context Protocol server that enables AI assistants to interact with Strapi CMS instances through a standardized interface, supporting content types and REST API operations.575MIT
- 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 gradedqualityDmaintenanceAn extension that implements the Model Context Protocol for Directus, enabling AI tools and LLMs to interact with Directus content through natural language for content editing, data analysis, and asset management.5 npm8MIT
- AlicenseAqualityDmaintenanceThe official Model Context Protocol server for Skema CMS, enabling AI clients to interact with and manage CMS data. It provides tools for reading, creating, updating, and searching collections and items through natural language.119 npmMIT