Skip to main content
Glama

Get Block by ID

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}")
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that the tool is a read operation (implied safe) and describes the return content (XML, attributes, text, context), which is helpful. However, it lacks details on permissions, error handling, rate limits, or whether it's idempotent, leaving behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose, followed by return details and usage context in two efficient sentences. Every sentence adds value without redundancy, making it appropriately sized and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and 3 required parameters with 0% schema coverage, the description is incomplete. It covers the purpose and return content well but fails to explain parameter meanings or full behavioral traits, leaving gaps for a tool with multiple inputs.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It only mentions 'data-block-id' (likely referring to block_id), but does not explain the purpose or relationships of graph_id and document_id parameters. This leaves two of three parameters semantically unclear.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Read') and resource ('a specific block by its data-block-id'), distinguishing it from siblings like query_blocks (which likely searches/filters) or read_document (which fetches entire documents). It specifies the targeted nature of the operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('for targeted reads without fetching the entire document'), implicitly contrasting with read_document. However, it does not explicitly state when not to use it or name alternatives, missing full explicit guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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