loading…
Search for a command to run...
loading…
Compress OCR-heavy PDFs into dense packed images so agents can work with long visual documents.
Compress OCR-heavy PDFs into dense packed images so agents can work with long visual documents.
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-mcp
Install with the adaptive sizing runtime:
python -m pip install "optical-context-mcp[ml]"
Run without installing:
uvx optical-context-mcp
MISTRAL_API_KEY is required for compress_pdfcompress_pdf returns up to 30 packed images inline by defaulttorch and torchvision are availableOPTICAL_CONTEXT_DISABLE_ADAPTIVE_SIZING=1 to force the legacy fixed sizingOPTICAL_CONTEXT_ADAPTIVE_MODEL_PATH=/path/to/model.pt to override the bundled checkpointFor pinned shared setups:
uvx --from optical-context-mcp==0.1.4 optical-context-mcp
Default transport is stdio:
optical-context-mcp
Register the server in a project:
claude mcp add -s project optical-context -- uvx optical-context-mcp
Typical 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
Run in your terminal:
claude mcp add optical-context-mcp -- npx Security
Low riskAutomated heuristic from public metadata — not a security guarantee.