Skip to main content
Glama

read_section

Extract specific document sections and their subsections by providing a document ID and section ID. Simplify navigation and analysis of lengthy documents by retrieving precise content.

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

Implementation Reference

  • Core implementation of read_section in DocumentNavigator class. Retrieves the document by ID, finds the specified section node, collects content from the node and all its subsections recursively, and returns the concatenated content.
    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-82 (registration)
    MCP tool registration for read_section using FastMCP's @mcp.tool() decorator. Provides input schema via type hints and docstring, strips optional # from section_id, and delegates to the navigator's read_section method.
    @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("#"))

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

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