Skip to main content
Glama

get_outline

Generate a structured document outline or table of contents for improved navigation. Specify the document ID and optionally set the maximum heading depth to analyze hierarchical sections efficiently.

Instructions

Get document outline/table of contents.

Tips: First use this tool to understand document structure after you load a document. Args: doc_id: Document identifier max_depth: Maximum heading depth to include, defaults to 3 Returns: Formatted document outline

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_idYes
max_depthNo

Implementation Reference

  • server.py:54-68 (handler)
    The MCP tool handler for get_outline, registered with @mcp.tool(). Includes input schema via docstring and types. Delegates implementation to DocumentNavigator.get_outline.
    @mcp.tool() def get_outline(doc_id: str, max_depth: int = 3) -> str: """Get document outline/table of contents. Tips: First use this tool to understand document structure after you load a document. Args: doc_id: Document identifier max_depth: Maximum heading depth to include, defaults to 3 Returns: Formatted document outline """ return navigator.get_outline(doc_id, max_depth)
  • Core helper function in DocumentNavigator that implements the outline generation logic by recursively traversing the document tree and formatting headings up to max_depth.
    def get_outline(self, doc_id: str, max_depth: int = 3) -> str: """Get document outline.""" document = self.get_document(doc_id) if not document: return f"Document '{doc_id}' not found" # Create a simple outline from document nodes outline = [] def build_outline(node: DocumentNode, depth: int = 0) -> None: if depth > max_depth: return if node.type == "heading" and node.title: indent = " " * (depth - 1) if depth > 0 else "" outline.append(f"{indent}#{node.id} - {node.title}") for child in node.children: build_outline(child, depth + 1 if node.type == "heading" else depth) if document.root: build_outline(document.root) return "\n".join(outline)
  • Similar outline generation method in the legacy DocumentCompass class, with nearly identical recursive traversal logic.
    def get_outline(self, max_depth: int = 3) -> str: """Get document outline as formatted string.""" outline = [] def build_outline(node: DocumentNode, depth: int = 0) -> None: if depth > max_depth: return if node.type == "heading": indent = " " * (depth - 1) if depth > 0 else "" outline.append(f"{indent}#{node.id} - {node.title}") for child in node.children: build_outline(child, depth + 1 if node.type == "heading" else depth) build_outline(self.root) return "\n".join(outline)
  • Structured outline method in Document class returning typed list of dicts, providing a schema-like output format for outlines.
    def get_outline(self, max_depth: int = 3) -> List[Dict[str, Any]]: """Get document outline as a structured list.""" outline = [] def build_outline(node: DocumentNode, depth: int = 0) -> None: if depth > max_depth: return if node.type == "heading" and node.level: outline.append( { "id": node.id, "title": node.title, "level": node.level, "depth": depth, "has_children": bool( [ child for child in node.children if child.type == "heading" ] ), } ) for child in node.children: build_outline(child, depth + 1 if node.type == "heading" else depth) if self.root: build_outline(self.root) return outline

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