Python tool for converting files and office documents to Markdown.
Have the MarkItDown MCP server read MARKITDOWN_ENABLE_PLUGINS from ENV (#1273)
afourney3bfb821c0962
diff --git a/packages/markitdown-mcp/Dockerfile b/packages/markitdown-mcp/Dockerfileindex fe52a4bd..773936a1 100644--- a/packages/markitdown-mcp/Dockerfile+++ b/packages/markitdown-mcp/Dockerfile@@ -3,8 +3,10 @@ FROM python:3.13-slim-bullseyeENV DEBIAN_FRONTEND=noninteractiveENV EXIFTOOL_PATH=/usr/bin/exiftoolENV FFMPEG_PATH=/usr/bin/ffmpeg+ENV MARKITDOWN_ENABLE_PLUGINS=True# Runtime dependency+# NOTE: Add any additional MarkItDown plugins hereRUN apt-get update && apt-get install -y --no-install-recommends \ffmpeg \exiftooldiff --git a/packages/markitdown-mcp/src/markitdown_mcp/__main__.py b/packages/markitdown-mcp/src/markitdown_mcp/__main__.pyindex e2f4b164..77ade997 100644--- a/packages/markitdown-mcp/src/markitdown_mcp/__main__.py+++ b/packages/markitdown-mcp/src/markitdown_mcp/__main__.py@@ -1,5 +1,6 @@import contextlibimport sys+import osfrom collections.abc import AsyncIteratorfrom mcp.server.fastmcp import FastMCPfrom starlette.applications import Starlette@@ -19,7 +20,15 @@ mcp = FastMCP("markitdown")@mcp.tool()async def convert_to_markdown(uri: str) -> str:"""Convert a resource described by an http:, https:, file: or data: URI to markdown"""- return MarkItDown().convert_uri(uri).markdown+ return MarkItDown(enable_plugins=check_plugins_enabled()).convert_uri(uri).markdown+++def check_plugins_enabled() -> bool:+ return os.getenv("MARKITDOWN_ENABLE_PLUGINS", "false").strip().lower() in (+ "true",+ "1",+ "yes",+ )def create_starlette_app(mcp_server: Server, *, debug: bool = False) -> Starlette: