Skip to main content
Glama

get_document

Retrieve and validate Markdown document content and structure from a specified file path to enable editing operations.

Instructions

        Get the complete document content and structure.
        
        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

  • Primary handler for the 'get_document' tool, decorated with @mcp.tool() for registration. Loads document content and structure using StatelessMarkdownProcessor and returns full markdown content, section list, and metadata.
    @self.mcp.tool()
    def get_document(document_path: str, validation_level: str = "NORMAL") -> Dict[str, Any]:
        """
        Get the complete document content and structure.
        
        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()
            content = editor.to_markdown()
            
            return {
                "success": True,
                "document_path": document_path,
                "content": content,
                "sections": [
                    {
                        "id": section.id,
                        "title": section.title,
                        "level": section.level,
                        "line_start": section.line_start,
                        "line_end": section.line_end
                    }
                    for section in sections
                ],
                "metadata": {
                    "total_sections": len(sections),
                    "total_lines": len(content.split('\n')),
                    "file_size": len(content),
                    "validation_level": validation_level
                }
            }
            
        except Exception as e:
            return self.processor.create_error_response(str(e), type(e).__name__)
  • Internal helper implementation for 'get_document' used in synchronous tool calls via call_tool_sync. Similar logic to main handler but wrapped in execute_operation.
    def _get_document_impl(self, document_path: str) -> Dict[str, Any]:
        """Implementation for get_document tool."""
        def operation(editor):
            from .safe_editor_types import EditResult, EditOperation
            
            content = editor.to_markdown()
            sections = editor.get_sections()
            
            document_data = {
                "content": content,
                "sections": [
                    {
                        "id": section.id,
                        "title": section.title,
                        "level": section.level,
                        "start_line": section.line_start,
                        "end_line": section.line_end
                    }
                    for section in sections
                ],
                "word_count": len(content.split()),
                "character_count": len(content)
            }
            
            return EditResult(
                success=True,
                operation=EditOperation.BATCH_OPERATIONS,
                modified_sections=[],
                errors=[],
                warnings=[],
                metadata=document_data
            )
        
        return self.processor.execute_operation(document_path, operation, auto_save=False)
  • Alternative handler for 'get_document' in the enhanced MCP server subclass, providing document content and statistics.
    @self.mcp.tool()
    def get_document(document_path: str, validation_level: str = "NORMAL") -> Dict[str, Any]:
        """Get the complete document (stateless only)."""
        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)
            content = editor.to_markdown()
            statistics = editor.get_statistics()
            return {
                "success": True,
                "document": content,
                "statistics": {
                    "total_sections": statistics.total_sections,
                    "total_lines": statistics.total_lines,
                    "word_count": statistics.word_count,
                    "character_count": statistics.character_count
                },
                "document_path": document_path,
                "stateless": True
            }
        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 'complete document content and structure' and validation levels, but lacks details on permissions, rate limits, error handling, or what 'complete' entails (e.g., metadata, formatting). This leaves significant gaps in understanding the tool's behavior.

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 appropriately sized and front-loaded, with the core purpose stated first in a clear sentence, followed by parameter details in a structured format. Every sentence earns its place without redundancy or fluff, making it highly efficient for quick comprehension.

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, but with an output schema), the description is minimally adequate. It covers the basic purpose and parameters but lacks behavioral context and usage guidelines. The presence of an output schema means return values needn't be explained, but overall completeness is limited.

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 adds meaning by explaining 'document_path' as 'Path to the Markdown file' and 'validation_level' with its allowed values and default, which clarifies beyond the bare schema. However, it doesn't detail path format or validation effects, preventing a perfect score.

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 the verb 'Get' and resource 'complete document content and structure', making it specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_section' or 'load_document', which limits its score to 4 rather than 5.

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 such as 'get_section' for partial content or 'load_document' which might have different semantics. Without any context or exclusions, the agent must infer usage from the name alone, which is insufficient for optimal tool selection.

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