Skip to main content
Glama

navigate_section

Retrieve navigation context for a specific section in a document, including parent, sibling, and child sections, enabling structured document exploration 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

Implementation Reference

  • MCP tool handler for 'navigate_section'. Decorated with @mcp.tool() which handles registration and schema from type hints/docstring. Delegates to DocumentNavigator.navigate() for core logic.
    @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 navigation logic in DocumentNavigator class. Retrieves the target node, builds breadcrumbs/path, identifies parent, same-level siblings, and child subsections, then formats as readable string output.
    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

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