Skip to main content
Glama

move_block

Relocate a block (and its children) to a new position in the Logseq graph. Choose to insert it as a child or sibling of the target block to restructure your knowledge base.

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
NameRequiredDescriptionDefault
as_childNo
block_idYes
target_block_idYes

Implementation Reference

  • MCP tool handler for 'move_block' decorated with @mcp.tool(). Calls the underlying logseq_client.move_block method. Includes full docstring for schema.
    @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 implements the move_block logic by calling the Logseq API '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
  • Exports the move_block tool from blocks.py and includes it in __all__ for module-level registration/import.
    from .pages import get_all_pages, get_page, create_page, delete_page, get_page_linked_references from .blocks import get_page_blocks, get_block, create_block, update_block, remove_block, insert_block, move_block, search_blocks __all__ = [ "get_all_pages", "get_page", "create_page", "delete_page", "get_page_blocks", "get_block", "create_block", "update_block", "remove_block", "insert_block", "move_block", "search_blocks", "get_page_linked_references", ]

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mikeysrecipes/logseq-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server