Compress OCR-heavy PDFs into dense packed images so agents can work with long visual documents.
Optical Context MCP is built for one specific job: turning large, visually structured PDFs into a smaller set of retrievable packed images for agent workflows.
It reads a local PDF, runs OCR with Mistral, recomposes the extracted text and figures into dense PNGs, and exposes those artifacts over MCP for batch retrieval.
Use it for:
Skip it for:
The image below shows a real local validation run on a public research paper with dense text, figures, charts, and page-level visual structure. The packed image on the right consolidates the seven source pages shown on the left.
Example local run facts from the generated manifest:
986x1084536,697 bytesThis example shows the intended workflow: take a long, visually structured PDF and compress it into a smaller set of retrievable packed images that still preserve the visual structure of the source.
python -m pip install optical-context-mcpRun without installing:
uvx optical-context-mcpMISTRAL_API_KEY is required for compress_pdfcompress_pdf returns up to 30 packed images inline by defaultFor pinned shared setups:
uvx --from optical-context-mcp==0.1.4 optical-context-mcpDefault transport is stdio:
optical-context-mcpRegister the server in a project:
claude mcp add -s project optical-context -- uvx optical-context-mcpTypical use:
compress_pdfget_packed_imagescompress_pdf: run OCR plus recomposition and create a stored jobget_job_manifest: load metadata for an existing jobget_packed_images: fetch one or more packed PNGs from an existing jobflowchart LR
A["Local PDF"] --> B["Mistral OCR"]
B --> C["Page markdown + embedded images"]
C --> D["Recomposition engine"]
D --> E["Dense packed PNG images"]
E --> F["Stored job artifacts"]
F --> G["Agent fetches manifest or image batches over MCP"]For many vision-capable agents, that is a better intermediate format than a plain OCR dump.
uv venv --python /opt/homebrew/bin/python3.11 .venv
uv pip install --python .venv/bin/python -e ".[dev]"
.venv/bin/python -m pytest