get_page_blocks
Retrieve all blocks from a specific Logseq page, including hierarchical structure and journal page metadata, to analyze page content and organization.
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 information about their 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)
Blocks from journal pages will have:
- "journal?": true
- "journalDay": YYYYMMDD - The date in numeric format (e.g., 20250404)
Args:
page_name (str): The name of the page to retrieve blocks from.
Returns:
list: A 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:8-30 (handler)The MCP tool handler function for 'get_page_blocks', decorated with @mcp.tool() for automatic registration. Includes type annotations, comprehensive docstring serving as schema, and delegates to LogseqAPIClient.@mcp.tool() 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 information about their 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) Blocks from journal pages will have: - "journal?": true - "journalDay": YYYYMMDD - The date in numeric format (e.g., 20250404) Args: page_name (str): The name of the page to retrieve blocks from. Returns: list: A list of blocks from the specified page. """ """Fetch all blocks from a specific page.""" return logseq_client.get_page_blocks(page_name)
- Low-level helper in LogseqAPIClient that implements the core logic by calling the Logseq API endpoint '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/blocks.py:10-28 (schema)Docstring of the handler providing detailed input/output schema description for the MCP tool.""" 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 information about their 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) Blocks from journal pages will have: - "journal?": true - "journalDay": YYYYMMDD - The date in numeric format (e.g., 20250404) Args: page_name (str): The name of the page to retrieve blocks from. Returns: list: A list of blocks from the specified page. """
- src/logseq_mcp/mcp.py:1-4 (registration)Creation of the global FastMCP instance 'mcp' used by @mcp.tool() decorators to register all tools including get_page_blocks.from mcp.server.fastmcp import FastMCP # Create a FastMCP instance that will be used in the tools modules mcp = FastMCP("logseq-mcp")