MCP server that compresses OCR-heavy PDFs into dense packed images for AI agent workflows.
Project description
Optical Context MCP
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.
What It Does
- reads a local PDF from the MCP host machine
- extracts page markdown and embedded images with Mistral OCR
- packs that content into dense PNGs that preserve visual grouping
- stores a manifest and temp job artifacts for follow-up retrieval
- lets an agent pull only the packed images it needs
Where It Fits
Use it for:
- operating manuals
- scanned handbooks
- product catalogs
- PDF slide decks
- visually structured OCR-heavy documents
Skip it for:
- tiny PDFs
- clean text-native PDFs where normal extraction is enough
- workflows that require exact page-faithful rendering
- cases where OCR cost is not justified
Example Result
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:
- source paper pages: 22
- previewed source page range: 15 to 21
- extracted images: 30
- packed output images: 6
- example packed image size:
986x1084 - example packed image file size:
536,697 bytes
This 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.
Install
python -m pip install optical-context-mcp
Run without installing:
uvx optical-context-mcp
MISTRAL_API_KEYis required forcompress_pdf- packed images are always stored locally under the system temp directory
compress_pdfreturns up to30packed images inline by default
For pinned shared setups:
uvx --from optical-context-mcp==0.1.4 optical-context-mcp
Run
Default transport is stdio:
optical-context-mcp
Claude Code
Register the server in a project:
claude mcp add -s project optical-context -- uvx optical-context-mcp
Typical use:
- call
compress_pdf - inspect the returned manifest
- fetch packed images with
get_packed_images
MCP Tools
compress_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 job
How It Works
flowchart 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"]
Why Packed Images Instead Of Just OCR Text
- section grouping
- table-like layout
- captions near figures
- visual adjacency between text and embedded graphics
For many vision-capable agents, that is a better intermediate format than a plain OCR dump.
Current Scope
- depends on Mistral OCR
- currently handles local file paths, not remote uploads
- stores artifacts in the local system temp directory by default
- optimized for compression and retrieval, not final polished markdown generation
- quality depends on OCR quality and the visual density of the source document
Roadmap
- make the OCR layer provider-agnostic so different OCR backends can be swapped behind the same MCP workflow
Development
uv venv --python /opt/homebrew/bin/python3.11 .venv
uv pip install --python .venv/bin/python -e ".[dev]"
.venv/bin/python -m pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optical_context_mcp-0.1.4.tar.gz.
File metadata
- Download URL: optical_context_mcp-0.1.4.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61ba368ffeb7caddfad9c6b6e2194dddfe62567c02eb9888fe304eba8cc78aec
|
|
| MD5 |
2d2432e30df5b828325f6c13bfe8f049
|
|
| BLAKE2b-256 |
4537113e544aacbbd15fff137a1afd38e8d0a752844c998fc5194497caf834ba
|
Provenance
The following attestation bundles were made for optical_context_mcp-0.1.4.tar.gz:
Publisher:
publish-pypi.yml on ChrBoebel/optical-context-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
optical_context_mcp-0.1.4.tar.gz -
Subject digest:
61ba368ffeb7caddfad9c6b6e2194dddfe62567c02eb9888fe304eba8cc78aec - Sigstore transparency entry: 1058657869
- Sigstore integration time:
-
Permalink:
ChrBoebel/optical-context-mcp@54ce9a0d2c1de49f38d65ca29633a4178d5097d7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ChrBoebel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@54ce9a0d2c1de49f38d65ca29633a4178d5097d7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file optical_context_mcp-0.1.4-py3-none-any.whl.
File metadata
- Download URL: optical_context_mcp-0.1.4-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11e708fd44bca1dc19c031f5ca54fdefc781462e63f3de3de3cbc20b5f88a4f6
|
|
| MD5 |
b8bf42b79fb189c2709f931c8b72613f
|
|
| BLAKE2b-256 |
be21435ee942ceb19b1dc3177b2fd015d446d34f19c77d65c7f6158751aed62a
|
Provenance
The following attestation bundles were made for optical_context_mcp-0.1.4-py3-none-any.whl:
Publisher:
publish-pypi.yml on ChrBoebel/optical-context-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
optical_context_mcp-0.1.4-py3-none-any.whl -
Subject digest:
11e708fd44bca1dc19c031f5ca54fdefc781462e63f3de3de3cbc20b5f88a4f6 - Sigstore transparency entry: 1058657884
- Sigstore integration time:
-
Permalink:
ChrBoebel/optical-context-mcp@54ce9a0d2c1de49f38d65ca29633a4178d5097d7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ChrBoebel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@54ce9a0d2c1de49f38d65ca29633a4178d5097d7 -
Trigger Event:
workflow_dispatch
-
Statement type: