
Directus Mcp Server
io.github.staminna由 GitHub 账号 staminna 发布v12.4.0更新于 Nov 4, 2026
MCP server for Directus 12 — items, collections, files, flows, users, and schema tools
概览
面向 Directus 12 的 MCP 服务器,让助手管理 Directus 实例中的集合、条目、结构、流程、文件和用户。
- 可以做什么
- 列出、查看、创建和删除集合,并读取、新建、更新、删除或批量修改条目
- 创建、更新和删除字段与关系,分析并校验数据结构,生成快照、比对并应用结构变更
- 列出、创建、更新、删除自动化流程,手动触发流程并查看其操作
- 列出用户和文件,并将 CSV 或 JSON 数据导入一个或多个集合
- 诊断集合访问与缓存问题,并按任务描述搜索可用工具
- 适用场景
- 适合已在使用 Directus 12 后端、希望助手在聊天客户端内浏览数据模型、编辑内容、调整结构或管理流程的场景。对能签发受限令牌的开发者或内容团队最有用。
- 运行要求
- 以 stdio 方式在本机运行,通常通过 npx 或已构建的 Node.js 安装启动。需要 DIRECTUS_URL 指定实例地址,并在 DIRECTUS_TOKEN 中提供静态 Directus 访问令牌(在 Directus 的用户设置中生成)。可选变量涵盖提示词/资源功能、超时、重试、日志和 TLS 客户端证书。需要能访问该 Directus 实例的网络。
安装
在 SourceWeft 中
- 打开 控制台中的 Directus Mcp Server,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
@staminna/directus-mcp-server
MCP server for Directus 12 — items, collections, files, flows, users, and schema tools. TypeScript, typed throughout.
[npm version] [License: MIT] [CI] [mcp-server-claude MCP server]
[mcp-server-claude MCP server]
Test Coverage
Coverage badges are generated from coverage/coverage-summary.json by npm run badges (no external service required). Run npm run test:coverage first.
Features
- 🔐 Full Authentication - Token-based authentication with Directus
- 📦 Collection Management - CRUD operations for collections and items
- 📁 File Operations - Upload, download, and manage files
- 🔄 Flow Management - Create, update, trigger, and manage Directus Flows
- 👥 User Management - User CRUD and role management
- 🔍 Schema Tools - Analyze and validate collection schemas
- 🩺 Diagnostics - Collection access diagnostics and troubleshooting
Installation
Via npm (Recommended)
From Source
Environment Variables
TLS / client certificates
Set these when the Directus instance uses a private CA or requires a client
certificate. Each of CA/CERT/KEY/PFX accepts either a file path or the
PEM/DER content itself.
Authentication — no OAuth required
This server uses a static Directus access token (DIRECTUS_TOKEN) and runs over stdio transport. OAuth is not required, by design:
- The MCP specification only defines OAuth 2.1 authorization for HTTP-based transports. For stdio servers the spec says implementations "SHOULD NOT" use it and should instead retrieve credentials from the environment — exactly what this server does.
- Directus 12 fully supports static access tokens. The OAuth 2.1 support Directus added (mid-2026) applies to its own built-in remote MCP endpoint and is optional; there are no breaking changes to token authentication in Directus 12 (see
DIRECTUS_V12_BREAKING_CHANGES.md). - OAuth only becomes relevant if you expose an MCP server remotely over HTTP (Streamable HTTP/SSE). As a local stdio subprocess of Claude Desktop, Claude Code, Cursor, etc., this server needs only the env token.
Generate the token in Directus under User Settings → Token (use a dedicated user with least-privilege role for production).
Using with a Claude subscription (Max/Pro) — no API key needed
MCP servers do not consume Anthropic API tokens themselves; only the AI client's model calls do. If you use this server inside Claude Code or Claude Desktop with a Claude Max (or Pro) subscription, the model usage is covered by the subscription — you do not need an Anthropic API key. An API key is only required when driving Claude programmatically via the Claude API (e.g. the remote MCP connector).
IDE Configuration
🟣 Cursor
- Open Cursor Settings:
Cmd+,(macOS) orCtrl+,(Windows/Linux) - Search for "MCP" or navigate to Features → MCP Servers
- Click "Edit in settings.json"
- Add the following configuration:
Or if installed locally:
- Save the file and restart Cursor
🌊 Windsurf
- Open Windsurf Settings:
Cmd+,(macOS) orCtrl+,(Windows/Linux) - Search for "MCP Servers"
- Click "Edit in settings.json"
- Add the following configuration:
Or if installed locally:
- Save the file
- Quit Windsurf completely (
Cmd+QorCtrl+Q) - Reopen Windsurf and wait ~10 seconds for MCP to initialize
🤖 Claude Desktop
-
Locate your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
-
Create or edit the config file:
Or if installed locally:
- Save the file and restart Claude Desktop
🔮 Claude.ai (Web with MCP)
For Claude.ai web interface with MCP support:
- Navigate to Claude.ai settings
- Find the MCP configuration section
- Add a new MCP server with:
Note: Claude.ai MCP support may require a Pro subscription and specific browser extensions.
Available Tools
Collection Management
Schema & Fields
Flow Management
User Management
File Management
Diagnostics
Discovery
Tool safety annotations
Every tool carries MCP annotations so a client can tell reads from writes before
calling: 17 are readOnlyHint: true, 6 are explicitly destructiveHint: false
(additive — creates), and 11 are destructiveHint: true (deletes, overwriting
updates, apply_schema, import_data, trigger_flow).
Note that destructiveHint defaults to true in the MCP spec, which is why
the additive tools set it to false rather than omitting it.
Deleting items safely
Following Directus 12.3.0, delete_items never falls back to deleting
everything:
ids: [...]deletes those items.query: {...}deletes everything the query matches.- Passing both is rejected.
- Passing neither deletes nothing and issues no request.
To delete every item in a collection, ask for it explicitly:
Since Directus 12.4.0 a query resolves its targets under the token's read
permissions: read access to the primary key is required, and only items the
token can read are deleted. A token that can delete but not read deletes
nothing.
Usage Examples
Once configured, you can interact with Directus through your AI assistant:
Troubleshooting
MCP Server Not Connecting
- Verify Directus is running: Ensure your Directus instance is accessible at the configured URL
- Check token permissions: The API token needs appropriate permissions for the operations you want to perform
- Restart IDE: After changing MCP configuration, fully restart your IDE
- Check logs: Look for MCP-related errors in your IDE's developer console
Permission Errors
Ensure your Directus token has the required permissions:
- Admin token for full access
- Or configure specific role permissions for collections you need to access
Connection Timeout
If using a remote Directus instance:
- Verify the URL is correct and accessible
- Check firewall/network settings
- Ensure CORS is properly configured on Directus
Development
Testing
The project ships unit, integration and end-to-end suites (vitest). Coverage thresholds (95% statements/lines/functions/branches) are enforced — the test run fails below them.
Live verification against a real Directus
tests/live/demo.mjs drives all 34 tools against a real instance over stdio. It is
deliberately outside npm test — it needs a credential and a reachable server, so it
is a manual gate rather than a CI one.
Credentials are read from ENV_FILE (default .env.mdbaudio) so they never pass through
shell history. Results are reported per tool as pass / refused-by-instance / fail, keeping
"this server is broken" separate from "this instance declined". --apply-schema diffs in
merge mode, which yields a strictly additive diff, so it can only re-create the scratch
collection — it cannot drop anything that already existed. Cleanup runs even when an
earlier phase fails.
The e2e suite uses the official MCP SDK client (StdioClientTransport) to spawn dist/index.js as a subprocess, talking to an in-process mock Directus on an ephemeral port — no real Directus instance or network access needed.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT © Jorge Domingues Nunes
Links
来源:README.md,提交 db58dcd
工具
0版本历史
2- v12.4.0最新Sep 30, 2026
- v12.3.2Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分