Skip to main content
Glama

get_block

Retrieve a specific block from the Logseq graph by its ID, including hierarchical details like parent ID, indentation level, and journal information if applicable.

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

  • MCP tool handler function for 'get_block', decorated with @mcp.tool(). Includes schema in docstring. Delegates to LogseqAPIClient.get_block().
    @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)
  • LogseqAPIClient helper method that performs the actual API call to retrieve a block by ID.
    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
  • Imports get_block tool (among others) in the main __init__.py, which registers it when mcp.run() is called.
    from .tools import ( get_all_pages, get_page, create_page, get_page_blocks, get_block, create_block, update_block, search_blocks, get_page_linked_references, )
  • Re-exports get_block from blocks.py module in tools/__init__.py
    from .pages import get_all_pages, get_page, create_page, delete_page, get_page_linked_references from .blocks import get_page_blocks, get_block, create_block, update_block, remove_block, insert_block, move_block, search_blocks
  • Docstring providing input/output schema for the get_block tool.
    """ 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. """

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

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