Skip to main content
Glama

doc2md

Turn any document into clean Markdown — built for AI agents.

doc2md is an MCP server that converts PDF, DOCX, PPTX, XLSX, EPUB, HTML, CSV/JSON/XML and scanned files (OCR) into agent-ready Markdown. Pass a public URL or base64 content; no API key, no account, no local dependencies for the agent side.

Most document-conversion MCP servers only run locally over stdio. doc2md is designed to be deployed remotely (Streamable HTTP) so any agent — Claude, ChatGPT, Cursor, Glama Chat, your own pipelines — can hand it a URL and get Markdown back in one call.

Why agents love it

  • URL-first — {"url": "https://…/report.pdf"} is all it takes; base64 supported for local files

  • Tables survive — PDF tables are extracted as Markdown/CSV/JSON, not flattened into noise

  • Pagination built in — large documents return in chunks with a offset continuation hint, so context windows stay healthy

  • Scanned? No problem — automatic detection, with a dedicated OCR tool (RapidOCR, offline, no cloud OCR API)

  • Cheap inspection first — get_document_info and search_document let agents find the right pages before converting anything

  • Safe to expose — SSRF protection (private/loopback/link-local IPs rejected on every redirect hop), 30 MB download cap, password-PDF support

Related MCP server: groupdocs-markdown-mcp

Tools

Tool

What it does

convert_pdf_to_markdown

PDF → Markdown with headings, tables, lists and reading order preserved. pages selection + offset/max_chars pagination.

convert_document_to_markdown

Universal one-call converter: auto-detects DOCX/PPTX/XLSX/EPUB/HTML/CSV/PDF and returns Markdown. Falls back to OCR for scanned PDFs and images.

extract_pdf_tables

Structural table extraction → markdown, csv or json rows, with page numbers and dimensions.

read_pdf_pages

Plain text of specific pages — the cheapest way to read a known location.

get_document_info

Format, page count, metadata, table of contents, scanned/encrypted flags.

search_document

Full-text keyword search with page numbers + snippets.

ocr_document

OCR for scanned PDFs and images (PNG/JPEG/WebP/BMP/TIFF), up to 30 pages per call.

split_pdf

Cut a PDF into parts by page range ('1-3,5,8-10'); each part returned as base64 (≤5 MB).

merge_pdfs

Merge 2–10 PDFs (URLs or base64) into one document, returned as base64 (≤10 MB).

extract_pdf_images

List/export embedded images (figures, charts, scans) with page, dimensions, format; optional base64 (≤2 MB each).

Plus a summarize_document prompt template for clients that surface MCP prompts.

Quickstart

Hosted (zero install)

One-click deploy your own instance from the doc2md page on Glama ("Deploy Server"), or run the Docker image below, then point any MCP client at the Streamable HTTP endpoint:

{
  "mcpServers": {
    "doc2md": {
      "type": "streamable-http",
      "url": "https://glama.ai/endpoints/<your-profile>/mcp"
    }
  }
}

Claude Desktop / Cursor (local)

{
  "mcpServers": {
    "doc2md": {
      "command": "uvx",
      "args": ["--from", "doc2md-mcp[ocr]", "doc2md"]
    }
  }
}

Docker

docker run --rm -i ghcr.io/skyzhao1223/doc2md                    # stdio
docker run --rm -p 8000:8000 \
  -e DOC2MD_TRANSPORT=streamable-http ghcr.io/skyzhao1223/doc2md # HTTP endpoint

# or build from source
docker build -t doc2md . && docker run --rm -i doc2md

From source

pip install "doc2md-mcp[ocr]"   # or: uvx --from "doc2md-mcp[ocr]" doc2md
doc2md                          # stdio server

# or from source
git clone https://github.com/skyzhao1223/doc2md && cd doc2md
uv sync --extra ocr --extra dev
uv run doc2md          # stdio server
uv run pytest          # test suite

Example session

