Skip to main content
Glama

get_block

Read a specific block by its data-block-id to retrieve XML content, attributes, text, and context without fetching the entire document.

Instructions

Read a specific block by its data-block-id. Returns detailed info including the block's XML content, attributes, text content, and context (prev/next block IDs). Use this for targeted reads without fetching the entire document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graph_idYes
document_idYes
block_idYes

Implementation Reference

  • The main handler function for the 'get_block' MCP tool. It authenticates, connects to the specified graph and document, retrieves the block information using DocumentReader.get_block_info(), and returns a dictionary with graph_id, document_id, and the block details (including XML content, attributes, text, and prev/next IDs).
    @server.tool( name="get_block", title="Get Block by ID", description=( "Read a specific block by its data-block-id. Returns detailed info including " "the block's XML content, attributes, text content, and context (prev/next block IDs). " "Use this for targeted reads without fetching the entire document." ), ) async def get_block_tool( graph_id: str, document_id: str, block_id: str, context: Context | None = None, ) -> dict: """Get detailed information about a block by its ID.""" auth = MCPAuthContext.from_context(context) auth.require_auth() if not graph_id or not graph_id.strip(): raise ValueError("graph_id is required") if not document_id or not document_id.strip(): raise ValueError("document_id is required") if not block_id or not block_id.strip(): raise ValueError("block_id is required") try: await hp_client.connect_document(graph_id.strip(), document_id.strip()) channel = hp_client.get_document_channel(graph_id.strip(), document_id.strip()) if channel is None: raise RuntimeError(f"Document channel not found: {graph_id}/{document_id}") reader = DocumentReader(channel.doc) block_info = reader.get_block_info(block_id.strip()) if block_info is None: raise RuntimeError(f"Block not found: {block_id}") result = { "graph_id": graph_id.strip(), "document_id": document_id.strip(), "block": block_info, } return result except Exception as e: logger.error( "Failed to get block", extra_context={ "graph_id": graph_id, "document_id": document_id, "block_id": block_id, "error": str(e), }, ) raise RuntimeError(f"Failed to get block: {e}")

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/sophia-labs/mnemosyne-mcp'

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