Skip to main content
Glama

get_block

Retrieve a specific block from a Logseq graph by its ID, including hierarchical details like parent block, indentation level, and adjacent blocks for structured data access.

Instructions

Gets a specific block from the Logseq graph by its ID. The returned block contains hierarchical structure information: - parent: The parent block's ID - level: The indentation level - left: The block to the left Args: block_id: The ID of the block to retrieve. Returns: Information about the requested block, or None if not found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
block_idYes

Implementation Reference

  • MCP tool handler for get_block, decorated with @mcp.tool(). Delegates to LogseqAPIClient to fetch the 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 hierarchical structure information: - parent: The parent block's ID - level: The indentation level - left: The block to the left Args: block_id: The ID of the block to retrieve. Returns: Information about the requested block, or None if not found. """ return logseq_client.get_block(block_id)
  • Implementation in LogseqAPIClient that calls the Logseq API endpoint logseq.Editor.getBlock to retrieve block data 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
  • Package __init__ that imports and exports the get_block tool, and provides main() to run the MCP server, triggering tool registrations via decorators.
    from .mcp import mcp from .utils.logging import log 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, ) import os import inspect __all__ = ["get_all_pages", "get_page", "create_page", "get_page_blocks", "get_block", "create_block", "update_block", "search_blocks", "get_page_linked_references"]

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