Class MarkdownTools

java.lang.Object
com.tnsai.tools.file.MarkdownTools

public class MarkdownTools extends Object
Function-shape Markdown conversion tool — the LangChain-style replacement for the legacy MarkItDownTool (see issue #188 — RFC).

Wraps the Microsoft MarkItDown Python CLI as an external subprocess. The CLI converts a wide range of file formats (PDF, Word, Excel, PowerPoint, HTML, images, audio, EPUB, CSV, JSON, XML, ZIP, …) plus URLs to a single markdown string.

Requires

pip install markitdown

The tool reports a clear "markitdown CLI not found" error when the binary is absent on PATH, so tool registration succeeds at startup (markitdown is loaded reflectively per #186) and only the actual call fails when invoked.

Since:
0.5.7 (Phase 2 batch 3 — built-in tool migration to function shape, see #188)
  • Field Details

    • DEFAULT_EXTENSIONS

      public static final Set<String> DEFAULT_EXTENSIONS
      Default whitelist mirrors the formats markitdown advertises support for. URLs are admitted separately by isUrl(String).
  • Constructor Details

    • MarkdownTools

      public MarkdownTools()
    • MarkdownTools

      public MarkdownTools(FileGuardConfig guardConfig)
  • Method Details

    • markitdown

      @Tool(name="markitdown", description="Convert a file or URL to Markdown using the MarkItDown Python CLI. Supported sources: PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), HTML, images (with OCR), audio (with transcription), EPUB, CSV, JSON, XML, ZIP archives, and HTTP(S) URLs. Returns the converted markdown as a single string.", keywords={"markdown","convert","markitdown","pdf","docx","xlsx","pptx","html","ocr"}, idempotent=true) public String markitdown(@ToolParam(description="Absolute file path or HTTP(S) URL of the source to convert") String source) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException