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.
This MCP server requires NodeJS v22.12 or newer.
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>"
}
}
}
}
pnpm install && pnpm build
{
"mcpServers": {
"directus": {
"command": "node",
"args": ["/path/to/directus-mcp-server/dist/index.js"]
}
}
}
The Directus MCP Server provides several tools to interact with your Directus instance.
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.
The read-items
tool allows you to fetch data from any Directus collection.
Parameters:
collection
: (required) The name of the collection to read fromfields
: (optional) Array of field names to returnsort
: (optional) Field to sort by (prefix with -
for descending order)limit
: (optional) Maximum number of items to returnExample 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.
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.
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.
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"
]
}
}
}
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.
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.