Skip to main content
Glama

load_document

Load and validate a Markdown document from a specified file path, with customizable validation strictness levels for accuracy and compliance.

Instructions

Load and analyze a Markdown document from a file path. Args: document_path: Path to the Markdown file (supports absolute, relative, and ~ expansion) validation_level: Validation strictness - "STRICT", "NORMAL", or "PERMISSIVE"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_pathYes
validation_levelNoNORMAL

Implementation Reference

  • Primary MCP tool handler and registration for 'load_document'. Loads document via stateless processor, analyzes sections, and returns success response with preview and stats.
    @self.mcp.tool() def load_document(document_path: str, validation_level: str = "NORMAL") -> Dict[str, Any]: """Load a Markdown document from a file path (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) sections = editor.get_sections() content_preview = editor.to_markdown()[:200] + "..." if len(editor.to_markdown()) > 200 else editor.to_markdown() return { "success": True, "message": f"Successfully analyzed document at {document_path}", "document_path": document_path, "sections_count": len(sections), "content_preview": content_preview, "file_size": len(editor.to_markdown()), "stateless": True } except Exception as e: return self.processor.create_error_response(str(e), type(e).__name__)
  • Core helper method that resolves path, validates file, reads content with encoding fallback, and creates SafeMarkdownEditor instance.
    def load_document(document_path: str, validation_level: ValidationLevel = ValidationLevel.NORMAL) -> SafeMarkdownEditor: """Load a document and create a SafeMarkdownEditor instance.""" resolved_path = StatelessMarkdownProcessor.resolve_path(document_path) StatelessMarkdownProcessor.validate_file_path(resolved_path, must_exist=True, must_be_file=True) # Read the file content try: content = resolved_path.read_text(encoding='utf-8') except UnicodeDecodeError: # Try with different encodings for encoding in ['utf-8-sig', 'latin1', 'cp1252']: try: content = resolved_path.read_text(encoding=encoding) break except UnicodeDecodeError: continue else: raise ValueError(f"Could not decode file {resolved_path} with any supported encoding") # Create editor instance editor = SafeMarkdownEditor( markdown_text=content, validation_level=validation_level ) return editor
  • Base MCP tool handler for 'load_document' in the parent class, similar logic to enhanced version.
    @self.mcp.tool() def load_document(document_path: str, validation_level: str = "NORMAL") -> Dict[str, Any]: """ Load and analyze a Markdown document from a file path. Args: document_path: Path to the Markdown file (supports absolute, relative, and ~ expansion) validation_level: Validation strictness - "STRICT", "NORMAL", or "PERMISSIVE" """ try: # Convert string validation level to enum validation_map = { "STRICT": ValidationLevel.STRICT, "NORMAL": ValidationLevel.NORMAL, "PERMISSIVE": ValidationLevel.PERMISSIVE } validation_enum = validation_map.get(validation_level.upper(), ValidationLevel.NORMAL) # Load document without server state editor = self.processor.load_document(document_path, validation_enum) sections = editor.get_sections() content_preview = editor.to_markdown()[:200] + "..." if len(editor.to_markdown()) > 200 else editor.to_markdown() return { "success": True, "message": f"Successfully analyzed document at {document_path}", "document_path": document_path, "sections_count": len(sections), "content_preview": content_preview, "file_size": len(editor.to_markdown()), "stateless": True } except Exception as e: return self.processor.create_error_response(str(e), type(e).__name__)

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

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