Skip to main content
Glama

get_outline

Extract and display the table of contents from loaded documents to understand document structure and navigate content 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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:54-67 (handler)
    MCP tool handler for 'get_outline'. This is the function executed when the tool is called, decorated with @mcp.tool() for automatic registration. It delegates to the navigator's implementation.
    @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's node tree, collecting headings up to the specified max_depth, and formatting them as a string.
    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)
Behavior3/5

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

No annotations are provided, so the description carries full burden. It states this is a read operation ('Get'), which is clear, but lacks details on permissions, rate limits, or error handling. The 'Tips' section adds some context about typical workflow, but behavioral traits like response format or potential failures are not disclosed beyond the basic return statement.

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 well-structured and front-loaded with the core purpose, followed by tips and parameter details. Every sentence adds value: the first states the action, the second provides usage guidance, and the last two clarify parameters and returns. No redundant or verbose content is present.

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 parameters, no annotations, but has output schema), the description is largely complete. It covers purpose, usage, parameters, and returns, though behavioral aspects like error cases or performance are omitted. The output schema exists, so the description needn't detail return values, but more transparency on operations would enhance completeness.

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

Parameters4/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 explains 'doc_id' as 'Document identifier' and 'max_depth' as 'Maximum heading depth to include, defaults to 3', adding meaningful context beyond the schema's bare titles. However, it doesn't specify format for 'doc_id' (e.g., string pattern) or constraints for 'max_depth' (e.g., valid range), leaving some gaps.

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 'Get' and resource 'document outline/table of contents', making the purpose specific and unambiguous. It distinguishes this tool from siblings like 'get_document_stats' or 'read_section' by focusing on structural metadata rather than content or statistics.

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

Usage Guidelines5/5

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

The description provides explicit guidance with 'Tips: First use this tool to understand document structure after you load a document.' This tells the agent when to use it (after loading) and implies it's for initial exploration rather than content reading, distinguishing it from alternatives like 'navigate_section' or 'read_section'.

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