Skip to main content
Glama
mikeysrecipes

Logseq MCP Tools

get_block

Retrieve a specific block from your Logseq graph using its unique ID to access content, hierarchical structure, and journal information.

Instructions

Gets a specific block from the Logseq graph by its ID.

The returned block contains information about its 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)

If the block is from a journal page, it will include:
  - "journal?": true
  - "journalDay": YYYYMMDD - Date in numeric format

Args:
    block_id (str): The ID of the block to retrieve.
    
Returns:
    dict: Information about the requested block.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
block_idYes

Implementation Reference

  • The MCP tool handler for 'get_block', decorated with @mcp.tool(). It defines the input schema via type hints and docstring, and delegates to the LogseqAPIClient.get_block() method.
    @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 information about its 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)
        
        If the block is from a journal page, it will include:
          - "journal?": true
          - "journalDay": YYYYMMDD - Date in numeric format
        
        Args:
            block_id (str): The ID of the block to retrieve.
            
        Returns:
            dict: Information about the requested block.
        """
        """Fetch a specific block by ID."""
        return logseq_client.get_block(block_id)
  • Helper method in LogseqAPIClient that calls the Logseq API 'logseq.Editor.getBlock' to fetch the block data.
    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

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