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 two main tools: - convert_to_markdown: Convert documents to Markdown - render_from_markdown: Render Markdown to other formats

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: CloneFrozenMixin

MCP server configuration.

All settings are immutable after server startup for security.

Variables:
  • enable_to_md (bool) – Whether to enable convert_to_markdown tool (default: True)

  • enable_from_md (bool) – Whether to enable render_from_markdown tool (default: False for security)

  • enable_doc_edit (bool) – Whether to enable edit_document tool (default: False for security)

  • 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
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, 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: All2MdError

Raised 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.