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
| Name | Required | Description | Default |
|---|---|---|---|
| graph_id | Yes | ||
| document_id | Yes | ||
| block_id | Yes |
Implementation Reference
- src/neem/mcp/tools/hocuspocus.py:850-907 (handler)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}")