Skip to main content
Glama

list_sections

Extract and display all sections from a Markdown document to help users navigate content and understand document structure.

Instructions

        List all sections in the document.
        
        Args:
            document_path: Path to the Markdown file
            validation_level: Validation strictness - "STRICT", "NORMAL", or "PERMISSIVE"  
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_pathYes
validation_levelNoNORMAL

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'list_sections' MCP tool. It loads the document using StatelessMarkdownProcessor, retrieves sections, extracts content previews using line ranges, and returns a structured list of sections with metadata.
    def list_sections(document_path: str, validation_level: str = "NORMAL") -> Dict[str, Any]:
        """
        List all sections in the document.
        
        Args:
            document_path: Path to the Markdown file
            validation_level: Validation strictness - "STRICT", "NORMAL", or "PERMISSIVE"  
        """
        try:
            validation_map = {"STRICT": ValidationLevel.STRICT, "NORMAL": ValidationLevel.NORMAL, "PERMISSIVE": ValidationLevel.PERMISSIVE}
            validation_enum = validation_map.get(validation_level.upper(), ValidationLevel.NORMAL)
            
            editor = self.processor.load_document(document_path, validation_enum)
            sections = editor.get_sections()
            
            # Get full content to extract section content
            full_content = editor.to_markdown()
            lines = full_content.split('\n')
            
            # Build section list with content preview
            section_list = []
            for section in sections:
                # Extract section content using line ranges
                try:
                    section_lines = lines[section.line_start:section.line_end+1]
                    section_content = '\n'.join(section_lines)
                    content_preview = section_content[:100] + "..." if len(section_content) > 100 else section_content
                except (IndexError, AttributeError):
                    # Fallback if line extraction fails
                    content_preview = "Content preview not available"
                
                section_list.append({
                    "id": section.id,  
                    "title": section.title,
                    "level": section.level,
                    "line_start": section.line_start,
                    "line_end": section.line_end,
                    "content_preview": content_preview
                })
            
            return {
                "success": True,
                "sections": section_list,
                "total_sections": len(sections)
            }
            
        except Exception as e:
            return self.processor.create_error_response(str(e), type(e).__name__)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'validation_level' but doesn't explain what validation entails (e.g., checking document format, handling errors) or the tool's behavior (e.g., returns a list, potential errors). This leaves significant gaps in understanding how the tool operates.

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 with a clear purpose statement followed by parameter explanations in a structured 'Args' section. It avoids unnecessary fluff, though the formatting with extra whitespace slightly reduces efficiency.

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 parameters, no annotations) and the presence of an output schema (which handles return values), the description is minimally adequate. It covers the basics but lacks details on behavioral traits, usage context, and full parameter semantics, making it incomplete for optimal agent understanding.

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%, so the description must compensate. It adds meaning by explaining 'document_path' as 'Path to the Markdown file' and 'validation_level' with its possible values, which clarifies beyond the bare schema. However, it doesn't detail the format of 'document_path' (e.g., relative/absolute) or the effects of different validation levels, leaving some ambiguity.

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 verb 'List' and resource 'all sections in the document', making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_section' or 'analyze_document', which would require a more detailed comparison.

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 like 'get_section' (for a single section) or 'analyze_document' (for broader analysis). It lacks context about prerequisites, such as whether the document must be loaded first, or exclusions for when not to use it.

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/quantalogic/quantalogic_markdown_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server