Skip to main content
Glama
mikeysrecipes

Logseq MCP Tools

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

Implementation Reference

  • 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 []
  • 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.
    """
  • 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")
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: it specifies the hierarchical structure of returned blocks (parent, level, left), details special fields for journal pages (journal?, journalDay), and clarifies the return type (list of blocks). However, it doesn't mention potential errors (e.g., invalid page names) or performance aspects like pagination.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized: it starts with the core purpose, follows with usage guidelines and behavioral details, and ends with explicit Args and Returns sections. Every sentence adds value, though the formatting with bullet points and separate sections is slightly verbose but still efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (retrieving structured data), no annotations, no output schema, and 1 parameter with 0% schema coverage, the description is largely complete. It covers purpose, usage, behavior, parameters, and return values. However, it lacks error handling information and doesn't explicitly state that it's a read-only operation (though implied by 'Gets').

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must fully compensate. It adds significant meaning beyond the bare schema: it explains the parameter 'page_name' as 'The name of the page to retrieve blocks from,' provides a specific format example for journal pages ('mmm dth, yyyy'), and implicitly clarifies that page names are strings. This fully documents the single parameter's semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Gets all blocks') and resource ('from a specific page in the Logseq graph'), distinguishing it from siblings like get_block (single block), get_all_pages (pages only), and search_blocks (filtered search). The verb 'gets' is precise and the scope 'all blocks from a specific page' is well-defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly provides when-to-use guidance: 'For journal pages, use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025").' This distinguishes usage from regular pages and offers a clear alternative format for a specific case, helping the agent choose correctly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/mikeysrecipes/logseq-mcp'

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