Directus MCP Server
Provides comprehensive tools for managing Directus schema and content, including collection management, field and relation configuration, full CRUD operations on items, and management of flows and dashboards.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Directus MCP Server list the 5 most recent items from the articles collection"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Directus MCP Server
A Model Context Protocol (MCP) server that provides comprehensive tools for managing Directus schema and content. This server enables AI assistants and other MCP clients to interact with Directus instances programmatically.
Installation
From npm (once published)
npm install -g directus-mcp-serverFrom source
git clone https://github.com/yourusername/directus-mcp.git
cd directus-mcp
npm install
npm run buildRelated MCP server: Directus MCP Server
Features
Schema Management: Create, read, update, and delete collections, fields, and relations
Content Management: Full CRUD operations on items with advanced querying
Type Safety: Built with TypeScript and Zod validation
Official SDK: Uses the official
@directus/sdkfor reliable API interactionsFlexible Authentication: Supports both static tokens and email/password authentication
Installation
npm installConfiguration
Create a .env file in the root directory with your Directus configuration:
# Directus Instance URL
DIRECTUS_URL=https://your-directus-instance.com
# Authentication - Use either token OR email/password
DIRECTUS_TOKEN=your_static_token_here
# Alternative: Email/Password authentication
# DIRECTUS_EMAIL=admin@example.com
# DIRECTUS_PASSWORD=your_passwordAuthentication Options
Static Token (Recommended for production):
Generate a static token in Directus Admin App
Set
DIRECTUS_TOKENenvironment variable
Email/Password:
Use for development or when static tokens aren't available
Set
DIRECTUS_EMAILandDIRECTUS_PASSWORDenvironment variables
Toolset Configuration
The Directus MCP server organizes tools into logical toolsets, similar to GitHub's MCP implementation. This allows you to control which tools are exposed to the MCP client.
Available Toolsets:
default- Contains collections, fields, relations, and content tools (default behavior when no toolset is specified)collections- Collection management tools (list, get, create, update, delete collections)fields- Field management tools (list, create, update, delete fields)relations- Relation management tools (list, create, delete relations)schema- Schema snapshot and diff tools (get snapshot, get diff, apply diff) - NOT included in default toolsetcontent- Content management tools (items CRUD operations)flow- Flow management tools (workflow automation) - NOT included in default toolsetdashboards- Dashboard and panel management tools (list, get, create, update, delete dashboards and panels) - NOT included in default toolsetall- All available tools regardless of toolset membership
Default Behavior:
When MCP_TOOLSETS is not set or empty, only tools in the default toolset are exposed. The default toolset contains collections, fields, relations, and content tools, but not schema, flow, or dashboard tools. Schema, flow, and dashboard tools must be explicitly requested by including schema, flow, or dashboards in the MCP_TOOLSETS environment variable.
Configuration:
Set the MCP_TOOLSETS environment variable to a comma-separated list of toolsets:
# Expose only collections tools
MCP_TOOLSETS=collections
# Expose only schema snapshot/diff tools
MCP_TOOLSETS=schema
# Expose collections and fields tools
MCP_TOOLSETS=collections,fields
# Expose only dashboard and panel tools
MCP_TOOLSETS=dashboards
# Expose all schema-related toolsets
MCP_TOOLSETS=collections,fields,relations,schema
# Expose all toolsets (includes flow and dashboard tools)
MCP_TOOLSETS=default,flow,dashboards
# OR
MCP_TOOLSETS=collections,fields,relations,schema,content,flow,dashboards
# OR simply use 'all' to expose everything
MCP_TOOLSETS=allExamples:
{
"mcpServers": {
"directus-schema": {
"command": "node",
"args": ["/path/to/directus-mcp/dist/index.js"],
"env": {
"DIRECTUS_URL": "https://your-directus-instance.com",
"DIRECTUS_TOKEN": "your_token",
"MCP_TOOLSETS": "schema"
}
},
"directus-content": {
"command": "node",
"args": ["/path/to/directus-mcp/dist/index.js"],
"env": {
"DIRECTUS_URL": "https://your-directus-instance.com",
"DIRECTUS_TOKEN": "your_token",
"MCP_TOOLSETS": "content"
}
}
}
}Notes:
Toolset names are case-insensitive
Invalid toolset names are ignored (with a warning)
If all requested toolsets are invalid, the server defaults to the
defaulttoolsetCollections, fields, relations, and content tools belong to both
defaultand their specific toolsetSchema, flow, and dashboard tools belong ONLY to their respective toolsets (not in
default)
Building
npm run buildUsage
Running the Server
npm startOr use the built binary:
node dist/index.jsMCP Client Configuration
Add to your MCP client configuration (e.g., Claude Desktop, Cline):
Option 1: Using npx (recommended - no installation needed):
{
"mcpServers": {
"directus": {
"command": "npx",
"args": ["-y", "directus-mcp-server"],
"env": {
"DIRECTUS_URL": "https://your-directus-instance.com",
"DIRECTUS_TOKEN": "your_static_token_here",
"MCP_TOOLSETS": "default"
}
}
}
}Option 2: Using global installation:
{
"mcpServers": {
"directus": {
"command": "directus-mcp",
"env": {
"DIRECTUS_URL": "https://your-directus-instance.com",
"DIRECTUS_TOKEN": "your_static_token_here",
"MCP_TOOLSETS": "default"
}
}
}
}Option 3: Using local source:
{
"mcpServers": {
"directus": {
"command": "node",
"args": ["/absolute/path/to/directus-mcp/dist/index.js"],
"env": {
"DIRECTUS_URL": "https://your-directus-instance.com",
"DIRECTUS_TOKEN": "your_static_token_here",
"MCP_TOOLSETS": "default"
}
}
}
}Available Tools
Schema Management Tools
list_collections
List all collections in the Directus instance.
Parameters: None
Example:
{}get_collection
Get detailed information about a specific collection.
Parameters:
collection(string): Collection name
Example:
{
"collection": "articles"
}create_collection
Create a new collection (database table) with optional fields. This automatically creates a proper database table, not just a folder.
Parameters:
collection(string): Collection namemeta(object, optional): Collection metadata (icon, note, singleton, etc.)schema(object, optional): Database schema configuration (automatically set if not provided)fields(array, optional): Initial fields to create
Example:
{
"collection": "articles",
"meta": {
"icon": "article",
"note": "Blog articles collection"
},
"fields": [
{
"field": "id",
"type": "integer",
"schema": {
"is_primary_key": true,
"has_auto_increment": true
}
},
{
"field": "title",
"type": "string",
"meta": {
"required": true
}
},
{
"field": "status",
"type": "string",
"meta": {
"interface": "select-dropdown",
"options": {
"choices": [
{"text": "Draft", "value": "draft"},
{"text": "Published", "value": "published"}
]
}
}
}
]
}update_collection
Update collection metadata.
Parameters:
collection(string): Collection namemeta(object): Metadata to update
Example:
{
"collection": "articles",
"meta": {
"icon": "article",
"note": "Updated description"
}
}delete_collection
Delete a collection and all its data.
Parameters:
collection(string): Collection name
Example:
{
"collection": "articles"
}list_fields
List all fields in a collection.
Parameters:
collection(string): Collection name
Example:
{
"collection": "articles"
}create_field
Add a new field to a collection.
Parameters:
collection(string): Collection namefield(string): Field nametype(string): Field type (string, integer, text, boolean, json, uuid, timestamp, etc.)meta(object, optional): Field metadataschema(object, optional): Database schema configuration
Example:
{
"collection": "articles",
"field": "author",
"type": "uuid",
"meta": {
"interface": "select-dropdown-m2o",
"required": true,
"special": ["m2o"]
}
}update_field
Update field properties.
Parameters:
collection(string): Collection namefield(string): Field nametype(string, optional): Field typemeta(object, optional): Metadata to updateschema(object, optional): Schema to update
Example:
{
"collection": "articles",
"field": "title",
"meta": {
"note": "Article title (required)"
}
}delete_field
Remove a field from a collection.
Parameters:
collection(string): Collection namefield(string): Field name
Example:
{
"collection": "articles",
"field": "old_field"
}list_relations
List all relations in the Directus instance.
Parameters: None
Example:
{}create_relation
Create a relation between collections.
Parameters:
collection(string): Many collection (with foreign key)field(string): Field name in many collectionrelated_collection(string, optional): One collectionmeta(object, optional): Relation metadataschema(object, optional): Database relation configuration
Example (Many-to-One):
{
"collection": "articles",
"field": "author",
"related_collection": "users",
"schema": {
"on_delete": "SET NULL"
}
}Example (One-to-Many):
{
"collection": "articles",
"field": "author",
"related_collection": "users",
"meta": {
"one_field": "articles"
}
}delete_relation
Delete a relation.
Parameters:
collection(string): Collection namefield(string): Field name
Example:
{
"collection": "articles",
"field": "author"
}Content Management Tools
query_items
Query items with filtering, sorting, and pagination.
Parameters:
collection(string): Collection namefields(array, optional): Fields to returnfilter(object, optional): Filter criteriasearch(string, optional): Search querysort(array, optional): Sort fields (prefix with-for descending)limit(number, optional): Maximum items to returnoffset(number, optional): Items to skippage(number, optional): Page numberaggregate(object, optional): Aggregation functionsgroupBy(array, optional): Group by fieldsdeep(object, optional): Deep relational queries
Filter Operators: _eq, _neq, _lt, _lte, _gt, _gte, _in, _nin, _null, _nnull, _contains, _ncontains, _starts_with, _nstarts_with, _ends_with, _nends_with, _between, _nbetween
Example:
{
"collection": "articles",
"filter": {
"status": {"_eq": "published"},
"date_created": {"_gte": "2024-01-01"}
},
"sort": ["-date_created"],
"limit": 10
}get_item
Get a single item by ID.
Parameters:
collection(string): Collection nameid(string|number): Item IDfields(array, optional): Fields to returndeep(object, optional): Deep relational queries
Example:
{
"collection": "articles",
"id": 1,
"fields": ["id", "title", "status", "author.first_name"]
}create_item
Create a new item.
Parameters:
collection(string): Collection namedata(object): Item data
Example:
{
"collection": "articles",
"data": {
"title": "My New Article",
"status": "draft",
"body": "Article content here...",
"author": "user-uuid-here"
}
}update_item
Update an existing item.
Parameters:
collection(string): Collection nameid(string|number): Item IDdata(object): Fields to update
Example:
{
"collection": "articles",
"id": 1,
"data": {
"status": "published"
}
}delete_item
Delete an item.
Parameters:
collection(string): Collection nameid(string|number): Item ID
Example:
{
"collection": "articles",
"id": 1
}bulk_create_items
Create multiple items at once.
Parameters:
collection(string): Collection nameitems(array): Array of item data objects
Example:
{
"collection": "articles",
"items": [
{"title": "Article 1", "status": "draft"},
{"title": "Article 2", "status": "draft"}
]
}bulk_update_items
Update multiple items at once.
Parameters:
collection(string): Collection nameitems(array): Array of items with id and fields to update
Example:
{
"collection": "articles",
"items": [
{"id": 1, "status": "published"},
{"id": 2, "status": "published"}
]
}bulk_delete_items
Delete multiple items at once.
Parameters:
collection(string): Collection nameids(array): Array of item IDs
Example:
{
"collection": "articles",
"ids": [1, 2, 3]
}Common Use Cases
Setting up a new content model
Create a collection with
create_collectionAdd fields with
create_fieldCreate relations with
create_relationStart adding content with
create_item
Querying content with relations
{
"collection": "articles",
"fields": ["*", "author.first_name", "author.last_name"],
"filter": {"status": {"_eq": "published"}},
"sort": ["-date_created"],
"limit": 10
}Bulk operations
Use bulk_create_items, bulk_update_items, or bulk_delete_items for efficient batch operations.
Development
# Watch mode for development
npm run dev
# Build for production
npm run buildTool Authoring
This project provides utilities to streamline MCP tool development and reduce code duplication:
Tool Helpers
Use createTool for tools that return data, and createActionTool for tools that perform actions:
import { createTool, createActionTool } from './tools/tool-helpers.js';
// Data-returning tool
const myTool = createTool({
name: 'my_tool',
description: 'Description of what the tool does',
inputSchema: MySchema,
toolsets: ['default', 'my-category'],
handler: async (client, args) => client.someMethod(args)
});
// Action tool (returns success message)
const myActionTool = createActionTool({
name: 'delete_something',
description: 'Delete something',
inputSchema: DeleteSchema,
toolsets: ['default'],
handler: async (client, args) => client.deleteMethod(args.id),
successMessage: (args) => `Successfully deleted item ${args.id}`
});Shared Validators
Common Zod schemas are available in src/tools/validators.ts:
CollectionNameSchema- For collection namesItemIdSchema- For item IDs (string | number)FieldsSchema- For field arraysFilterSchema- For Directus filter objectsQuery parameter schemas (
SortSchema,LimitSchema, etc.)Flow-related schemas (
FlowTriggerSchema,FlowStatusSchema, etc.)
Example usage:
import { CollectionNameSchema, ItemIdSchema } from './tools/validators.js';
const MyToolSchema = z.object({
collection: CollectionNameSchema,
id: ItemIdSchema,
// ... other fields
});Directus Client Resource Factory
The client uses a resource factory pattern for consistent CRUD operations. When adding new Directus resources, define them in the client constructor using createResourceMethods().
Error Handling
All tools include error handling and will return descriptive error messages for:
Authentication failures
Invalid parameters
API errors
Network issues
Validation errors
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Available Tools
20 toolsbulk_create_itemsA
Create multiple items in a collection at once. More efficient than creating items one by one. Example: {collection: "articles", items: [{title: "Article 1", status: "draft"}, {title: "Article 2", status: "draft"}]}
Inputs: collection (required), items (required).
bulk_delete_itemsA
Delete multiple items from a collection at once by their IDs. This action cannot be undone. Example: {collection: "articles", ids: [1, 2, 3]}
Inputs: collection (required), ids (required).
bulk_update_itemsA
Update multiple items in a collection at once. Each item must include an id field. Example: {collection: "articles", items: [{id: 1, status: "published"}, {id: 2, status: "published"}]}
Inputs: collection (required), items (required).
create_collectionA
Create a new collection (database table) in Directus. Automatically creates a proper database table with schema. Can include initial fields. Example: {collection: "articles", meta: {icon: "article", note: "Blog articles"}, fields: [{field: "id", type: "integer", schema: {is_primary_key: true, has_auto_increment: true}}, {field: "title", type: "string"}]}
Inputs: collection (required), meta, schema, fields.
create_fieldA
Add a new field to a collection. Specify field type, interface, and constraints. Example: {collection: "articles", field: "status", type: "string", meta: {interface: "select-dropdown", options: {choices: [{text: "Draft", value: "draft"}, {text: "Published", value: "published"}]}, required: true}}
Inputs: collection (required), field (required), type (required), meta, +1 more.
create_itemA
Create a new item in a collection. Provide the item data as key-value pairs. Example: {collection: "articles", data: {title: "My Article", status: "draft", body: "Article content..."}}
Inputs: collection (required), data (required).
create_relationA
Create a relation between collections (M2O, O2M, or M2M). For M2O: specify collection, field, and related_collection. For O2M: also include meta.one_field. Example M2O: {collection: "articles", field: "author", related_collection: "users"}
Inputs: collection (required), field (required), related_collection, meta, +1 more.
delete_collectionA
Delete a collection and all its data. This action cannot be undone. Use with caution.
Inputs: collection (required).
delete_fieldA
Remove a field from a collection. This will delete the column and all its data. Use with caution.
Inputs: collection (required), field (required).
delete_itemA
Delete an item from a collection by ID. This action cannot be undone.
Inputs: collection (required), id (required).
delete_relationB
Delete a relation. Specify the collection and field that contains the relation.
Inputs: collection (required), field (required).
get_collectionB
Get detailed information about a specific collection including all fields, metadata, and schema configuration.
Inputs: collection (required).
get_itemA
Get a single item by ID from a collection. Optionally specify fields to return and deep query for relational data.
Inputs: collection (required), id (required), fields, deep.
list_collectionsB
List all collections in the Directus instance. Returns collection names, metadata, and schema information.
Inputs: no named parameters.
list_fieldsB
List all fields in a specific collection with their types, metadata, and schema configuration.
Inputs: collection (required).
list_relationsA
List all relations (foreign keys, M2O, O2M, M2M) in the Directus instance.
Inputs: no named parameters.
query_itemsA
Query items from a collection with advanced filtering, sorting, pagination, and search. Supports Directus filter operators like _eq, _neq, _lt, _lte, _gt, _gte, _in, _nin, _null, _nnull, _contains, _ncontains, _starts_with, _nstarts_with, _ends_with, _nends_with, _between, _nbetween. Example: {collection: "articles", filter: {"status": {"_eq": "published"}, "date_created": {"_gte": "2024-01-01"}}, sort: ["-date_created"], limit: 10}
Inputs: collection (required), fields, filter, search, +7 more.
update_collectionC
Update collection metadata such as icon, note, visibility settings, etc.
Inputs: collection (required), meta.
update_fieldC
Update field properties such as metadata, interface options, or schema constraints.
Inputs: collection (required), field (required), type, meta, +1 more.
update_itemA
Update an existing item in a collection. Provide the item ID and fields to update. Example: {collection: "articles", id: 1, data: {status: "published"}}
Inputs: collection (required), id (required), data (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 20 tools
Each tool has a distinct purpose: create vs update vs delete for different resources (collections, fields, items, relations), plus bulk variants and querying. No overlap that could confuse an agent.
All tools follow a consistent verb_noun pattern with snake_case (e.g., create_collection, list_fields, bulk_create_items). Prefixes like bulk_ are applied uniformly. No mixing of conventions.
20 tools cover the core operations of a headless CMS: CRUD for collections, fields, items, relations, plus bulk and query. Slightly on the high side but still well-scoped for the domain.
Covers CRUD for all main entities plus bulk operations and advanced querying. Minor gaps: no explicit list_items (query_items serves that role), no update for relations, and missing some higher-level features like user management, but core data operations are complete.
Maintenance
Related MCP Connectors
Manage FireCMS Cloud from an AI agent: Firestore data, collections, schemas and users.
Find, write, publish and check pages and API references in your DeveloperHub docs from an AI client
Query and update Teable records, manage tables, and access the Teable API with AI agents.
The agent-native cloud: database, functions, AI, storage, computers. 53 tools. OAuth or API key.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact directly with Strapi v5 CMS content through full CRUD operations, media uploads, and content type exploration using Strapi's Document Service API.591 npm1MIT
- AlicenseAqualityBmaintenanceEnables comprehensive interaction with Directus CMS including collection management, file operations, flow automation, user management, and schema analysis through natural language commands.34121 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage tasks in Directus databases with automatic schema synchronization, supporting CRUD operations, filtering by status and priority, and TypeScript type safety.MIT
- FlicenseNot gradedqualityNot gradedmaintenanceProvides AI agents with full access to Strapi 5.x CMS for managing content types, entries, media, and schemas. It supports full CRUD operations, relation management, and secure authentication for comprehensive content administration.-