move_artifact
Move artifacts between folders or to root level in Mnemosyne knowledge graphs to reorganize content structure.
Instructions
Move an artifact to a different folder. Set new_parent_id to null to move to root level.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| graph_id | Yes | ||
| artifact_id | Yes | ||
| new_parent_id | No | ||
| new_order | No |
Implementation Reference
- src/neem/mcp/tools/hocuspocus.py:644-705 (handler)The handler function that executes the move_artifact tool. It authenticates, validates inputs, reads current artifact state from Y.js workspace, updates the parent folder and order using WorkspaceWriter, and returns the updated workspace snapshot.async def move_artifact_tool( graph_id: str, artifact_id: str, new_parent_id: Optional[str] = None, new_order: Optional[float] = None, context: Context | None = None, ) -> dict: """Move an artifact to a different 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 artifact_id or not artifact_id.strip(): raise ValueError("artifact_id is required and cannot be empty") try: await hp_client.connect_workspace(graph_id.strip()) # Read current artifact state from Y.js 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_artifact(artifact_id.strip()) if not current: raise RuntimeError(f"Artifact '{artifact_id}' not found in graph '{graph_id}'") # Update artifact with new parent/order via Y.js await hp_client.transact_workspace( graph_id.strip(), lambda doc: WorkspaceWriter(doc).update_artifact( artifact_id.strip(), parent_id=new_parent_id.strip() if new_parent_id else None, order=new_order, ), ) snapshot = hp_client.get_workspace_snapshot(graph_id.strip()) result = { "success": True, "artifact_id": artifact_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 artifact", extra_context={ "graph_id": graph_id, "artifact_id": artifact_id, "error": str(e), }, ) raise RuntimeError(f"Failed to move artifact: {e}")
- src/neem/mcp/tools/hocuspocus.py:636-643 (registration)The @server.tool decorator that registers the move_artifact tool with the FastMCP server, specifying its name, title, and description. The function signature provides the input schema.@server.tool( name="move_artifact", title="Move Artifact", description=( "Move an artifact to a different folder. " "Set new_parent_id to null to move to root level." ), )
- src/neem/mcp/server/standalone_server.py:317-317 (registration)Call to register_hocuspocus_tools which includes the move_artifact tool registration in the standalone MCP server.register_hocuspocus_tools(mcp_server)