get_block
Retrieve a specific block from your Logseq graph using its unique ID to access content, hierarchical structure, and journal information.
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)The MCP tool handler for 'get_block', decorated with @mcp.tool(). It defines the input schema via type hints and docstring, and delegates to the LogseqAPIClient.get_block() method.@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)
- Helper method in LogseqAPIClient that calls the Logseq API 'logseq.Editor.getBlock' to fetch the block data.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