Labsco
creatuluw logo

Directus Task MCP Server

from creatuluw

Manage tasks in Directus with automatic schema synchronization.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

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

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 limit
  • get-task: Get a specific task by ID
  • create-task: Create a new task
  • update-task: Update an existing task
  • delete-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
}

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

  1. Create a new model file in src/models/
  2. Define TypeScript interfaces and Zod schemas
  3. Export field definitions for Directus
  4. Add tools to the main server for the new model
  5. 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

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