
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 分