get_block
Retrieve a specific block from a Logseq graph by its ID, including hierarchical details like parent block, indentation level, and adjacent blocks for structured data access.
Instructions
Gets a specific block from the Logseq graph by its ID.
The returned block contains hierarchical structure information:
- parent: The parent block's ID
- level: The indentation level
- left: The block to the left
Args:
block_id: The ID of the block to retrieve.
Returns:
Information about the requested block, or None if not found.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| block_id | Yes |
Implementation Reference
- src/logseq_mcp/tools/blocks.py:27-43 (handler)MCP tool handler for get_block, decorated with @mcp.tool(). Delegates to LogseqAPIClient to fetch the 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 hierarchical structure information: - parent: The parent block's ID - level: The indentation level - left: The block to the left Args: block_id: The ID of the block to retrieve. Returns: Information about the requested block, or None if not found. """ return logseq_client.get_block(block_id)
- Implementation in LogseqAPIClient that calls the Logseq API endpoint logseq.Editor.getBlock to retrieve block data 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:1-17 (registration)Package __init__ that imports and exports the get_block tool, and provides main() to run the MCP server, triggering tool registrations via decorators.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"]