Skip to main content
Glama

read_section

Extract specific sections from documents by providing document and section identifiers to retrieve targeted content with subsections for focused analysis.

Instructions

Read content of a specific document section.

Args:
    doc_id: Document identifier
    section_id: Section ID from outline (e.g., 'h1_0', 'h2_1')

Returns:
    Section content with subsections

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_idYes
section_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:70-82 (handler)
    MCP tool handler for 'read_section'. Decorated with @mcp.tool(), handles input parameters, strips '#' from section_id if present, and delegates to Navigator.read_section. This is the entry point for the tool.
    @mcp.tool()
    def read_section(doc_id: str, section_id: str) -> str:
        """Read content of a specific document section.
    
        Args:
            doc_id: Document identifier
            section_id: Section ID from outline (e.g., 'h1_0', 'h2_1')
    
        Returns:
            Section content with subsections
        """
    
        return navigator.read_section(doc_id, section_id.strip("#"))
  • Core helper method in Navigator class that retrieves the document, finds the specified section node, collects content from the node and all its descendants recursively, and joins them into a string. Handles error cases for missing document or section.
    def read_section(self, doc_id: str, section_id: str) -> str:
        """Read specified section content."""
        document = self.get_document(doc_id)
        if not document:
            return f"Document '{doc_id}' not found"
    
        # Get the node and return its content with subsections
        node = document.get_node(section_id)
        if not node:
            return f"Section '{section_id}' not found"
    
        content = [node.content] if node.content else []
    
        def collect_content(n: DocumentNode) -> None:
            for child in n.children:
                if child.content:
                    content.append(child.content)
                collect_content(child)
    
        collect_content(node)
        return "\n".join(content)
  • server.py:70-70 (registration)
    The @mcp.tool() decorator registers the read_section function as an MCP tool.
    @mcp.tool()
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 reads content (implying a read-only operation) and returns section content with subsections, which adds useful behavioral context. However, it doesn't mention potential errors (e.g., invalid IDs), permissions, or rate limits, leaving gaps for a tool with no annotation coverage.

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 appropriately sized and front-loaded, starting with the core purpose in the first sentence. The 'Args' and 'Returns' sections are structured efficiently, with each sentence adding clear value without unnecessary details or repetition.

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

Completeness4/5

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

Given the tool's moderate complexity (2 required parameters) and the presence of an output schema (which handles return values), the description is mostly complete. It covers purpose, parameters, and return behavior, but lacks details on error handling or usage constraints, which could be beneficial despite the output schema.

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

Parameters5/5

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

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'doc_id' is a 'Document identifier' and 'section_id' is a 'Section ID from outline' with examples (e.g., 'h1_0', 'h2_1'), clarifying the format and purpose of both parameters that the schema alone does not provide.

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 specific action ('Read content') and resource ('specific document section'), distinguishing it from siblings like 'get_outline' (structure) and 'load_document' (full document). It precisely defines what the tool does without being vague or tautological.

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

Usage Guidelines3/5

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

The description implies usage by specifying it reads 'a specific document section', suggesting it should be used when you need content from a particular section rather than the whole document. However, it doesn't explicitly state when to use this tool versus alternatives like 'load_document' or 'navigate_section', nor does it mention prerequisites or exclusions.

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/shenyimings/DocNav-MCP'

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