Directus Task MCP Server
Enables AI assistants to manage tasks in Directus databases with automatic schema synchronization, supporting CRUD operations, filtering by status and priority, and TypeScript type safety.
README
Directus Task MCP Server
A Model Context Protocol (MCP) server for managing tasks in Directus with automatic schema synchronization. This server allows you to interact with your Directus PostgreSQL database through AI assistants like Claude or Cursor.
Features
- Task Management: Create, read, update, and delete tasks
- Schema Management: Automatically sync TypeScript models to Directus collections
- Filtering: Filter tasks by status, priority, and other criteria
- Validation: Built-in validation using Zod schemas
- Type Safety: Full TypeScript support with proper typing
Prerequisites
- Node.js 18+
- A Directus instance (local or hosted)
- Directus API token or user credentials
Installation
-
Clone and setup the project:
npm install npm run build -
Configure your Directus connection:
The server uses the following environment variables:
DIRECTUS_URL: Your Directus instance URL (default: https://te9-pg-api.up.railway.app/)DIRECTUS_TOKEN: Your Directus API token (default: mo7tahjWjKgHW-42_tEMThJiqBstu2V_)DIRECTUS_USER_EMAIL: Alternative to token - user emailDIRECTUS_USER_PASSWORD: Alternative to token - user password
Configuration
For Cursor
- Create a
.cursor/mcp.jsonfile in your project root:{ "mcpServers": { "directus-tasks": { "command": "node", "args": ["dist/index.js"], "env": { "DIRECTUS_URL": "https://te9-pg-api.up.railway.app/", "DIRECTUS_TOKEN": "mo7tahjWjKgHW-42_tEMThJiqBstu2V_" } } } }
For Claude Desktop
- Open Claude Desktop settings
- Navigate to Developer tab and click "Edit Config"
- Add the following configuration:
{ "mcpServers": { "directus-tasks": { "command": "node", "args": ["/absolute/path/to/your/project/dist/index.js"], "env": { "DIRECTUS_URL": "https://te9-pg-api.up.railway.app/", "DIRECTUS_TOKEN": "mo7tahjWjKgHW-42_tEMThJiqBstu2V_" } } } }
Important: Replace /absolute/path/to/your/project with the actual absolute path to your project directory.
Available Tools
The MCP server provides the following tools:
Schema Management
sync-task-schema: Synchronizes the Task model schema with your Directus database
Task Management
list-tasks: List all tasks with optional filtering by status, priority, and limitget-task: Get a specific task by IDcreate-task: Create a new taskupdate-task: Update an existing taskdelete-task: Delete a task
User Management
get-user-info: Get current user information
Task Model
The Task model includes the following fields:
interface Task {
id?: string; // UUID primary key
title: string; // Required task title
description?: string; // Optional description
status: 'todo' | 'in_progress' | 'completed'; // Task status
priority: 'low' | 'medium' | 'high'; // Task priority
due_date?: string; // Optional due date (ISO format)
created_at?: string; // Auto-generated creation timestamp
updated_at?: string; // Auto-generated update timestamp
user_created?: string; // Auto-generated user who created
user_updated?: string; // Auto-generated user who updated
}
Usage Examples
1. First Time Setup
Please sync the task schema with the database
2. Create a Task
Create a new task with title "Implement user authentication" and high priority
3. List Tasks
Show me all tasks with status "in_progress"
4. Update a Task
Update task with ID [task-id] to completed status
5. Get Task Details
Show me details for task [task-id]
Development
Project Structure
src/
├── models/
│ └── Task.ts # Task model with TypeScript interfaces and Zod schemas
├── services/
│ └── SchemaManager.ts # Schema management service
└── index.ts # Main MCP server implementation
Adding New Models
- Create a new model file in
src/models/ - Define TypeScript interfaces and Zod schemas
- Export field definitions for Directus
- Add tools to the main server for the new model
- Use SchemaManager to sync the schema
Development Commands
# Install dependencies
npm install
# Build the project
npm run build
# Development mode (watch for changes)
npm run dev
# Start the server directly
npm start
Troubleshooting
Common Issues
- Authentication Errors: Verify your Directus URL and token are correct
- Schema Sync Failures: Ensure your Directus user has admin permissions
- Connection Issues: Check that your Directus instance is accessible
Debugging
The server logs errors to stderr. You can check the logs in your AI assistant's console or terminal.
Security Notes
- Store your Directus token securely
- Use environment variables for sensitive configuration
- Consider using a dedicated service account for the MCP server
- Regularly rotate your API tokens
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。