mirror of
https://github.com/microsoft/markitdown.git
synced 2025-06-26 22:00:21 +00:00
Have the MarkItDown MCP server read MARKITDOWN_ENABLE_PLUGINS from ENV (#1273)
* Have the MarkItdown MCP server read MARKITDOWN_ENABLE_PLUGINS from os.environ * Update the Dockerfile to enable plugins. No puglins are installed by default.
This commit is contained in:
parent
62b72284fe
commit
3bfb821c09
@ -3,8 +3,10 @@ FROM python:3.13-slim-bullseye
|
|||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
ENV EXIFTOOL_PATH=/usr/bin/exiftool
|
ENV EXIFTOOL_PATH=/usr/bin/exiftool
|
||||||
ENV FFMPEG_PATH=/usr/bin/ffmpeg
|
ENV FFMPEG_PATH=/usr/bin/ffmpeg
|
||||||
|
ENV MARKITDOWN_ENABLE_PLUGINS=True
|
||||||
|
|
||||||
# Runtime dependency
|
# Runtime dependency
|
||||||
|
# NOTE: Add any additional MarkItDown plugins here
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
exiftool
|
exiftool
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
from collections.abc import AsyncIterator
|
from collections.abc import AsyncIterator
|
||||||
from mcp.server.fastmcp import FastMCP
|
from mcp.server.fastmcp import FastMCP
|
||||||
from starlette.applications import Starlette
|
from starlette.applications import Starlette
|
||||||
@ -19,7 +20,15 @@ mcp = FastMCP("markitdown")
|
|||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def convert_to_markdown(uri: str) -> str:
|
async def convert_to_markdown(uri: str) -> str:
|
||||||
"""Convert a resource described by an http:, https:, file: or data: URI to markdown"""
|
"""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:
|
def create_starlette_app(mcp_server: Server, *, debug: bool = False) -> Starlette:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user