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
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| section_id | Yes |
Implementation Reference
- docnav/navigator.py:852-872 (handler)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("#"))