How to convert documents to Markdown for RAG with an AI agent

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Markdown MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-markdown -- dnx GroupDocs.Markdown.Mcp --yes
Folders, licensing and more →

Retrieval pipelines start with a conversion step, and that step decides how good the retrieval will be. Markdown is the format most chunkers and embedders handle best: headings survive, tables stay tables, lists stay lists.

Note
The commands and config snippets on this page are for the .NET build of the server — the only platform available today. Installation and client setup: MCP server for .NET. Other platforms will expose the same tools with their own launch command; everything else on this page applies unchanged.

The pattern

  1. Put the corpus in the storage folder the server can see.
  2. Ask: “Convert every PDF in this folder to Markdown, images as files, with front matter.”
  3. The agent calls convert_to_markdown per document.
  4. .md files (and an image folder) land in your output folder, ready to chunk.

Choose images: "file" for ingestion

The default embeds images as base64 data URIs, which makes a self-contained file — and makes a terrible RAG corpus: a single picture becomes a multi-megabyte blob sitting in the middle of a chunk, and your embedder gets a page of base64 instead of a paragraph of text.

For an index, use images: "file" (pictures written alongside, referenced by path) or skip images entirely when only the prose matters.

Turn on front matter

frontMatter: true writes YAML with title, author, format, and page count at the top of each file. That is chunk metadata you would otherwise have to reconstruct from file names — and it lets a retrieval answer cite “the Employee Handbook, page 42” instead of “handbook-final-v3.md”.

The trap that ruins ingestion runs

Evaluation mode converts only the first three pages. Nothing errors, nothing warns; you get a valid .md that contains the first three pages of a 200-page manual. Build an index from it and every retrieval quietly fails to find what it should.

Make the check the first step of any run:

Before converting anything: what is the license status of the markdown server?

get_license_status; see Licensing.

Sanity-check the corpus, not just the tool

For each converted file, tell me the source page count and the resulting Markdown length.

A 300-page manual that became 4 KB of Markdown is either a scan with no text layer or a truncated run. Both are invisible unless you look.

Setup

dnx GroupDocs.Markdown.Mcp --yes

with GROUPDOCS_MCP_STORAGE_PATH pointing at the corpus — per-client config or the installer.

Where to go next

Read more