Back to Directus

Overview

content/guides/11.ai/2.mcp/0.index.md

latest9.7 KB
Original Source
<!-- TODO: Add video <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; border-radius: 12px;"> <iframe src="https://www.youtube.com/embed/mJiLiUGh9r8" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 12px;" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> -->

AI assistants can now directly access your Directus content using the Model Context Protocol (MCP). Instead of copying data back and forth, your AI tools connect directly to your Directus instance.

::callout{icon="material-symbols:info" color="info"} MCP requires Directus v11.12+. For older versions, use the Local MCP alternative. ::

How can this help me?

  • Content editors: Migrate content from Google Docs, organize individual files, and manage content with AI assistance.
  • Developers: Rapidly prototype data models, create collections, and build automation workflows.
  • Teams: Dramatically speed up content operations while maintaining brand consistency.

Get started with the Directus MCP Server

::card-group

:::card{title="Quick Setup" icon="material-symbols:rocket-launch" to="/guides/ai/mcp/installation"} Enable MCP and connect your AI tools in under 5 minutes. :::

:::card{title="See What's Possible" icon="material-symbols:bolt" to="/guides/ai/mcp/use-cases"} Real examples of AI-powered content workflows that save hours of manual work. :::

:::card{title="Available Tools" icon="material-symbols:construction" to="/guides/ai/mcp/tools"} Complete reference of MCP tools and their capabilities. :::

:::card{title="Custom Prompts" icon="material-symbols:chat" to="/guides/ai/mcp/prompts"} Create reusable prompt templates for consistent AI interactions. :::

:::card{title="Security Guide" icon="material-symbols:security" to="/guides/ai/mcp/security"} Essential security practices for using MCP safely with your Directus data. :::

:::card{title="Troubleshooting" icon="material-symbols:help" to="/guides/ai/mcp/troubleshooting"} Common issues and solutions when setting up and using the Directus MCP server. :::

:::card{title="Local Alternative" icon="material-symbols:dns" to="/guides/ai/mcp/local-mcp"} Node.js-based MCP server for advanced setups and older Directus versions. :::

::


What you can do with the Directus MCP Server?

For Content Editors

Use LLMs and AI to create and manage content.

  • Import blog posts from Google Docs with proper field mapping
  • Build landing pages using page builder components and relationships
  • Add metadata to individual images (alt text, descriptions, tags)
  • Organize files into logical folder structures
  • Create content entries with proper relationships to authors, categories, etc.

For Developers

Rapidly prototype data models and build automation using natural language.

  • Create collections with proper field types and validation rules
  • Set up complex relationships (M2O, O2M, M2M, M2A) between collections
  • Generate automation flows triggered by database events
  • Build approval workflows with custom operations
  • Prototype entire data models through conversation

How it works

  1. Enable MCP in Directus Settings → AI
  2. Generate an access token for your MCP user (we recommend creating a dedicated user for MCP operations)
  3. Connect your AI tool to the Directus MCP server
  4. Use AI to create, edit, and manage your content

Your AI assistant operates through your existing Directus permissions - no middleware or data copying required.


Security built-in

  • Uses your existing Directus permissions
  • Complete audit trail of all changes
  • Global delete protection (disabled by default)

::callout{icon="material-symbols:security" color="info"} Security: For production deployments, review our comprehensive Security Guide covering threat mitigation, compliance requirements, and enterprise security controls. ::


Supported clients


Real-world examples

Content Creation

:::chat

chatId: "content-creation" messages:

  • role: user content: "Can you convert this blog post over to Directus for me - with all the proper fields?"
  • role: assistant content: "I'll help you convert this blog post to Directus! First, let me get the system prompt to understand the role better, then I'll examine the current schema to see what collections exist." toolInvocations:
    • toolCallId: "system-prompt" toolName: "system-prompt" state: "result"
    • toolCallId: "schema" toolName: "schema" state: "result"
  • role: assistant content: "Perfect! I can see you have a posts collection already. Let me examine its schema to understand the current structure:" toolInvocations:
    • toolCallId: "schema-detailed" toolName: "schema" state: "result"
  • role: assistant content: "Great! Your posts collection has all the essential fields for blog content. Now I'll create this blog post in your Directus instance. The structure looks perfect for this content - I'll populate the title, slug, content, excerpt, and tags fields." toolInvocations:
    • toolCallId: "create-post" toolName: "items" state: "result" result: "Created blog post"
  • role: assistant content: "✅ Perfect! I've successfully created your blog post in Directus with:\n\n- Title: "Why Content Workflows Suck (And What to Do About It)"\n- Status: Set to "draft" for review\n- Content: Full markdown content with proper formatting\n- Tags: Added relevant tags including "content management", "workflow", "CMS"\n\nThe post is now available in your Directus admin. Would you like me to set the status to "published" or make any other adjustments?"

:::

Asset Organization

:::chat

chatId: "asset-organization" messages:

  • role: user content: "I just uploaded a product photo but forgot to add alt text. Can you analyze this image and add proper metadata?"
  • role: assistant content: "I'll analyze the image and add appropriate metadata. Let me retrieve the image first:" toolInvocations:
    • toolCallId: "get-image" toolName: "assets" state: "result" result: "Retrieved image data"
  • role: assistant content: "I can see it's a photo of a red leather handbag with gold hardware on a white background. Let me update the file metadata:" toolInvocations:
    • toolCallId: "update-metadata" toolName: "files" state: "result" result: "Updated file metadata"
  • role: assistant content: "✅ Done! I've updated your image with:\n\n- Title: "Red Leather Handbag with Gold Hardware"\n- Alt Text: "Red leather handbag with gold chain strap on white background"\n- Description: "Premium red leather handbag with gold-tone hardware for product catalog"\n- Tags: Added "handbag", "leather", "red", "gold-hardware"\n\nThe file metadata has been updated. Would you like me to organize it into a specific folder as well?"

:::

Data Modeling

:::chat

chatId: "data-modeling" messages:

  • role: user content: "Help me build a custom CRM inside my Directus instance. Organizations and contacts with many-to-many, deals with relations to both, activities for tracking emails/calls, deal stages collection."
  • role: assistant content: "I'll help you build a custom CRM! Let me start by understanding your current setup and then create the collections with proper relationships." toolInvocations:
    • toolCallId: "system-prompt" toolName: "system-prompt" state: "result"
    • toolCallId: "schema-check" toolName: "schema" state: "result"
  • role: assistant content: "Perfect! Clean instance. I'll create your CRM collections step by step:" toolInvocations:
    • toolCallId: "create-organizations" toolName: "collections" state: "result" result: "Created organizations collection"
    • toolCallId: "create-contacts" toolName: "collections" state: "result" result: "Created contacts collection"
    • toolCallId: "create-deal-stages" toolName: "collections" state: "result" result: "Created deal_stages collection"
  • role: assistant content: "Collections created! Now creating deals with proper relationships:" toolInvocations:
    • toolCallId: "create-deals" toolName: "collections" state: "result" result: "Created deals collection"
    • toolCallId: "create-activities" toolName: "collections" state: "result" result: "Created activities collection"
    • toolCallId: "create-org-contacts-junction" toolName: "collections" state: "result" result: "Created M2M junction table"
  • role: assistant content: "✅ CRM is ready! Your collections:\n\n- Organizations & Contacts (M2M via junction table)\n- Deals → Organizations, Contacts, Deal Stages, Users (owner)\n- Activities → Organizations, Contacts, Deals (emails, calls, tasks)\n- Deal Stages for pipeline management\n\nAll owners linked to directus_users. Ready to start managing your sales pipeline!"

:::