Optical Context MCP
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Optical Context MCPcompress the PDF at ./documents/report.pdf"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
optionally sizes embedded figures with a bundled technical-document model
stores a manifest and temp job artifacts for follow-up retrieval
lets an agent pull only the packed images it needs
Related MCP server: TokenDiet MCP
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:
986x1084example 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-mcpInstall with the adaptive sizing runtime:
python -m pip install "optical-context-mcp[ml]"Run without installing:
uvx optical-context-mcpMISTRAL_API_KEYis required forcompress_pdfpacked images are always stored locally under the system temp directory
compress_pdfreturns up to30packed images inline by defaultthe adaptive sizing checkpoint is bundled with the package
adaptive sizing activates automatically when
torchandtorchvisionare availableset
OPTICAL_CONTEXT_DISABLE_ADAPTIVE_SIZING=1to force the legacy fixed sizingset
OPTICAL_CONTEXT_ADAPTIVE_MODEL_PATH=/path/to/model.ptto override the bundled checkpoint
For pinned shared setups:
uvx --from optical-context-mcp==0.1.4 optical-context-mcpRun
Default transport is stdio:
optical-context-mcpClaude Code
Register the server in a project:
claude mcp add -s project optical-context -- uvx optical-context-mcpTypical use:
call
compress_pdfinspect 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
adaptive sizing falls back safely to fixed medium image sizing when the ML runtime is absent
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 pytestAvailable Tools
3 toolscompress_pdfC
Read a local PDF, run Mistral OCR, recompose it into dense packed PNG images, and create a retrievable compression job.
| Name | Required | Description | Default |
|---|---|---|---|
| pdf_path | Yes | ||
| chars_per_image | No | ||
| inline_images | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It outlines the pipeline steps but omits critical details: whether the operation is destructive, if it requires network access, what permissions are needed, approximate time, or error conditions. For a multi-step tool, this is insufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single 18-word sentence that efficiently lists the sequential steps. It is front-loaded with the main action (read local PDF). However, it could be structured with bullet points or separate clauses to improve readability, though it remains reasonably concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (3 parameters, no output schema, no annotations), the description is incomplete. It does not explain return values (e.g., job ID), how to retrieve results (via siblings), or the role of optional parameters. A comprehensive description should at least indicate that a job object is created and that its manifest can be fetched via get_job_manifest.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has three properties (pdf_path, chars_per_image, inline_images) with zero description coverage in the schema. The description does not mention any parameters, so it adds no meaning beyond the schema. With 0% schema coverage, the description should at least explain the effect of each parameter, but it fails to do so.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool reads a local PDF, runs Mistral OCR, recomposes into PNG images, and creates a compression job. This distinguishes it from its siblings (get_job_manifest, get_packed_images) which are retrieval tools. However, it could better emphasize that the primary output is a job object rather than a compressed file.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. The description does not mention prerequisites (e.g., local file access, Mistral OCR availability) or scenarios where it should be avoided. There is no mention of the sibling tools or when retrieval should be used instead.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_job_manifestC
Load the saved manifest for a previously compressed PDF job.
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description must disclose behavioral traits. It only says 'load' without clarifying whether it is read-only, what happens if the job_id is invalid, or any side effects. This is insufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single short sentence, but it omits essential information. It is under-specified rather than effectively concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the lack of annotations, no output schema, and a single parameter with 0% schema coverage, the description is critically incomplete. It does not explain what a manifest is, nor the return format or error behavior.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0% for the single parameter 'job_id'. The description does not add any meaning beyond the schema (it simply names the parameter). With no additional context, the agent cannot infer format or constraints.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'Load' and the resource 'saved manifest for a previously compressed PDF job', which distinguishes it from sibling tools like compress_pdf and get_packed_images.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. There are no explicit when-to-use, when-not-to-use, or alternative recommendations.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_packed_imagesC
Return one or more previously generated packed PNG images for a stored job.
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | Yes | ||
| start_index | No | ||
| limit | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must disclose behavioral traits. It labels the operation as 'return' implying read-only, but does not mention pagination behavior, order, error conditions, or any side effects. It is insufficiently transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence with no fluff, but it is under-informative. It achieves conciseness at the cost of missing critical details.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 3 parameters, no output schema, and no annotations, the description is too sparse. It does not explain pagination, the nature of packed images, or expected behavior. The tool is more complex than the description conveys.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description should explain parameters. It does not describe job_id, start_index, or limit beyond the schema defaults. The meaning of start_index and limit (likely pagination) is left implicit.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool returns previously generated packed PNG images for a job. It uses a specific verb ('Return') and resource ('packed PNG images'), but does not explicitly distinguish from sibling tools like compress_pdf or get_job_manifest.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives, nor prerequisites or limitations. The description implies basic usage but lacks explicit when-to-use or when-not-to-use context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
3 tool updates
v0.1.4- First observed
compress_pdf - First observed
get_job_manifest - First observed
get_packed_images
TDQS
Each tool targets a distinct operation: compression, manifest retrieval, and image retrieval. No overlap or ambiguity.
All tool names follow a consistent verb_noun pattern with lowercase and underscores (compress_pdf, get_job_manifest, get_packed_images).
Three tools are appropriate for the narrow domain of PDF compression and retrieval. The count feels slightly minimal but sufficient for the core workflow.
The set covers the essential operations (compress, get metadata, get output) but lacks optional features like job deletion or status polling, which are minor gaps.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Compress PDFs to exact target sizes (82-93% smaller). Tools: compress_pdf, optimize_pdf, inspect_pdf
Convert and compress PDFs and images, redact personal data, and run text and data utilities.
Image processing for AI agents: resize, convert, compress, crop, and web-ready AI-generated images.
Video, audio, and image processing for AI agents: convert, transcribe, upscale - 150+ operations.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceRenders large text blobs as dense PNG image pages via pxpipe, enabling vision models to read content at ~3x token efficiency with a single inline image block.MIT
- AlicenseNot gradedqualityDmaintenanceCompresses file reads, command output, search hits, and fetched web pages before entering agent context to reduce token usage, using deterministic transforms and a safety verifier.569MIT
- AlicenseAqualityAmaintenanceEnables text-first agents to inspect images via focused questions, returning compact, checked evidence packets. Reduces visual context by ~90% while preserving expected fields.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to analyze, compress, and verify PDFs while preserving text, vectors, and document structure, with configurable presets and target-size limits.1MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ChrBoebel/optical-context-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server