remove_block
Permanently delete a block and its child blocks from your Logseq knowledge graph using the block ID. This action cannot be undone.
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/blocks.py:159-179 (handler)The MCP tool handler for 'remove_block', decorated with @mcp.tool(). It invokes the LogseqAPIClient's 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)
- Helper method in LogseqAPIClient that performs the actual API call to logseq.Editor.removeBlock to remove the block.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
- src/logseq_mcp/__init__.py:1-18 (registration)Imports from tools module which triggers loading of blocks.py (containing remove_block) via tools/__init__.py, implicitly registering the @mcp.tool() decorated functions including remove_block.from .mcp import mcp from .utils.logging import log from .tools import ( get_all_pages, get_page, create_page, get_page_blocks, get_block, create_block, update_block, search_blocks, get_page_linked_references, ) import os import inspect __all__ = ["get_all_pages", "get_page", "create_page", "get_page_blocks", "get_block", "create_block", "update_block", "search_blocks", "get_page_linked_references"]