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 "Install 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 Serverlist 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)
From source
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
Configuration
Create a .env file in the root directory with your Directus configuration:
Authentication 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:
Examples:
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
Usage
Running the Server
Or use the built binary:
MCP Client Configuration
Add to your MCP client configuration (e.g., Claude Desktop, Cline):
Option 1: Using npx (recommended - no installation needed):
Option 2: Using global installation:
Option 3: Using local source:
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:
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:
update_collection
Update collection metadata.
Parameters:
collection(string): Collection namemeta(object): Metadata to update
Example:
delete_collection
Delete a collection and all its data.
Parameters:
collection(string): Collection name
Example:
list_fields
List all fields in a collection.
Parameters:
collection(string): Collection name
Example:
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:
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:
delete_field
Remove a field from a collection.
Parameters:
collection(string): Collection namefield(string): Field name
Example:
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):
Example (One-to-Many):
delete_relation
Delete a relation.
Parameters:
collection(string): Collection namefield(string): Field name
Example:
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:
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:
create_item
Create a new item.
Parameters:
collection(string): Collection namedata(object): Item data
Example:
update_item
Update an existing item.
Parameters:
collection(string): Collection nameid(string|number): Item IDdata(object): Fields to update
Example:
delete_item
Delete an item.
Parameters:
collection(string): Collection nameid(string|number): Item ID
Example:
bulk_create_items
Create multiple items at once.
Parameters:
collection(string): Collection nameitems(array): Array of item data objects
Example:
bulk_update_items
Update multiple items at once.
Parameters:
collection(string): Collection nameitems(array): Array of items with id and fields to update
Example:
bulk_delete_items
Delete multiple items at once.
Parameters:
collection(string): Collection nameids(array): Array of item IDs
Example:
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
Bulk operations
Use bulk_create_items, bulk_update_items, or bulk_delete_items for efficient batch operations.
Development
Tool 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:
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:
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.