all2md.mcp
MCP server for all2md document conversion.
This package provides a Model Context Protocol (MCP) server that exposes all2md’s document conversion functionality to LLMs like Claude.
The server runs over stdio transport and provides three main tools: - read_document_as_markdown: Convert a document to Markdown - save_document_from_markdown: Render Markdown to another format and save it - edit_document: Apply structured edits to a document
Security features include: - Path allowlists for read/write operations - Server-level attachment mode configuration - Network access control - Symlink resolution and path traversal prevention
Usage
- Run the server from command line:
$ all2md-mcp
- With configuration:
$ all2md-mcp –read-dirs “/home/user/docs” –write-dirs “/home/user/output”
- Or use environment variables:
$ export ALL2MD_MCP_ALLOWED_READ_DIRS=”/home/user/docs” $ export ALL2MD_MCP_ALLOWED_WRITE_DIRS=”/home/user/output” $ all2md-mcp
- all2md.mcp.main() int
Run all2md-mcp server.
- class all2md.mcp.MCPConfig
Bases:
CloneFrozenMixinMCP server configuration.
All settings are immutable after server startup for security.
- Variables:
enable_to_md (bool) – Whether to enable read_document_as_markdown tool (default: True)
enable_from_md (bool) – Whether to enable save_document_from_markdown tool (default: False for security)
enable_doc_edit (bool) – Whether to enable edit_document tool (default: False for security)
enable_search (bool) – Whether to enable search_documents tool (default: True; read-only)
enable_diff (bool) – Whether to enable diff_documents tool (default: True; read-only)
enable_outline (bool) – Whether to enable get_document_outline tool (default: True; read-only)
enable_list_files (bool) – Whether to enable list_workspace_files tool (default: True; read-only)
search_index_dir (str | Path | None) – Optional directory for persisting/loading the search keyword index. None (default) rebuilds a fresh in-memory index on every call. When set, the keyword index is saved there and reused on subsequent calls. The directory is validated against the write allowlist at startup.
read_allowlist (list[str | Path] | None) – List of allowed read directory paths. Initially strings from env/CLI, then converted to resolved Path objects by prepare_allowlist_dirs.
write_allowlist (list[str | Path] | None) – List of allowed write directory paths. Initially strings from env/CLI, then converted to resolved Path objects by prepare_allowlist_dirs.
include_images (bool) – Whether to include images in the output for vLLM visibility. - True: Images embedded as base64 (vLLMs can see them) - False: Images replaced with alt text only Default: False (opt-in for vision-enabled LLMs). Note: With disable_network=True (default), only works for embedded images (PDF, DOCX, PPTX), not for external HTML images that require fetching.
flavor (str) – Markdown flavor/dialect to use (gfm, commonmark, multimarkdown, pandoc, kramdown, markdown_plus). Default: “gfm” (GitHub Flavored Markdown)
disable_network (bool) – Whether to disable network access globally. When True (default), prevents fetching external images from HTML files, but embedded images in PDF/DOCX/PPTX will still work with base64 mode.
log_level (str) – Logging level (DEBUG|INFO|WARNING|ERROR)
- enable_to_md: bool = True
- enable_from_md: bool = False
- enable_doc_edit: bool = False
- enable_search: bool = True
- enable_diff: bool = True
- enable_outline: bool = True
- enable_list_files: bool = True
- search_index_dir: str | Path | None = None
- read_allowlist: list[str | Path] | None = None
- write_allowlist: list[str | Path] | None = None
- include_images: bool = False
- flavor: str = 'gfm'
- disable_network: bool = True
- log_level: str = 'INFO'
- validate() None
Validate configuration consistency.
- Raises:
ValueError – If configuration is invalid
- __init__(enable_to_md: bool = True, enable_from_md: bool = False, enable_doc_edit: bool = False, enable_search: bool = True, enable_diff: bool = True, enable_outline: bool = True, enable_list_files: bool = True, search_index_dir: str | Path | None = None, read_allowlist: list[str | Path] | None = None, write_allowlist: list[str | Path] | None = None, include_images: bool = False, flavor: str = 'gfm', disable_network: bool = True, log_level: str = 'INFO') None
- exception all2md.mcp.MCPSecurityError
Bases:
All2MdErrorRaised when MCP security validation fails.
Initialize MCP security error.
- Parameters:
message (str) – Error message
path (str | None) – Path that failed validation
- __init__(message: str, path: str | None = None) None
Initialize MCP security error.
- Parameters:
message (str) – Error message
path (str | None) – Path that failed validation
For MCP module documentation, see Advanced Modules and the user guide at MCP Server.