Skip to main content
Glama

navigate_section

Navigate document sections to find parent, sibling, and child relationships for better document comprehension and analysis.

Instructions

Get navigation context for a section (parent, siblings, children).

Args:
    doc_id: Document identifier
    section_id: Section ID to navigate to

Returns:
    Navigation context with related sections

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_idYes
section_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler and registration for the 'navigate_section' tool. Includes input schema via type hints and docstring, delegates core logic to DocumentNavigator.navigate.
    @mcp.tool()
    def navigate_section(doc_id: str, section_id: str) -> str:
        """Get navigation context for a section (parent, siblings, children).
    
        Args:
            doc_id: Document identifier
            section_id: Section ID to navigate to
    
        Returns:
            Navigation context with related sections
        """
        return navigator.navigate(doc_id, section_id.strip("#"))
  • Core implementation of section navigation in DocumentNavigator, providing formatted output with current section, breadcrumb path, parent, siblings, and subsections.
    def navigate(self, doc_id: str, section_id: str) -> str:
        """Get navigation context as formatted string."""
        document = self.get_document(doc_id)
        if not document:
            return f"Document '{doc_id}' not found"
    
        node = document.get_node(section_id)
        if not node:
            return f"Section '{section_id}' not found"
    
        output = f"Current: {node.title or node.id}\n"
    
        # Build breadcrumbs
        ancestors = []
        current = node.parent
        while current and current.type != "document":
            if current.type == "heading":
                ancestors.append(current)
            current = current.parent
    
        if ancestors:
            breadcrumb_path = " > ".join([a.title for a in reversed(ancestors)])
            output += f"Path: {breadcrumb_path} > {node.title or node.id}\n"
    
        # Find parent
        if node.parent and node.parent.type == "heading":
            output += f"Parent: {node.parent.title}\n"
    
        # Find siblings (same level headings)
        if node.parent:
            siblings = [
                child for child in node.parent.children if child.type == "heading"
            ]
            if len(siblings) > 1:
                output += "Siblings:\n"
                for sibling in siblings:
                    marker = "→ " if sibling.id == node.id else "  "
                    output += f"{marker}{sibling.title} (#{sibling.id})\n"
    
        # Find children (direct child headings)
        children = [child for child in node.children if child.type == "heading"]
        if children:
            output += "Subsections:\n"
            for child in children:
                output += f"  {child.title} (#{child.id})\n"
    
        return output
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral context. It implies a read-only operation ('Get') but doesn't disclose error handling (e.g., invalid IDs), performance traits (e.g., speed), authentication needs, or whether it modifies state. The return statement is vague about format.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the core purpose in the first sentence and parameter/return details in a structured format. Every sentence adds value, though the return statement could be more specific to enhance clarity without sacrificing brevity.

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

Completeness3/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 minimally adequate. It covers purpose and parameters but lacks usage guidelines and behavioral details, making it incomplete for optimal agent use without additional context.

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

Parameters3/5

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

Schema description coverage is 0%, but the description adds basic meaning: 'doc_id' is a 'Document identifier' and 'section_id' is a 'Section ID to navigate to'. This clarifies their roles beyond schema titles. However, it doesn't detail expected formats (e.g., string patterns) or constraints, leaving gaps in documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('navigation context for a section'), including what information it retrieves (parent, siblings, children). It distinguishes itself from siblings like 'read_section' (which reads content) or 'get_outline' (which provides document structure), though it doesn't explicitly name these alternatives.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing valid document/section IDs), compare to siblings like 'get_outline' for broader navigation, or specify use cases like exploring document hierarchy versus reading content.

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