move_document
Move documents between folders or to root level in Mnemosyne MCP knowledge graphs to organize workspace navigation and update folder assignments.
Instructions
Move a document to a folder. Set new_parent_id to null to move to root level (unfiled). Note: This updates the document's folder assignment in workspace navigation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| graph_id | Yes | ||
| document_id | Yes | ||
| new_parent_id | No |
Implementation Reference
- src/neem/mcp/tools/hocuspocus.py:786-844 (handler)The main handler function that implements the move_document tool. It authenticates the user, validates inputs, connects to the workspace via Hocuspocus client, verifies the document exists, updates the document's parent folder using WorkspaceWriter, and returns the updated workspace snapshot.async def move_document_tool( graph_id: str, document_id: str, new_parent_id: Optional[str] = None, context: Context | None = None, ) -> dict: """Move a document to a folder via Y.js.""" auth = MCPAuthContext.from_context(context) auth.require_auth() if not graph_id or not graph_id.strip(): raise ValueError("graph_id is required and cannot be empty") if not document_id or not document_id.strip(): raise ValueError("document_id is required and cannot be empty") try: await hp_client.connect_workspace(graph_id.strip()) # Verify document exists in workspace channel = hp_client._workspace_channels.get(graph_id.strip()) if channel is None: raise RuntimeError(f"Workspace not connected: {graph_id}") reader = WorkspaceReader(channel.doc) current = reader.get_document(document_id.strip()) if not current: raise RuntimeError(f"Document '{document_id}' not found in workspace '{graph_id}'") # Update document parent via Y.js await hp_client.transact_workspace( graph_id.strip(), lambda doc: WorkspaceWriter(doc).update_document( document_id.strip(), parent_id=new_parent_id.strip() if new_parent_id else None, ), ) snapshot = hp_client.get_workspace_snapshot(graph_id.strip()) result = { "success": True, "document_id": document_id.strip(), "graph_id": graph_id.strip(), "new_parent_id": new_parent_id.strip() if new_parent_id else None, "workspace": snapshot, } return result except Exception as e: logger.error( "Failed to move document", extra_context={ "graph_id": graph_id, "document_id": document_id, "error": str(e), }, ) raise RuntimeError(f"Failed to move document: {e}")
- src/neem/mcp/tools/hocuspocus.py:777-785 (registration)Registers the move_document tool on the FastMCP server, defining its name, title, description, and input parameters (graph_id, document_id, new_parent_id). This decorator handles schema implicitly via type annotations.@server.tool( name="move_document", title="Move Document", description=( "Move a document to a folder. " "Set new_parent_id to null to move to root level (unfiled). " "Note: This updates the document's folder assignment in workspace navigation." ), )