all2md.mcp.config
Configuration management for MCP server.
This module handles configuration from environment variables and CLI arguments, with CLI arguments taking precedence over environment variables.
All configuration is set at server startup and cannot be changed per-tool-call for security reasons.
Classes
MCPConfig: Server configuration with security settings
- class all2md.mcp.config.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
- all2md.mcp.config.load_config_from_env() MCPConfig
Load configuration from environment variables.
- Returns:
Configuration loaded from environment
- Return type:
- all2md.mcp.config.create_argument_parser() ArgumentParser
Create argument parser for MCP server CLI.
- Returns:
Configured argument parser
- Return type:
argparse.ArgumentParser