agent → get_document_info {"url": "https://arxiv.org/pdf/1706.03762"}
      ← {kind: "pdf", page_count: 15, is_scanned: false, toc: [...]}

agent → search_document {"url": "...", "query": "BLEU"}
      ← matches on pages 8, 9, 10 with snippets

agent → read_pdf_pages {"url": "...", "pages": "8-9"}
      ← plain text of exactly those pages

Limits

Limit

Value

Download / base64 size

30 MB

Default response size

40,000 chars (max 200,000), with offset continuation

OCR pages per call

30 (renders at 200 dpi)

Table scan depth

first 100 pages per call, 50 tables max

Split

≤20 parts per call, base64 included for parts ≤5 MB

Merge

≤10 inputs, merged output ≤10 MB

Image export

≤50 images per call, base64 for images ≤2 MB

URL fetch

public http(s) only, ≤5 redirects, SSRF-filtered

Self-hosting notes

  • Transport: DOC2MD_TRANSPORT=stdio (default) or streamable-http / sse with DOC2MD_HOST / DOC2MD_PORT. Glama hosting wraps stdio automatically.

  • OCR is optional: install the ocr extra (or use the Docker image, which includes it). Without OCR, all other tools still work and OCR calls return an actionable error.

  • Conversion results are cached in memory (content-hash keyed, 30 min TTL) so paginated reads of the same document don't re-convert. Nothing is written to disk persistently; documents are processed in memory and dropped.

Development

uv sync --extra dev --extra ocr
uv run pytest            # 40+ tests: detection, conversion, tables, split/merge, SSRF, in-process MCP smoke tests

Layout: src/doc2md/{server,convert,tables,pdfops,ocr,fetch,detect,cache}.py.

Security

  • SSRF protection: every URL (including each redirect hop) must resolve to public unicast IPs only; file:, ftp: and other schemes are rejected.

  • Size caps on downloads, base64 payloads and OCR page counts.

  • No persistence: documents live in memory for the duration of a call.

  • Runs as a non-root user in the official Docker image.

License

AGPL-3.0-or-later — see LICENSE. The AGPL choice is driven by PyMuPDF (used via PyMuPDF4LLM for high-quality PDF → Markdown), which is AGPL itself. If you operate a modified version of this server over a network, you must offer your users its source.

Roadmap

  • Formula / LaTeX extraction quality pass

  • split_pdf, merge_pdfs utility tools (v0.2.0)

  • Image extraction via extract_pdf_images with base64 export (v0.2.0)

  • PyPI release: doc2md-mcp (v0.2.0)

  • Batch/webhook conversion jobs for very large documents

Available Tools

10 tools
convert_document_to_markdownA
Read-onlyIdempotent

Convert almost any document to Markdown in one call: DOCX, PPTX, XLSX, EPUB, HTML, CSV/JSON/XML/TXT and PDF are auto-detected from the URL or base64 content. This is the universal 'just give me the text' tool — use it when the file format is unknown or mixed.

Images and scanned PDFs are routed to OCR automatically when the server
has OCR installed. Legacy .doc/.xls/.ppt binaries are not supported.

Inputs: url, pages, offset, filename, +3 more. Returns: result

convert_pdf_to_markdownA
Read-onlyIdempotent

Convert a PDF document to clean Markdown, preserving headings, tables, lists and reading order. Use this whenever an agent needs to read a PDF: reports, papers, invoices, manuals, slide exports. Accepts a public URL or base64 content; no API key needed.

For large PDFs, convert selected pages ('pages': '1,3-5') or page through
the output with 'offset'/'max_chars'. Scanned PDFs are rejected with a
hint to use ocr_document instead.

Inputs: url, pages, offset, filename, +3 more. Returns: result

extract_pdf_imagesA
Read-onlyIdempotent

List and optionally export the images embedded in a PDF — figures, charts, logos and scanned page bitmaps — with page number, pixel dimensions, format and size. Set include_base64=true to get the actual image data (each up to 2 MB) for saving or further processing. Duplicate images are reported once.

