move_block
Move a block and its children to reorganize your Logseq knowledge graph, either as a child or sibling of another block.
Instructions
Moves a block to a new location in the graph.
This allows for reorganizing the structure of blocks in the graph by moving
a block (and all its children) to a different location.
IMPORTANT NOTES:
1. The block will maintain its children when moved
2. The hierarchical position depends on the 'as_child' parameter:
- If as_child=True: The block becomes a child of the target block
- If as_child=False: The block becomes a sibling after the target block
Args:
block_id (str): The ID of the block to move.
target_block_id (str): The ID of the target block to move to.
as_child (bool, optional): Whether to make the block a child of the target.
Default is False (insert as sibling).
Returns:
dict: Result of the move operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| block_id | Yes | ||
| target_block_id | Yes | ||
| as_child | No |
Implementation Reference
- src/logseq_mcp/tools/blocks.py:133-157 (handler)MCP tool handler for 'move_block': decorated with @mcp.tool(), defines input schema via type hints and docstring, executes by calling logseq_client.move_block@mcp.tool() def move_block(block_id: str, target_block_id: str, as_child: bool = False) -> Dict: """ Moves a block to a new location in the graph. This allows for reorganizing the structure of blocks in the graph by moving a block (and all its children) to a different location. IMPORTANT NOTES: 1. The block will maintain its children when moved 2. The hierarchical position depends on the 'as_child' parameter: - If as_child=True: The block becomes a child of the target block - If as_child=False: The block becomes a sibling after the target block Args: block_id (str): The ID of the block to move. target_block_id (str): The ID of the target block to move to. as_child (bool, optional): Whether to make the block a child of the target. Default is False (insert as sibling). Returns: dict: Result of the move operation. """ """Move a block to a new location in the graph.""" return logseq_client.move_block(block_id, target_block_id, as_child)
- Helper method in LogseqAPIClient that performs the actual Logseq API call for moving a block using logseq.Editor.moveBlock with structured parameters.def move_block(self, block_id: str, target_block_id: str, as_child: bool = False) -> Dict: """Move a block to a new location in the graph""" # Determine the appropriate API method based on the as_child parameter method = "logseq.Editor.moveBlock" # The API expects a structured argument for the move operation move_params = { "srcUUID": block_id, "targetUUID": target_block_id, "isChild": as_child } response = self.call_api(method, [move_params]) if isinstance(response, dict) and "result" in response: return response.get("result") return response