Directus MCP server

Bridges AI tools with Directus headless CMS, enabling content operations through automatically generated tools based on your instance's schema
Back to servers
Provider
Rijk van Zanten
Release date
Apr 01, 2025
Language
TypeScript
Package
Stats
221 downloads
24 stars

Directus Model Context Protocol (MCP) Server allows your AI tools to connect to and use your Directus API on your behalf. This MCP server enables AI assistants like Claude to interact directly with your Directus instance, querying collections and retrieving data as needed.

Installation

This MCP server requires NodeJS v22.12 or newer.

Global Installation (Recommended)

npm install -g @rijk/directus-mcp-server

Then configure Claude AI to use the npm package as remote server:

{
  "mcpServers": {
    "directus": {
      "command": "directus-mcp-server",
      "env": {
        "DIRECTUS_URL": "<your Directus instance URL>",
        "DIRECTUS_TOKEN": "<your Directus user token>"
      }
    }
  }
}

Local Installation

  1. Clone the repository
  2. Install dependencies and build the server:
    pnpm install && pnpm build
    
  3. Configure Claude AI by pointing it to the built file:
    {
      "mcpServers": {
        "directus": {
          "command": "node",
          "args": ["/path/to/directus-mcp-server/dist/index.js"]
        }
      }
    }
    

Using the MCP Server

The Directus MCP Server provides several tools to interact with your Directus instance.

Reading Collections

Before retrieving data, you should first discover what collections are available in your Directus instance. Use the read-collections tool to get information about all available collections and their fields.

Reading Items

The read-items tool allows you to fetch data from any Directus collection.

Parameters:

  • collection: (required) The name of the collection to read from
  • fields: (optional) Array of field names to return
  • sort: (optional) Field to sort by (prefix with - for descending order)
  • limit: (optional) Maximum number of items to return

Example usage:

{
  "collection": "articles",
  "fields": ["id", "title", "date_published"],
  "sort": "-date_published",
  "limit": 10
}

This would return the 10 most recently published articles with only the id, title, and publication date fields.

Getting Current User Information

Use the read-current-user tool to retrieve information about the currently authenticated user. This corresponds to the /users/me endpoint in the Directus API.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later