doc2md
This server turns documents (PDF, DOCX, PPTX, XLSX, EPUB, HTML, CSV/JSON/XML, images/scans) into clean Markdown or structured data, and provides utilities for inspecting, searching, splitting, merging, and extracting content from PDFs.
Convert PDFs to Markdown with headings, tables, lists, and pagination (
offset/max_chars, page selection).Convert many formats in one call (DOCX, PPTX, XLSX, EPUB, HTML, CSV, PDF, etc.), including OCR fallback for scanned PDFs and images.
Extract PDF tables as Markdown, CSV, or JSON with page numbers and dimensions.
Read plain text from specific PDF pages cheaply.
Get document info: format, page count, metadata, table of contents, scanned/encrypted flags.
Full-text search PDFs with page numbers and snippets.
OCR scanned PDFs and images (PNG/JPEG/WebP/BMP/TIFF), up to 30 pages per call.
Split PDFs into parts by page ranges and return base64 parts.
Merge 2–10 PDFs (URLs or base64) into one PDF.
Extract embedded PDF images with metadata, optionally as base64.
Accept input via public URL or base64 content, with SSRF protection, size caps, and no persistence.
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 filesTables survive — PDF tables are extracted as Markdown/CSV/JSON, not flattened into noise
Pagination built in — large documents return in chunks with a
offsetcontinuation hint, so context windows stay healthyScanned? No problem — automatic detection, with a dedicated OCR tool (RapidOCR, offline, no cloud OCR API)
Cheap inspection first —
get_document_infoandsearch_documentlet agents find the right pages before converting anythingSafe 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 |
| PDF → Markdown with headings, tables, lists and reading order preserved. |
| 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. |
| Structural table extraction → |
| Plain text of specific pages — the cheapest way to read a known location. |
| Format, page count, metadata, table of contents, scanned/encrypted flags. |
| Full-text keyword search with page numbers + snippets. |
| OCR for scanned PDFs and images (PNG/JPEG/WebP/BMP/TIFF), up to 30 pages per call. |
| Cut a PDF into parts by page range ( |
| Merge 2–10 PDFs (URLs or base64) into one document, returned as base64 (≤10 MB). |
| 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 doc2mdFrom 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 suiteExample 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 pagesLimits
Limit | Value |
Download / base64 size | 30 MB |
Default response size | 40,000 chars (max 200,000), with |
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) orstreamable-http/ssewithDOC2MD_HOST/DOC2MD_PORT. Glama hosting wraps stdio automatically.OCR is optional: install the
ocrextra (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 testsLayout: 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_pdfsutility tools (v0.2.0)Image extraction via
extract_pdf_imageswith base64 export (v0.2.0)PyPI release:
doc2md-mcp(v0.2.0)Batch/webhook conversion jobs for very large documents
Available Tools
10 toolsconvert_document_to_markdownARead-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_markdownARead-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_imagesARead-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_tablesARead-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_infoARead-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_pdfsARead-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_documentARead-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_pagesARead-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_documentARead-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_pdfARead-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
Scored across 10 tools
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).
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.
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.
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
Related MCP Connectors
Convert PDF, DOCX, XLSX and 25 other formats to clean Markdown for LLMs and RAG. No key or account.
Convert PDF, Word, Excel and scanned documents to Markdown, tables and RAG chunks. OCR.
PDF, DOCX and image URLs to clean, LLM-ready Markdown or text, with OCR for scanned pages.
Any URL to clean markdown/JSON; PDF, XLSX, CSV, DOCX to text and tables. Free tier for agents.
Related MCP Servers
- AlicenseAqualityBmaintenanceConverts PDF, DOCX, PPTX, XLSX, CSV, and JSON into clean, compact, AI-ready Markdown, reducing tokens up to 65%.1454 npmMIT
- AlicenseNot gradedqualityCmaintenanceConverts documents (PDF, DOCX, XLSX, EPUB, etc.) to clean, structured Markdown, and retrieves document info, for use with AI agents.MIT
- FlicenseNot gradedqualityDmaintenanceConvert PDFs, Word documents, Excel/CSV files, and YouTube videos into clean, structured Markdown for AI agents, LLMs, and knowledge tools.1-
- AlicenseAqualityBmaintenanceTurns 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.2MIT