directus-mcp-server

v12.7.0
io.github.staminna/directus-mcp-server Checked 1 hour ago Published 5 days ago

MCP 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.

ParameterTypeDescription
include_systembooleanInclude 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.

ParameterTypeDescription
collection *stringCollection 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…

ParameterTypeDescription
collection *stringCollection name
fieldsarrayFields to return
filterobjectFilter conditions
limitnumberNumber of items to return (default: 25)
offsetnumberNumber of items to skip
searchstringFull-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…
sortarraySort fields
versionstringContent version to read from a versioned collection. Use 'published' for the published version, or a version key for a draft.
version_rawbooleanReturn 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…

ParameterTypeDescription
collection *stringCollection name
fieldsarrayInitial fields to create
folderbooleanCreate 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.
metaobjectCollection 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.

ParameterTypeDescription
collection *stringCollection name
confirmbooleanConfirm 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.

ParameterTypeDescription
collection *stringCollection name
data *objectItem 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.

ParameterTypeDescription
collection *stringCollection name
data *objectUpdated data
id *string | numberItem ID
versionstringDraft 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…

ParameterTypeDescription
collection *stringCollection name
cascadeDeletebooleanDelete related items (requires ids)
confirmbooleanConfirm deletion
idsarrayExplicit item IDs to delete
queryobjectDirectus 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…

ParameterTypeDescription
collection *stringCollection name
field *stringField name
type *stringField type
default_valueDefault value
interfacestringField interface
notestringField note
optionsobjectInterface options
requiredbooleanIs field required
uniquebooleanIs field unique
validationobjectValidation 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.

ParameterTypeDescription
collection *stringCollection name
field *stringField name
default_valueDefault value
interfacestringField interface
notestringField note
optionsobjectInterface options
requiredbooleanIs field required
typestringField type
uniquebooleanIs field unique
validationobjectValidation 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.

ParameterTypeDescription
collection *stringCollection name
field *stringField name
confirmbooleanConfirm 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…

ParameterTypeDescription
collection *stringCollection name
operations *objectThe writes to apply, grouped by phase. Phases run in order: create, then update, then delete. Omit a phase to skip it.
validatebooleanValidate 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.

ParameterTypeDescription
collection *stringCollection name
includeRelationsbooleanInclude relationship analysis
validateConstraintsbooleanValidate 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.

ParameterTypeDescription
collectionstringSpecific collection to analyze
includeSystemCollectionsbooleanInclude 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…

ParameterTypeDescription
collection *stringSource collection
field *stringSource field
type *stringRelationship type
allowed_collectionsarrayAllowed collections (M2A only)
collection_fieldstringCollection field (M2A only)
junction_collectionstringJunction collection (M2M only)
junction_fieldstringJunction field (M2M only)
on_deletestringOn delete action
on_updatestringOn update action
primary_key_fieldstringPrimary key field (M2A only)
related_collectionstringTarget collection
related_fieldstringTarget field
related_junction_fieldstringRelated junction field (M2M only)
sort_fieldstringSort 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.

ParameterTypeDescription
collection *stringCollection name
strictbooleanEnable 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.

ParameterTypeDescription
collection *stringCollection name to diagnose
includeFieldsbooleanInclude field access tests
includePermissionsbooleanInclude permission checks
includeRelationsbooleanInclude 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.

ParameterTypeDescription
collectionstringSpecific 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.

ParameterTypeDescription
collection *stringCollection name to validate
waitTimenumberWait 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.

ParameterTypeDescription
fieldsarrayFields to return
filterobjectFilter conditions
limitnumberNumber of users to return (default: 25)
offsetnumberNumber of users to skip
searchstringSearch query
sortarraySort 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.

ParameterTypeDescription
id *stringUser ID
fieldsarrayFields 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.

ParameterTypeDescription
fieldsarrayFields to return
filterobjectFilter conditions
limitnumberNumber of files to return (default: 25)
offsetnumberNumber of files to skip
searchstringSearch query
sortarraySort 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.

ParameterTypeDescription
fieldsarrayFields to return
filterobjectFilter conditions
folderstringDirectus 12.4+: only flows in this folder (folder ID); pass "" for root-level flows
limitnumberNumber of flows to return (default: 25)
offsetnumberNumber of flows to skip
searchstringSearch query
sortarraySort fields
statusstringFilter 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.

ParameterTypeDescription
id *stringFlow ID
include_operationsbooleanInclude 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…

ParameterTypeDescription
name *stringFlow name
descriptionstringFlow description
folderstringDirectus 12.4+: flow folder ID to file the flow under (omit for root)
operationsarrayInitial operations to create with the flow
optionsobjectTrigger-specific options
statusstringFlow status (default: active)
triggerstringTrigger 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.

ParameterTypeDescription
data *objectFlow data to update
id *stringFlow 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.

ParameterTypeDescription
id *stringFlow ID
confirmbooleanConfirm 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.

ParameterTypeDescription
id *stringFlow ID
dataobjectData 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.

ParameterTypeDescription
flow_idstringFilter operations by flow ID
limitnumberNumber 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.

ParameterTypeDescription
exclude_collectionsarrayExclude these collections. Mutually exclusive with include_collections.
include_collectionsarrayRestrict 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.

ParameterTypeDescription
snapshot *objectA snapshot as returned by get_schema_snapshot
forcebooleanBypass the Directus version and database vendor checks
modestring'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.

ParameterTypeDescription
diff *objectThe { hash, diff } object returned by diff_schema
confirmbooleanConfirm application
forcebooleanBypass 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…

ParameterTypeDescription
collectionstringTarget 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.
confirmbooleanConfirm a destructive import
dangerously_allow_deletebooleanBatch import only. Permit deletion of rows absent from the file. Requires confirm.
dry_runbooleanBatch import only. Report the changes without writing.
file_datastringBase64-encoded file contents (alternative to file_path)
file_pathstringPath to a local .csv or .json file
filenamestringFilename for the upload; its extension selects the parser (.csv or .json)
modestringBatch 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.

ParameterTypeDescription
query *stringFree-text task description, e.g. "delete rows" or "change the data model"
limitnumberMaximum number of tools to return (default: 10)