get_block
Retrieve a specific block from the Logseq graph by its ID, including hierarchical details like parent ID, indentation level, and journal information if applicable.
Instructions
Gets a specific block from the Logseq graph by its ID.
The returned block contains information about its hierarchical structure:
- parent: The parent block's ID
- level: The indentation level (1 for top-level, 2+ for indented blocks)
- left: The block to the left (typically the parent for indented blocks)
If the block is from a journal page, it will include:
- "journal?": true
- "journalDay": YYYYMMDD - Date in numeric format
Args:
block_id (str): The ID of the block to retrieve.
Returns:
dict: Information about the requested block.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| block_id | Yes |
Implementation Reference
- src/logseq_mcp/tools/blocks.py:32-53 (handler)MCP tool handler function for 'get_block', decorated with @mcp.tool(). Includes schema in docstring. Delegates to LogseqAPIClient.get_block().@mcp.tool() def get_block(block_id: str) -> Optional[Dict]: """ Gets a specific block from the Logseq graph by its ID. The returned block contains information about its hierarchical structure: - parent: The parent block's ID - level: The indentation level (1 for top-level, 2+ for indented blocks) - left: The block to the left (typically the parent for indented blocks) If the block is from a journal page, it will include: - "journal?": true - "journalDay": YYYYMMDD - Date in numeric format Args: block_id (str): The ID of the block to retrieve. Returns: dict: Information about the requested block. """ """Fetch a specific block by ID.""" return logseq_client.get_block(block_id)
- LogseqAPIClient helper method that performs the actual API call to retrieve a block by ID.def get_block(self, block_id: str) -> Optional[Dict]: """Get a block by ID""" response = self.call_api("logseq.Editor.getBlock", [block_id]) if response is None: return None return response.get("result") if isinstance(response, dict) else response
- src/logseq_mcp/__init__.py:3-13 (registration)Imports get_block tool (among others) in the main __init__.py, which registers it when mcp.run() is called.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, )
- src/logseq_mcp/tools/__init__.py:1-2 (registration)Re-exports get_block from blocks.py module in tools/__init__.pyfrom .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:34-51 (schema)Docstring providing input/output schema for the get_block tool.""" Gets a specific block from the Logseq graph by its ID. The returned block contains information about its hierarchical structure: - parent: The parent block's ID - level: The indentation level (1 for top-level, 2+ for indented blocks) - left: The block to the left (typically the parent for indented blocks) If the block is from a journal page, it will include: - "journal?": true - "journalDay": YYYYMMDD - Date in numeric format Args: block_id (str): The ID of the block to retrieve. Returns: dict: Information about the requested block. """