Model Context Protocol (MCP) server for Directus v12 — exposes collections, items, files, flows, users & schema tools to AI assistants like Claude. TypeScript, full API coverage.
@staminna/directus-mcp-server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
MCP server for Directus 12 — items, collections, files, flows, users, and schema tools. TypeScript, typed throughout.
Test Coverage
| Statements | Branches | Functions | Lines |
|------------|----------|-----------|-------|
| | | | |
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
| Variable | Required | Description |
|----------|----------|-------------|
| DIRECTUS_URL | Yes | Your Directus instance URL (e.g., http://localhost:8065) |
| DIRECTUS_TOKEN | Yes | Static API token with appropriate permissions |
| DIRECTUS_PROMPTS_COLLECTION_ENABLED | No | Enable AI prompts collection (true/false) |
| DIRECTUS_PROMPTS_COLLECTION | No | Collection name for AI prompts (default: ai_prompts) |
| DIRECTUS_RESOURCES_ENABLED | No | Enable resources feature (true/false) |
| DIRECTUS_RESOURCES_EXCLUDE_SYSTEM | No | Exclude system collections from resources (true/false) |
| NODE_ENV | No | Environment mode (development/production) |
| DIRECTUS_TIMEOUT | No | Request timeout in ms (default: 30000) |
| DIRECTUS_RETRIES | No | Retry attempts for network errors, 5xx and 429 (default: 3) |
| DIRECTUS_RETRY_DELAY | No | Base backoff delay in ms (default: 1000) |
| DIRECTUS_MAX_RETRY_DELAY | No | Backoff ceiling in ms (default: 10000) |
| DIRECTUS_IMPORT_MAX_FILE_SIZE | No | Client-side import size ceiling in bytes, mirroring the Directus IMPORT_MAX_FILE_SIZE (default: 50 MB) |
| LOG_LEVEL | No | DEBUG/INFO/WARN/ERROR (default: INFO). Logs go to stderr; stdout is reserved for MCP |
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.
| Variable | Description |
|----------|-------------|
| DIRECTUS_HTTPS_CA | Certificate authority |
| DIRECTUS_HTTPS_CERT | Client certificate |
| DIRECTUS_HTTPS_KEY | Client private key |
| DIRECTUS_HTTPS_PFX | PKCS#12 bundle (alternative to cert/key) |
| DIRECTUS_HTTPS_PASSPHRASE | Passphrase for the key or PFX |
| DIRECTUS_HTTPS_REJECT_UNAUTHORIZED | false to accept self-signed certificates |
| DIRECTUS_HTTPS_SERVERNAME | SNI server name override |
---
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).