Skip to content

JoshTheDerf/directus-extension-mcp-activity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Directus MCP Activity Extension

A Model Context Protocol (MCP) tool for viewing and managing the Directus activity log.

Features

  • View Activity Log: Query the complete activity history with flexible filtering
  • Track User Actions: See who did what, when, and where
  • Filter by Context: Find activities by collection, item, user, or action type
  • Audit Trail: Complete audit trail of all system actions
  • Manage Records: Delete old activity records when needed

Installation

From npm (coming soon)

npm install directus-extension-mcp-activity

Local Development

  1. Clone this repository into your Directus extensions folder
  2. Install dependencies:
    cd extensions/directus-extension-mcp-activity
    npm install
  3. Build the extension:
    npm run build
  4. Restart your Directus instance

Usage

This extension adds an activity tool to your Directus MCP server. It can be accessed through any MCP client connected to your Directus instance.

Available Actions

Read One Activity

Get details about a specific activity:

{
  "action": "readOne",
  "id": "activity-id-123",
  "fields": ["id", "action", "collection", "item", "timestamp", "user.first_name", "user.last_name"]
}

List Recent Activities

Query the activity log with filtering:

{
  "action": "read",
  "limit": 50,
  "sort": ["-timestamp"]
}

Filter by Collection and Item

See all activities for a specific item:

{
  "action": "read",
  "collection": "posts",
  "item": "post-uuid-456",
  "sort": ["-timestamp"]
}

Filter by User

Track actions by a specific user:

{
  "action": "read",
  "user": "user-uuid-789",
  "limit": 100
}

Filter by Action Type

Find specific types of actions:

{
  "action": "read",
  "activityAction": "create",
  "limit": 50
}

Delete Activity Record

Remove an activity record (admin only):

{
  "action": "delete",
  "id": "activity-id-123"
}

Activity Fields

  • id: Unique identifier for the activity
  • action: Type of action (create, update, delete, login, comment, upload, run)
  • user: User who performed the action
  • timestamp: When the action occurred
  • ip: IP address of the user
  • user_agent: Browser/client information
  • collection: Collection the action was performed on (if applicable)
  • item: Primary key of the affected item (if applicable)
  • comment: Optional comment associated with the action
  • origin: Where the action originated (API, app, etc.)
  • revisions: Related revision records

Common Use Cases

Audit Trail

Track all changes to important items:

{
  "action": "read",
  "collection": "products",
  "item": "important-product-id"
}

User Monitoring

See what a user has been doing:

{
  "action": "read",
  "user": "user-id",
  "limit": 100
}

Security Investigation

Check login activities:

{
  "action": "read",
  "activityAction": "login",
  "limit": 50
}

Change History

Track content changes:

{
  "action": "read",
  "collection": "articles",
  "activityAction": "update"
}

Requirements

  • Directus 10.10.0 or higher
  • Admin permissions for delete operations

Development

# Build the extension
npm run build

# Watch mode for development
npm run dev

# Validate the extension
npm run validate

License

MIT

Author

Joshua Bemenderfer

directus-extension-mcp-activity

About

Adds an activity log tool to the Directus MCP server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors