Skip to main content

doc2images-mcp

An MCP server that renders documents to images and returns them directly as multimodal content for the model.

  • Deterministic "document -> image" conversion only;
  • Does not convert documents to Markdown and does not do LLM-based document understanding / OCR;
  • PDF rendering is handled by pypdfium2 (PDFium), a self-contained Python wheel with no external binaries. PDFium ships its own encoding data, including the CJK CMaps, so Chinese/Japanese/Korean text renders correctly.

This version supports PDF only. The DOCX / PPTX branch is reserved in the code and will be enabled once LibreOffice is wired in.

Requirements

Dependency Notes
Python >= 3.14 (see .python-version)
uv Dependency management and run entry point

No system packages are required: pypdfium2 bundles the PDFium binaries.

Install

uv tool install doc2images-mcp

Wiring it into OpenCode

Add the following to the mcp.servers section of opencode.jsonc:

"doc2images": {
  "type": "local",
  "command": [
    "uvx",
    "doc2images-mcp",
  ],
},

To cap how much image data reaches the context, you can also tighten OpenCode's image settings:

"media": {
  "image": {
    "auto_resize": true,
    "max_width": 2000,
    "max_height": 2000,
    "max_base64_bytes": 5242880,
  },
},

Tool: pdf_to_images

Renders PDF pages and returns a list of images (one per page).

Parameter Default Description
file_path — Document path. Relative paths resolve against DOC2IMG_BASE_DIR
dpi 150 Rasterization resolution, 72–300. Higher is sharper and larger
first_page 1 First page to render (1-based)
last_page 0 Last page to render; 0 means "up to max_pages"
max_pages 10 Hard cap on the number of pages (1–50) to protect the context
max_width 3000 Maximum output width; wider pages are scaled down proportionally

Environment variables

Variable Default Description
DOC2IMG_BASE_DIR Current working directory Base directory used to resolve relative paths

Testing

Sample PDFs live in data/; the tests render them through the tool:

uv run pytest -v

Rendered intermediate images are written to tmp/, which is ignored via its own .gitignore.

Roadmap

  • Office support: after installing LibreOffice, add soffice --headless --convert-to pdf for .docx/.pptx/.ppt in the dispatch function, then reuse the same rendering logic.
  • Embedded image extraction: extract only the images embedded in a document instead of whole pages.
  • Alternative backend: PyMuPDF (fitz) is a drop-in alternative if its richer text/embedded-image APIs are ever needed; the tool interface stays the same.

Metadata

Release files for doc2images-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for doc2images-mcp 0.1.0
File Size Uploaded
doc2images_mcp-0.1.0.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for doc2images-mcp 0.1.0
File Interpreter ABI Platform
doc2images_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / doc2images_mcp-0.1.0.tar.gz

Download URL doc2images_mcp-0.1.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d9d61c65e3cfdf224f4b435296fba183e019fb4cec9fcd2441a77b963341a739
BLAKE2b-256 checksum
How to use checksums
3b3b71acbf62a5d2426c62efbccc7c146bf959eba7fba3799dbdf12f76e10144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / doc2images_mcp-0.1.0-py3-none-any.whl

Download URL doc2images_mcp-0.1.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddc1bf0bd276719815a2ca6a3f5ed38e3b3eb891c2492df8d66c9688174e2f9e
BLAKE2b-256 checksum
How to use checksums
5ed953dbbc9dc34b996f0f1ccc7ad686c40527bc493671a783fdb4fe9e40f3e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page