directus-mcp-server
v12.7.0MCP server for Directus 12 — items, collections, files, flows, users, and schema tools
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
list_collections
Lists every collection in the Directus instance with its metadata, so the data model can be discovered before anything is read or written. Start here when the collection name is unknown; use get_collection_schema for the fields of one collection and get_collection_items to read its rows. Folders (grouping elements with no table behind them) and inactive collections (Directus 12.4 refuses to read or write their contents) are flagged in the result. System collections are omitted unless include_system is true. Returns one entry per collection with its name, metadata and those flags.
| Parameter | Type | Description |
|---|---|---|
include_system | boolean | Include system collections |
get_collection_schema
Returns the field-level schema of one collection: field names, database types, interfaces, required and unique constraints, defaults and relation metadata. Use it before create_item or update_item to learn which fields exist and which are mandatory; use list_collections to find the collection name first, analyze_collection_schema when relationship mapping and constraint checks are also wanted. Read-only. Fails when the collection does not exist or the token cannot read it, and diagnose_collection_access tells those two apart.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
get_collection_items
Reads items (rows) from one collection with Directus filtering, sorting, field selection, full-text search and pagination. This is the read path for content: use get_users, get_files or get_flows for those system collections, and get_collection_schema when the shape rather than the data is wanted. Returns at most 25 items unless limit says otherwise, so paginate with offset over large collections. Results are scoped to what the token may read, so a filter can legitimately return fewer rows than exist. On versioned collections, version reads one draft and version_raw returns the delta instead o…
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
fields | array | Fields to return |
filter | object | Filter conditions |
limit | number | Number of items to return (default: 25) |
offset | number | Number of items to skip |
search | string | Full-text search across the collection's searchable fields. Since Directus 12.6.1 a search on a many-to-many junction also matches the related fields, and a numeric search no longer matches hidden ID… |
sort | array | Sort fields |
version | string | Content version to read from a versioned collection. Use 'published' for the published version, or a version key for a draft. |
version_raw | boolean | Return the raw version delta instead of the item merged with its version |
create_collection
Creates a collection, either a real database table or a grouping folder. A table gets an auto-increment integer id when no fields are passed; folder: true makes a grouping element, which has no schema and can hold neither items nor fields. Use create_field to add fields afterwards, apply_schema to provision several collections from a snapshot. The table is created immediately and is not rolled back when a later field in the same call fails. A fresh collection can take a moment to become readable: validate_collection_creation confirms it, refresh_collection_cache clears a stale cache. Returns t…
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
fields | array | Initial fields to create |
folder | boolean | Create a grouping folder instead of a table. A folder has no schema, so it cannot hold items and fields cannot be added to it. Default: false. |
meta | object | Collection metadata |
delete_collection
Drops a collection and every item in it, permanently. Requires confirm: true; without it nothing is deleted and the call reports what it would have done. Irreversible and not transactional: related items elsewhere may be left orphaned and a RESTRICT foreign key can make the drop fail halfway. Use delete_items to remove rows and keep the collection, delete_field to remove a single field. Take get_schema_snapshot first when the data model may need restoring.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
confirm | boolean | Confirm deletion |
create_item
Inserts one item (row) into a collection and returns it, including the generated primary key. Use bulk_operations for many rows in one call, import_data for a CSV or JSON file, update_item to change a row that exists. Directus validates the payload, so a missing required field or a failed validation rule comes back as a tool error and nothing is written. Fields the token may not write are rejected rather than silently dropped. The payload may include relational fields, which Directus resolves against the related collection.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
data * | object | Item data |
update_item
Updates fields of one item by primary key and leaves fields absent from data untouched: a PATCH, not a replace. Use create_item for a new row, bulk_operations for many rows, delete_items to remove them. In versioned collections the published item is read-only, so pass version with a draft key to write into a draft; without it Directus refuses the write. Overwrites whatever the field held, so read it with get_collection_items first when the previous value matters. Returns the updated item.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
data * | object | Updated data |
id * | string | number | Item ID |
version | string | Draft version key to write into. Published items in versioned collections cannot be edited directly. |
delete_items
Deletes items from a collection, by explicit ids or by a Directus query, permanently. Requires confirm: true, and passing neither ids nor query deletes nothing. ids and query are mutually exclusive. Since Directus 12.4 a query resolves its targets under the read permissions of the token: read access to the primary key is required and only readable items are deleted, so the deleted count can be lower than the matching count. Use { "limit": -1 } in query to deliberately target every item. cascadeDelete also removes related items and works only with ids. Use delete_collection to drop the whole co…
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
cascadeDelete | boolean | Delete related items (requires ids) |
confirm | boolean | Confirm deletion |
ids | array | Explicit item IDs to delete |
query | object | Directus query selecting the items to delete, e.g. { "filter": { "status": { "_eq": "archived" } } }. Mutually exclusive with ids. Use { "limit": -1 } to deliberately target every item. |
create_field
Adds a field to an existing collection: a database column plus its Directus interface metadata. Use create_relationship for relational fields, since this tool creates a plain column and no foreign key, and update_field for a field that already exists. The column is added immediately; on a non-empty table a required field without default_value can fail or leave existing rows invalid, so add it optional first and backfill. type is the Directus type (string, integer, boolean, dateTime, json, uuid and so on) while interface only affects how the admin app renders it. Returns the created field defin…
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
field * | string | Field name |
type * | string | Field type |
default_value | Default value | |
interface | string | Field interface |
note | string | Field note |
options | object | Interface options |
required | boolean | Is field required |
unique | boolean | Is field unique |
validation | object | Validation rules |
update_field
Changes an existing field, either its Directus metadata (interface, note, validation, options) or its database schema (type, required, unique, default_value). Metadata changes are safe; a type change rewrites the column and can fail or lose precision on existing data, and turning on required or unique fails on rows that already violate it. Idempotent: the same body applied twice leaves the same result. Use create_field to add a field, delete_field to remove one, and update_field with a hidden interface to retire a field without destroying data. Returns the updated field definition.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
field * | string | Field name |
default_value | Default value | |
interface | string | Field interface |
note | string | Field note |
options | object | Interface options |
required | boolean | Is field required |
type | string | Field type |
unique | boolean | Is field unique |
validation | object | Validation rules |
delete_field
Drops one field and its column from a collection, discarding the data in it permanently. Requires confirm: true. Relations pointing at the field can be left dangling, so check analyze_relationships first; use update_field to hide a field in the admin app instead of destroying it, delete_collection to drop the whole table. Not reversible, so take get_schema_snapshot beforehand when the model may need restoring.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
field * | string | Field name |
confirm | boolean | Confirm deletion |
bulk_operations
Applies many writes to one collection in a single call: creates, updates and deletes together. Prefer it to repeated create_item or update_item calls when the row count is high; use import_data for a CSV or JSON file and delete_items when deleting by query rather than by id. Not a transaction: the phases run in order (create, update, delete) and a failure partway leaves earlier writes committed, so the result reports what succeeded per phase. validate: true checks the payload against the collection schema before anything is written. This tool writes data and has nothing to do with analyze_rela…
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
operations * | object | The writes to apply, grouped by phase. Phases run in order: create, then update, then delete. Omit a phase to skip it. |
validate | boolean | Validate operations before execution |
analyze_collection_schema
Inspects one collection and reports its fields with types and constraints, optionally mapped against its relationships and checked for schema problems. Use it when deciding how to query or extend a collection; get_collection_schema returns the raw field list alone, validate_collection_schema returns only the problems, analyze_relationships gives the cross-collection view. Read-only. includeRelations adds inbound and outbound relations and validateConstraints adds constraint findings; each costs extra requests against Directus, so leave them off for a quick look.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
includeRelations | boolean | Include relationship analysis |
validateConstraints | boolean | Validate schema constraints |
analyze_relationships
Maps relationships across the instance: which collections point at which, through which fields, and of which type (o2o, o2m, m2o, m2m, m2a). Pass collection to narrow it to one collection and its neighbours, or omit it for the whole graph. Use it before create_relationship, before deleting a field or collection, or when a nested query returns an unexpected shape; analyze_collection_schema covers one collection in depth. Read-only, and it reads the data model only, never items. System collections are excluded unless includeSystemCollections is true.
| Parameter | Type | Description |
|---|---|---|
collection | string | Specific collection to analyze |
includeSystemCollections | boolean | Include system collections |
create_relationship
Creates a relationship between collections together with the schema it needs: a m2o or o2o foreign key, an o2m reverse field, a m2m junction collection, or a m2a any-collection link. Use create_field for a plain non-relational column and analyze_relationships to see what already exists. Which parameters are required depends on type: m2m needs junction_collection and both junction fields, m2a needs allowed_collections and collection_field. Creates real tables and constraints and does not roll back when a later step fails, so a half-created m2m may need manual cleanup. on_delete and on_update se…
| Parameter | Type | Description |
|---|---|---|
collection * | string | Source collection |
field * | string | Source field |
type * | string | Relationship type |
allowed_collections | array | Allowed collections (M2A only) |
collection_field | string | Collection field (M2A only) |
junction_collection | string | Junction collection (M2M only) |
junction_field | string | Junction field (M2M only) |
on_delete | string | On delete action |
on_update | string | On update action |
primary_key_field | string | Primary key field (M2A only) |
related_collection | string | Target collection |
related_field | string | Target field |
related_junction_field | string | Related junction field (M2M only) |
sort_field | string | Sort field |
validate_collection_schema
Checks one collection for schema problems and returns the findings: missing primary key, one-sided or broken relations, a database type that disagrees with its interface, constraints the stored data violates. Read-only, and it reports rather than repairs. Use it after create_collection or apply_schema, or when writes fail for no obvious reason; use diagnose_collection_access when permissions rather than schema are the suspicion. strict: true also reports conventions and warnings instead of errors alone.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name |
strict | boolean | Enable strict validation |
diagnose_collection_access
Explains why a collection cannot be read or written with the current token: whether it exists, whether it is active, whether the token holds item, field and relation permissions, and which of those is the blocker. Read-only and safe against production. Reach for it first when a tool returns an empty result or a forbidden error, before concluding the data is missing; validate_collection_schema covers a suspect schema and refresh_collection_cache a collection that was just created. Each include flag adds targeted probe requests against Directus.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name to diagnose |
includeFields | boolean | Include field access tests |
includePermissions | boolean | Include permission checks |
includeRelations | boolean | Include relation access tests |
refresh_collection_cache
Flushes the Directus server cache so recent schema changes become visible, then optionally verifies that one collection is readable. Use it after create_collection, create_field or apply_schema when a collection or field is reported as missing; validate_collection_creation answers the narrower question of whether a new collection is ready. Mutating but not destructive: it discards cached data, never stored data, though the next requests are slower while the cache refills. Needs a token allowed to flush the cache, and it affects every client of the instance, not just this session.
| Parameter | Type | Description |
|---|---|---|
collection | string | Specific collection to verify after refresh |
validate_collection_creation
Confirms that a newly created collection is usable: present in the schema, active, and readable with the current token, retrying once after waitTime milliseconds (default 2000) because Directus can lag a moment behind a create. Read-only. Use it right after create_collection and before writing items; refresh_collection_cache when it still reports the collection as missing, diagnose_collection_access for the full permission breakdown.
| Parameter | Type | Description |
|---|---|---|
collection * | string | Collection name to validate |
waitTime | number | Wait time in milliseconds before retry (default: 2000) |
get_users
Lists Directus users (directus_users) with filtering, sorting, field selection, search and pagination. Use get_user to fetch one user when the id is known. Returns at most 25 users unless limit says otherwise. Results are scoped to the permissions of the token, so a token without access to directus_users gets an empty list rather than an error. Directus never returns password hashes or static tokens; pass fields to keep responses small.
| Parameter | Type | Description |
|---|---|---|
fields | array | Fields to return |
filter | object | Filter conditions |
limit | number | Number of users to return (default: 25) |
offset | number | Number of users to skip |
search | string | Search query |
sort | array | Sort fields |
get_user
Fetches one Directus user by id, with optional field selection. Use get_users to search or list when the id is unknown. Read-only. Fails when the id does not exist or the token cannot read directus_users. The password hash and static token are never returned. The shorthand id me is not resolved here, so pass the actual user id.
| Parameter | Type | Description |
|---|---|---|
id * | string | User ID |
fields | array | Fields to return |
get_files
Lists files in the Directus file library (directus_files) with filtering, sorting, field selection, search and pagination, returning their metadata rather than their binary contents. Use import_data to load rows from a CSV or JSON file, and get_collection_items for files referenced from a content collection. Returns at most 25 files unless limit says otherwise. Each entry carries the file id, filename, type, size and storage location, which is what an asset URL is built from.
| Parameter | Type | Description |
|---|---|---|
fields | array | Fields to return |
filter | object | Filter conditions |
limit | number | Number of files to return (default: 25) |
offset | number | Number of files to skip |
search | string | Search query |
sort | array | Sort fields |
get_flows
Lists Directus automation flows with filtering, sorting, search and pagination. Use get_flow for one flow and its operations, get_operations for operations across flows, trigger_flow to run one. status narrows to active or inactive flows; folder (Directus 12.4+) narrows to one flow folder, where an empty string means root-level flows. Returns at most 25 flows unless limit says otherwise, and flow metadata only: operations are omitted unless get_flow asks for them.
| Parameter | Type | Description |
|---|---|---|
fields | array | Fields to return |
filter | object | Filter conditions |
folder | string | Directus 12.4+: only flows in this folder (folder ID); pass "" for root-level flows |
limit | number | Number of flows to return (default: 25) |
offset | number | Number of flows to skip |
search | string | Search query |
sort | array | Sort fields |
status | string | Filter by flow status |
get_flow
Fetches one automation flow by id, optionally with its operations expanded so the whole pipeline can be read in a single call. Use get_flows to find the id and get_operations to list operations across several flows. Read-only: reading a flow never runs it, trigger_flow does that. include_operations costs an extra request and makes the response large on long flows.
| Parameter | Type | Description |
|---|---|---|
id * | string | Flow ID |
include_operations | boolean | Include flow operations in response |
create_flow
Creates an automation flow and, optionally, its first operations in the same call. trigger selects what starts the flow (manual, schedule, event, webhook) and options carries the trigger-specific configuration, so a schedule flow needs its cron expression in options. A flow created with status active starts reacting immediately, events included, so create it inactive when that is not wanted. Each operations entry needs key, type and editor coordinates; operations are created but not chained, so wire the resolve and reject paths with update_flow or in the admin app. Use update_flow to change a…
| Parameter | Type | Description |
|---|---|---|
name * | string | Flow name |
description | string | Flow description |
folder | string | Directus 12.4+: flow folder ID to file the flow under (omit for root) |
operations | array | Initial operations to create with the flow |
options | object | Trigger-specific options |
status | string | Flow status (default: active) |
trigger | string | Trigger type (e.g., manual, schedule, event, webhook) |
update_flow
Updates one flow by id: name, status, trigger, description or trigger options. Idempotent, and it replaces the keys present in data while leaving the rest alone. Switching status to active makes the flow start reacting to its trigger at once, and changing trigger or options can leave the flow inconsistent with operations built for the old trigger. Operations themselves are not edited here, so read them with get_flow or get_operations. This tool writes an automation and has nothing to do with analyze_relationships, which inspects the data model.
| Parameter | Type | Description |
|---|---|---|
data * | object | Flow data to update |
id * | string | Flow ID |
delete_flow
Deletes a flow and all of its operations, permanently. Requires confirm: true. Whatever depended on the flow stops working, including a webhook URL that pointed at it, its schedule and any flow that triggered it, and the run history goes with it. Use update_flow with status inactive to switch a flow off and keep it. Not reversible.
| Parameter | Type | Description |
|---|---|---|
id * | string | Flow ID |
confirm | boolean | Confirm deletion |
trigger_flow
Runs one flow now and returns whatever its last operation produced. The side effects are whatever the flow does, which can mean writing items, sending mail or calling external services, so treat it as destructive unless the flow is known to be read-only. Flows with a manual trigger accept this reliably; others may refuse it or ignore the payload. data becomes the trigger payload and must match what the flow expects. Read the flow with get_flow before running it.
| Parameter | Type | Description |
|---|---|---|
id * | string | Flow ID |
data | object | Data to pass to the flow |
get_operations
Lists the operations (steps) that make up flows, optionally narrowed to one flow with flow_id. Use get_flow with include_operations for the whole pipeline of a single flow, and this tool to scan across flows, for example to find every step of a given type. Read-only: listing an operation never runs it. Returns at most 50 operations unless limit says otherwise, each with its key, type, editor position and options.
| Parameter | Type | Description |
|---|---|---|
flow_id | string | Filter operations by flow ID |
limit | number | Number of operations to return (default: 50) |
get_schema_snapshot
Exports the data model (collections, fields and relations, with no item data) as a snapshot object that diff_schema and apply_schema accept. Use it to back up the model before a destructive change, to move a model between environments, or to version it in git. Read-only. include_collections and exclude_collections are mutually exclusive and produce a partial snapshot, which on apply can read as a request to delete everything left out, so prefer a full snapshot for migrations.
| Parameter | Type | Description |
|---|---|---|
exclude_collections | array | Exclude these collections. Mutually exclusive with include_collections. |
include_collections | array | Restrict the snapshot to these collections. Mutually exclusive with exclude_collections. |
diff_schema
Compares a snapshot against the live data model and reports the operations that applying it would perform. Read-only, nothing is modified, which makes it the safe way to preview a migration before apply_schema, the tool that consumes the { hash, diff } object returned here. mode mirror (default) includes deletions so the live model would end up matching the snapshot exactly; merge drops them for a strictly additive diff. force bypasses the Directus version and database vendor checks and risks producing a diff that cannot be applied. An empty diff means the model already matches.
| Parameter | Type | Description |
|---|---|---|
snapshot * | object | A snapshot as returned by get_schema_snapshot |
force | boolean | Bypass the Directus version and database vendor checks |
mode | string | 'mirror' (default) reports every operation including deletions; 'merge' excludes deletions for an additive diff. |
apply_schema
Applies a diff from diff_schema to the live data model, creating, altering and dropping collections and fields. Requires confirm: true. Destructive and not transactional: a mirror-mode diff drops whatever is missing from the snapshot, and a failure partway leaves the model half-migrated. The hash ties the diff to the model it was computed against and the call is refused when the model has moved since; force bypasses that check and can corrupt the model. Always run diff_schema first and keep a get_schema_snapshot backup.
| Parameter | Type | Description |
|---|---|---|
diff * | object | The { hash, diff } object returned by diff_schema |
confirm | boolean | Confirm application |
force | boolean | Bypass the hash and version safety check |
import_data
Imports rows from a CSV or JSON file into one collection, or into several related collections at once from a flat multi-collection file. Use it when the data is in a file; bulk_operations takes payloads already in memory and create_item a single row. Subject to the Directus IMPORT_MAX_FILE_SIZE limit (50mb by default). Single-collection: pass collection, and the file is a plain array of rows. Batch (Directus 12.2+): omit collection, and the file MUST be a JSON array of { "collection": string, "items": object[] } entries, e.g. [{"collection":"authors","items":[{"name":"Ann"}]},{"collection":"a…
| Parameter | Type | Description |
|---|---|---|
collection | string | Target collection. Omit for a multi-collection batch import, in which case the file must be an array of { collection, items } entries rather than a bare row array. |
confirm | boolean | Confirm a destructive import |
dangerously_allow_delete | boolean | Batch import only. Permit deletion of rows absent from the file. Requires confirm. |
dry_run | boolean | Batch import only. Report the changes without writing. |
file_data | string | Base64-encoded file contents (alternative to file_path) |
file_path | string | Path to a local .csv or .json file |
filename | string | Filename for the upload; its extension selects the parser (.csv or .json) |
mode | string | Batch import only. 'add' inserts, 'merge' upserts. Default: add. |
search_tools
Finds the tools on this server that match a task description and returns their full definitions, so the right one can be called straight away. Use it first when unsure which tool fits, rather than guessing a name. Read-only and local: it searches the definitions this server already advertises, reaches Directus not at all, and so costs nothing against the instance. Matching runs over tool names, descriptions and keywords. Returns up to 10 tools unless limit says otherwise, best match first.
| Parameter | Type | Description |
|---|---|---|
query * | string | Free-text task description, e.g. "delete rows" or "change the data model" |
limit | number | Maximum number of tools to return (default: 10) |