Inputs: url, pages, filename, password, +3 more.

extract_pdf_tablesA
Read-onlyIdempotent

Extract data tables from a PDF with structure preserved — returns each table's page number, dimensions and content as Markdown, CSV or JSON rows. Ideal for financial statements, spec sheets, price lists and any document where tables matter more than prose. Scans up to 100 pages per call.

Inputs: url, pages, format, filename, +3 more.

get_document_infoA
Read-onlyIdempotent

Inspect a document before converting it: detected format, page count, title/author metadata, table of contents (PDF), whether the file is scanned (needs OCR) or encrypted. Call this first for unknown or large documents to plan which pages to convert.

Inputs: url, filename, password, file_base64.

merge_pdfsA
Read-onlyIdempotent

Merge multiple PDFs, in the given order, into a single PDF document. Accepts either public URLs or base64-encoded files (exactly one of the two). Returns the merged file as base64 (up to 10 MB) plus per-input page counts. Useful for re-assembling split reports, combining invoices or building one attachment from several exports.

Inputs: urls, files_base64.

ocr_documentA
Read-onlyIdempotent

OCR a scanned PDF or image (PNG/JPEG/WebP/BMP/TIFF) and return the recognised text per page. Use this when a PDF has no embedded text layer (convert_pdf_to_markdown will tell you) or when extracting text from screenshots, photos of documents, receipts and forms. Limited to 30 pages per call — narrow with 'pages'.

Inputs: url, pages, filename, password, +1 more.

read_pdf_pagesA
Read-onlyIdempotent

Read the plain text of specific PDF pages — the cheapest way to inspect a known location in a large PDF (e.g. after finding page numbers with search_document or get_document_info). Returns text per page without Markdown table reconstruction. 'pages' is required.

Inputs: url, pages, filename, password, +1 more. Returns: result

search_documentA
Read-onlyIdempotent

Full-text keyword search inside a PDF: returns every match with its page number and a surrounding text snippet. Use it to locate information in large PDFs (manuals, contracts, filings) before reading the exact pages with read_pdf_pages — much cheaper than converting the whole file.

Inputs: url, query, filename, password, +2 more.

split_pdfA
Read-onlyIdempotent

Split a PDF into multiple PDF documents by page range. Each part comes back with its page count, size and base64 content (parts up to 5 MB), ready to be fed into other doc2md tools or written to a file. Use it to break a large report into chapters, isolate an appendix, or prepare page-limited uploads.

Inputs: url, ranges, filename, password, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool targets a distinct operation: merging, converting, table extraction, page reading, info retrieval, search, OCR, splitting, and image extraction. Even the two conversion tools are clearly differentiated by scope (PDF-specific vs. universal document conversion).

    Naming Consistency4/5

    Most tools follow a clear verb-first pattern (merge, convert, extract, read, get, search, split). Minor inconsistency exists between 'ocr_document' (acronym as verb) and the inconsistent use of 'pdf' vs 'document' in object names, but the pattern remains predictable.

    Tool Count5/5

    Ten tools is well-scoped for a document conversion server, covering all major workflow stages without redundancy or bloat. Each tool has a clear purpose and none feel superfluous.

    Completeness5/5

    The tool set covers the full document handling lifecycle: inspection, conversion, OCR, search, table/image extraction, splitting, and merging. There are no obvious missing operations for the stated doc2md purpose.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Converts documents (PDF, DOCX, XLSX, EPUB, etc.) to clean, structured Markdown, and retrieves document info, for use with AI agents.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Convert PDFs, Word documents, Excel/CSV files, and YouTube videos into clean, structured Markdown for AI agents, LLMs, and knowledge tools.
      1
      -
    • A
      license
      A
      quality
      B
      maintenance
      Turns any URL into clean markdown/JSON and converts PDF, XLSX, CSV, DOCX into text and tables. Free tier of 100 calls/day, then pay-per-call credits.
      2
      MIT