Skip to main content
Glama

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
NameRequiredDescriptionDefault
page_nameYes

Implementation Reference

  • 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 []
  • 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
  • Inclusion of get_page_blocks in the main module imports and __all__, ensuring it's registered when the server runs.
    get_page_blocks,
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/apw124/logseq-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server