Skip to main content
Glama

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: 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

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_pdf

  • packed images are always stored locally under the system temp directory

  • compress_pdf returns up to 30 packed images inline by default

  • the adaptive sizing checkpoint is bundled with the package

  • adaptive sizing activates automatically when torch and torchvision are available

  • set OPTICAL_CONTEXT_DISABLE_ADAPTIVE_SIZING=1 to force the legacy fixed sizing

  • set OPTICAL_CONTEXT_ADAPTIVE_MODEL_PATH=/path/to/model.pt to override the bundled checkpoint

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:

  1. call compress_pdf

  2. inspect the returned manifest

  3. fetch packed images with get_packed_images

MCP Tools

  • compress_pdf: run OCR plus recomposition and create a stored job

  • get_job_manifest: load metadata for an existing job

  • get_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 pytest

Available Tools

3 tools
compress_pdfC

Read a local PDF, run Mistral OCR, recompose it into dense packed PNG images, and create a retrievable compression job.

ParametersJSON Schema
NameRequiredDescriptionDefault
pdf_pathYes
chars_per_imageNo
inline_imagesNo

TDQS

C2.6/5.0
Behavior2/5

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.

Conciseness4/5

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.

Completeness2/5

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.

Parameters1/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
job_idYes

TDQS

C2.7/5.0
Behavior2/5

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.

Conciseness2/5

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.

Completeness1/5

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.

Parameters2/5

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.

Purpose5/5

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.

Usage Guidelines2/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
job_idYes
start_indexNo
limitNo

TDQS

C2.6/5.0
Behavior2/5

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.

Conciseness3/5

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.

Completeness2/5

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.

Parameters2/5

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.

Purpose4/5

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.

Usage Guidelines2/5

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.

  1. 3 tool updatesv0.1.4
    • First observedcompress_pdf
    • First observedget_job_manifest
    • First observedget_packed_images

TDQS

B3.2/5.0
Disambiguation5/5

Each tool targets a distinct operation: compression, manifest retrieval, and image retrieval. No overlap or ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with lowercase and underscores (compress_pdf, get_job_manifest, get_packed_images).

Tool Count4/5

Three tools are appropriate for the narrow domain of PDF compression and retrieval. The count feels slightly minimal but sufficient for the core workflow.

Completeness4/5

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

ActivityInactive
ResponsivenessSyncing

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

Related MCP Servers

Latest Blog Posts

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