-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Feature Request: Add Collection and Collection Group Management Tools
Summary
Add comprehensive collection management capabilities to the Directus MCP Server, including collection creation/deletion and collection group organization tools.
Motivation
User Story
As a content manager/system administrator using AI assistants with Directus, I want to organize my collections into logical groups and create new collections through natural language commands, so that I can maintain a clean and organized database structure without manually navigating the admin interface.
Current Gap
The MCP server currently only provides read access to collections via read-collections
. Users cannot:
- Create new collections programmatically through AI assistants
- Organize collections into groups (folders) for better structure
- Delete unused collections safely
- Manage collection organization at scale
Proposed Features
Collection Management
create-collection
- Create collections with fields and metadatadelete-collection
- Safely delete collections with confirmation
Collection Group Management
create-collection-group
- Create organizational foldersdelete-collection-group
- Remove groups (moves collections to root)assign-collection-to-group
- Organize existing collectionsremove-collection-from-group
- Move collections back to rootlist-collection-groups
- View organizational structure
Use Cases
- Content Editors: "Create a new blog posts collection with title and content fields"
- System Administrators: "Organize all user-related collections into a 'User Management' group"
- Developers: "Set up the initial database structure for our new project"
- Data Architects: "Clean up unused collections and reorganize the schema"
Implementation Benefits
- Non-destructive by default: All tools include safety confirmations
- Schema cache integration: Automatic cache refresh after changes
- Consistent API: Follows existing MCP tool patterns
- Comprehensive validation: Proper error handling and parameter validation
Technical Considerations
- Uses existing Directus SDK methods (
createCollection
,deleteCollection
,updateCollection
) - Maintains backward compatibility with current tools
- Includes comprehensive TypeScript types and validation
- Follows MCP protocol standards
Business Value
- Productivity: Reduces manual admin interface navigation
- Consistency: Ensures standardized collection setup through AI guidance
- Organization: Enables systematic database structure management
- Accessibility: Makes complex admin tasks available through natural language
Example Usage
Creating a Collection
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create-collection",
"arguments": {
"collection": "blog_posts",
"meta": {
"icon": "article",
"note": "Blog posts collection"
},
"fields": [
{
"field": "title",
"type": "string",
"meta": {
"interface": "input",
"required": true
}
},
{
"field": "content",
"type": "text",
"meta": {
"interface": "input-rich-text-html"
}
}
]
}
}
}
Organizing Collections into Groups
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create-collection-group",
"arguments": {
"group": "content-management",
"meta": {
"icon": "folder",
"note": "Content management collections",
"color": "#2196F3"
}
}
}
}
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "assign-collection-to-group",
"arguments": {
"collection": "blog_posts",
"group": "content-management"
}
}
}
Safety Features
- Confirmation required for destructive operations (
delete-collection
,delete-collection-group
) - Comprehensive validation of input parameters
- Graceful error handling with descriptive messages
- Schema cache refresh ensures consistency
Impact on Existing Users
- Fully backward compatible - no breaking changes
- Optional features - existing workflows remain unchanged
- Enhanced functionality - expands capabilities without affecting current tools
This enhancement would significantly expand the MCP server's utility for database management workflows while maintaining the safety-first approach of the current implementation.
Implementation Status
🚧 Work in Progress - This feature has been implemented in a fork and is available for testing:
- Fork Repository: fefehun/directus-mcp
- Feature Branch:
feature/collection-management
- Status: Ready for review and testing
- Pull Request: [Link to PR when created]
Testing
The implementation includes:
- ✅ All 7 collection management tools fully implemented
- ✅ Updated documentation with examples
- ✅ TypeScript types and validation
- ✅ Schema cache integration
- 🔄 TODO: Add comprehensive test suite for all new tools
You can test the implementation by:
- Cloning the fork:
git clone https://github.com/[username]/directus-mcp.git
- Checking out the feature branch:
git checkout feature/collection-group-management
- Building and running:
pnpm install && pnpm build
Ready for Integration
This implementation is production-ready and awaiting review for potential inclusion in the main repository. All safety considerations and backward compatibility have been maintained.