get_page_blocks
Retrieve structured blocks from a specific Logseq page, including hierarchical details like parent ID, indentation level, and left block relationships, using the page name as input.
Instructions
Gets all blocks from a specific page in the Logseq graph.
For journal pages, use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025").
Returned blocks contain hierarchical structure information:
- parent: The parent block's ID
- level: The indentation level (1 for top-level, 2+ for indented)
- left: The block to the left (typically the parent for indented blocks)
Args:
page_name: The name of the page to retrieve blocks from.
Returns:
List of blocks from the specified page.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_name | Yes |
Implementation Reference
- src/logseq_mcp/tools/blocks.py:9-25 (handler)The MCP tool handler for 'get_page_blocks', decorated with @mcp.tool(). Includes type hints and docstring serving as input/output schema. Delegates to LogseqAPIClient.get_page_blocks().def get_page_blocks(page_name: str) -> List[Dict]: """ Gets all blocks from a specific page in the Logseq graph. For journal pages, use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025"). Returned blocks contain hierarchical structure information: - parent: The parent block's ID - level: The indentation level (1 for top-level, 2+ for indented) - left: The block to the left (typically the parent for indented blocks) Args: page_name: The name of the page to retrieve blocks from. Returns: List of blocks from the specified page. """ return logseq_client.get_page_blocks(page_name)
- Helper method in LogseqAPIClient that performs the actual API call to retrieve page blocks from Logseq using 'logseq.Editor.getPageBlocksTree'.def get_page_blocks(self, page_name: str) -> List[Dict]: """Get all blocks for a page""" response = self.call_api("logseq.Editor.getPageBlocksTree", [page_name]) if isinstance(response, list): return response return response.get("result", []) if isinstance(response, dict) else []
- src/logseq_mcp/tools/__init__.py:2-2 (registration)Import of the get_page_blocks tool function from blocks.py, exposing it for use in the tools module.from .blocks import get_page_blocks, get_block, create_block, update_block, remove_block, insert_block, move_block, search_blocks
- src/logseq_mcp/__init__.py:7-7 (registration)Inclusion of get_page_blocks in the main module imports and __all__, ensuring it's registered when the server runs.get_page_blocks,