remove_block
Permanently deletes a specified block and its children from the Logseq graph using its unique block ID. Ensure the block ID is obtained from functions like get_page_blocks(), get_block(), or search_blocks(). This action is irreversible.
Instructions
Removes a block from the Logseq graph.
This operation permanently removes the specified block and all its children.
This action cannot be undone.
To remove a block, you need its block ID, which can be obtained from:
- get_page_blocks() function
- get_block() function
- search_blocks() function
Args:
block_id (str): The ID of the block to remove.
Returns:
dict: Result of the removal operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| block_id | Yes |
Implementation Reference
- src/logseq_mcp/tools/__init__.py:1-2 (registration)Imports from blocks.py including remove_block, which triggers execution of the @mcp.tool() decorator during module import, effectively registering the tool.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
- src/logseq_mcp/tools/blocks.py:159-179 (handler)The core MCP tool handler for 'remove_block'. Decorated with @mcp.tool(), it defines the input schema via type hints and docstring, and implements the logic by delegating to the LogseqAPIClient.remove_block method.@mcp.tool() def remove_block(block_id: str) -> Dict: """ Removes a block from the Logseq graph. This operation permanently removes the specified block and all its children. This action cannot be undone. To remove a block, you need its block ID, which can be obtained from: - get_page_blocks() function - get_block() function - search_blocks() function Args: block_id (str): The ID of the block to remove. Returns: dict: Result of the removal operation. """ """Remove a block and its children from the graph.""" return logseq_client.remove_block(block_id)
- Supporting client method in LogseqAPIClient that performs the actual HTTP API call to Logseq's Editor.removeBlock endpoint.def remove_block(self, block_id: str) -> Dict: """Remove a block and its children from the graph""" response = self.call_api("logseq.Editor.removeBlock", [block_id]) if isinstance(response, dict) and "result" in response: return response.get("result") return response