Repository navigation
Closed
Description
Summary
Extend the move_note MCP tool to support moving entire directories, not just individual files. Also rename the folder parameter in write_note to directory for consistency.
Motivation
Currently, move_note only moves single files. Users need to move directories to reorganize their knowledge base structure efficiently.
Requirements
1. Add is_directory parameter to move_note
async def move_note(
identifier: str,
destination_path: str,
is_directory: bool = False, # NEW
project: Optional[str] = None,
context: Context | None = None,
) -> str:When is_directory=True:
identifieris a directory path (e.g.,"docs","projects/2025")destination_pathis the new directory path (no file extension required)- All files within the directory are moved, preserving relative structure
2. Service layer changes
New method in EntityService:
async def move_directory(
self, source_dir: str, dest_dir: str, project_config, app_config
) -> DirectoryMoveResult:
# 1. Find all entities with file_path starting with source_dir/
entities = await self.entity_repository.find_by_directory_prefix(source_dir)
# 2. Validate no conflicts at destination
# 3. Move each file, updating database
# 4. Return results (success count, failures, etc.)3. API endpoint
New endpoint or enhanced existing:
POST /knowledge/move-directory- Request:
{ "source_directory": str, "destination_directory": str } - Response:
{ "total_files": int, "successful_moves": int, "failed_moves": int, "errors": [...] }
4. Rename folder → directory in write_note
For naming consistency across all tools:
write_note(..., folder: str, ...)→write_note(..., directory: str, ...)- Update docstrings and examples
Existing Infrastructure to Reuse
EntityRepository.find_by_directory_prefix()- SQL LIKE query for finding entities in a directoryFileService.move_file()- Atomic file moves with concurrency controlFileService.ensure_directory()- Creates destination directories- Existing error handling patterns in
move_note
Design Considerations
- Transaction safety: Wrap DB updates in transaction; rollback file moves on failure
- Conflict detection: Check all destination paths before starting moves
- Path transformation:
old_path.replace(f"{source}/", f"{dest}/", 1) - Progress reporting: Return detailed results for large directory moves
Testing Requirements
- Unit tests for path transformation
- Integration tests for directories with 1, 10, 100+ files
- Error cases: permission denied, conflicts, partial failures
- Concurrent directory move operations
Acceptance Criteria
-
move_note("docs", "archive/docs", is_directory=True)moves all files indocs/toarchive/docs/ - Nested directories are preserved (e.g.,
docs/a/b.md→archive/docs/a/b.md) - Database records updated for all moved files
- Search index re-indexed for all moved files
- Clear error messages for conflicts and failures
-
write_noteparameter renamed fromfoldertodirectory
Metadata
Metadata
Assignees
Labels
No labels
Activity
claude commentedon Jan 21, 2026
Claude finished @phernandez's task in 3m 30s —— View job
Issue Analysis Complete ✅
I've analyzed this feature request and prepared a detailed implementation plan.
Issue Triage
Classification:
No Duplicates Found: This is a unique feature request.
Key Findings
The codebase already has excellent infrastructure to build on:
✅ Existing Components:
EntityRepository.find_by_directory_prefix()- Optimized SQL LIKE queries for directory listingFileService.move_file()- Atomic file moves with concurrency controlEntityService.move_entity()- Complete single-file move logic with:/knowledge/entities/{entity_id}/movewith stable UUIDstests/mcp/test_tool_move_note.pyProposed Implementation
Minimal approach that extends existing infrastructure:
1. Rename Parameter ✅ Simple
write_note(..., folder: str, ...)→write_note(..., directory: str, ...)2. Add
is_directoryParameter tomove_noteWhen
is_directory=True:EntityRepository.find_by_directory_prefix()new_path = old_path.replace(source_dir, dest_dir, 1)EntityService.move_entity()(reuses all safety logic)Example:
3. Service Layer Method
4. API Endpoint (Optional)
Design Principles
move_entity()instead of duplicatingis_directory=Falsedefault preserves existing behaviorTesting Strategy
Unit Tests (
tests/):Integration Tests (
test-int/):Coverage: Maintains 100% requirement
Questions Before Implementation
Please confirm your preferences:
API Endpoint: Add dedicated
/v2/knowledge/move-directoryendpoint?Rollback Strategy: On partial failure:
Progress Reporting: For 100+ files:
Proceed with implementation? Or would you like adjustments?
Branch:
claude/issue-516-20260121-0023is ready for implementationfeat: add directory move support to move_note tool (#516)