Skip to main content
Glama

OCR.space MCP Server

Pipeline Status Coverage Ruff Python 3.11+ License: MIT

Python MCP server for OCR.space - extract text from images and PDFs using OCR.

Features

  • Six comprehensive tools:

    • ocr_file - Extract text from local images/PDFs

    • ocr_url - Extract text from images/PDFs at URLs

    • ocr_auto - Smart OCR that auto-handles oversized files

    • split_pdf - Split large PDFs into API-compatible chunks

    • list_languages - Show supported OCR languages

    • check_tier_status - Verify API configuration

  • Automatic oversized file handling:

    • PDFs too large? Automatically split by pages, OCR each chunk, join results

    • Images too large? Automatically compress while preserving quality

  • Dual-tier support:

    • Free tier: 1 MB limit, US servers

    • PRO tier: 5 MB limit, EU endpoint for GDPR compliance

  • Full API parameter support:

    • 26+ languages including auto-detection

    • Two OCR engines (optimized for different use cases)

    • Table optimization mode

    • Auto-rotation detection

    • Searchable PDF generation

    • Save results as TXT or JSON

Related MCP server: EasyOCR MCP Server

Installation

# With uv (recommended)
uv sync

# With pip
pip install -e .

Configuration

API Keys

Get your free API key at ocr.space/ocrapi/freekey.

For PRO features (larger files, EU endpoint), sign up at ocr.space/ocrapi.

Environment Variables

Copy .envrc.example to .envrc and configure:

# Required: Free tier API key
export OCR_SPACE_API_KEY="your-free-api-key"

# Optional: PRO tier for GDPR-compliant EU processing
export OCR_SPACE_PRO_API_KEY="your-pro-api-key"
export OCR_SPACE_PRO_ENDPOINT="https://eu.api.ocr.space/parse/image"

Then enable with direnv allow.

Claude Code / MCP Config

Add to .mcp.json:

{
  "mcpServers": {
    "ocr-space": {
      "command": "uv",
      "args": ["run", "--project", "/path/to/ocr-space-mcp", "ocr-space-mcp"],
      "env": {
        "OCR_SPACE_API_KEY": "${OCR_SPACE_API_KEY}",
        "OCR_SPACE_PRO_API_KEY": "${OCR_SPACE_PRO_API_KEY}",
        "OCR_SPACE_PRO_ENDPOINT": "${OCR_SPACE_PRO_ENDPOINT}"
      }
    }
  }
}

OpenCode Config

Add to opencode.json:

{
  "mcp": {
    "ocr-space": {
      "command": "uv",
      "args": ["run", "--project", "/path/to/ocr-space-mcp", "ocr-space-mcp"],
      "env": {
        "OCR_SPACE_API_KEY": "${OCR_SPACE_API_KEY}",
        "OCR_SPACE_PRO_API_KEY": "${OCR_SPACE_PRO_API_KEY}",
        "OCR_SPACE_PRO_ENDPOINT": "${OCR_SPACE_PRO_ENDPOINT}"
      }
    }
  }
}

Usage

Check Configuration

Check my OCR.space tier status

OCR a Local File

Extract text from /path/to/document.pdf
OCR this image using the PRO tier: /path/to/scan.png

Parameters:

Parameter

Description

Default

file_path

Path to image/PDF (required)

-

tier

free or pro

free

language

OCR language code

eng

ocr_engine

1 (fast) or 2 (accurate)

1

output_path

Save result to file

-

output_format

txt or json

txt

detect_orientation

Auto-rotate image

false

scale

Upscale low-res images

false

is_table

Optimize for tables

false

is_create_searchable_pdf

Generate searchable PDF

false

OCR from URL

Extract text from https://example.com/document.png

Smart OCR for Large Files (ocr_auto)

The ocr_auto tool automatically handles files that exceed the API size limits:

OCR this large document: /path/to/big-scan.pdf

How it works:

  • PDFs: Splits into chunks by page, OCRs each chunk, joins results

  • Images: Compresses (quality + resize) until under limit, then OCRs

Parameters: Same as ocr_file, but no size limit errors!

Split PDF Only

If you just want to split a large PDF without OCR:

Split /path/to/large.pdf for free tier processing

Creates multiple smaller PDF files in a temp directory (or specify output_dir).

List Languages

What OCR languages are supported?

Supported languages: Arabic, Bulgarian, Chinese (Simplified/Traditional), Croatian, Czech, Danish, Dutch, English, Finnish, French, German, Greek, Hungarian, Italian, Japanese, Korean, Polish, Portuguese, Russian, Slovenian, Spanish, Swedish, Thai, Turkish, Ukrainian, Vietnamese.

Use language=auto with Engine 2 for automatic language detection.

Tier Comparison

Feature

Free

PRO

File size limit

1 MB

5 MB

Server location

US only

EU available

Rate limit

500/day

Unlimited

GDPR compliance

No

Yes (EU endpoint)

Price

Free

$30/month

OCR Engines

Engine

Best For

Engine 1

Faster processing, Asian languages, large images

Engine 2

Auto-language detection, special characters, rotated text

Development

# Install with dev dependencies
uv sync --extra dev

# Run linter
uv run ruff check .

# Format code
uv run ruff format .

# Run tests
uv run pytest -v

# Run tests with coverage
uv run pytest --cov=ocr_space_mcp --cov-report=term-missing

License

MIT - see LICENSE

Available Tools

6 tools
check_tier_statusA

Check which API tiers are configured and available. Shows which environment variables are set.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must carry the full burden of behavioral disclosure. It does state that it shows which environment variables are set, which gives some transparency about its read-only nature. However, it does not mention whether it requires any specific setup, what the response format is, or any potential side effects, leaving gaps for the agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, concise and front-loaded. The first sentence states the primary purpose, and the second adds a relevant detail about environment variables. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema), the description provides enough context: it explains what the tool checks and the nature of the output (environment variable status). However, it could be slightly more explicit about what 'configured and available' means or what the agent should do with this information, though the sibling tools suggest a clear context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the description is not required to explain parameter semantics. The baseline for 0 parameters is 4, and the description adds value by clarifying the tool's purpose rather than repeating schema information.

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 tool's function: checking which API tiers are configured and available. The verb 'Check' is specific, and the resource 'API tiers' is distinct from the sibling tools (OCR/PDF operations), making it easy to differentiate.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not explicitly state when to use this tool versus alternatives, but the sibling tools are all OCR/PDF operations, so the usage context is implied: this is a configuration/diagnostic tool. No exclusions or alternative instructions are provided, so it earns a mid score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_languagesA

List all supported OCR languages with their codes.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It conveys that the tool lists languages and includes codes, but adds no extra behavioral context such as return format, sorting, or side effects. The basic read-only nature is understood but not amplified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, front-loaded sentence communicates the exact purpose without any redundant words or structures. It is a model of conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter tool with no output schema and clear sibling context, the description fully explains the tool's capability. An agent can confidently invoke it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the baseline score is 4 per the rubric. The description correctly avoids inventing parameter details, and none are needed.

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 uses the specific verb 'list' and identifies the resource as 'supported OCR languages' with their codes, making the tool's purpose unmistakable. It clearly distinguishes this utility from sibling OCR execution tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage (when you need the list of OCR languages) but provides no explicit guidance on when to use it versus alternatives, nor any exclusions. For a simple listing tool, this is adequate but not explicitly guided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ocr_autoA

Smart OCR that automatically handles oversized files. For PDFs: splits into chunks, OCRs each, and joins results. For images: compresses to fit within size limit before OCR. Use this when you don't know if the file exceeds the size limit.

ParametersJSON Schema
NameRequiredDescriptionDefault
tierNoAPI tier: 'free' (1MB limit, US servers) or 'pro' (5MB limit, EU/GDPR)free
languageNoOCR language code (e.g., 'eng', 'ger', 'fre'). Use 'auto' with Engine 2.eng
file_pathYesPath to the image or PDF file to OCR
ocr_engineNoEngine 1: Faster, Asian languages. Engine 2: Auto-detect, better accuracy.
output_pathNoOptional path to save extracted text (.txt) or full result (.json)
output_formatNoOutput format: 'txt' (text only) or 'json' (full API response)txt

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behaviors: automatic chunking for PDFs, compression for images, and result joining. This gives the agent critical insight into how the tool handles large files, beyond what the schema exposes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences, front-loaded with the core value proposition ('Smart OCR'), then details specific behaviors, and ends with usage guidance. Every sentence earns its place, no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description provides sufficient behavioral context for a tool with 6 parameters and no output schema. It explains the automatic handling of oversized files, which is the tool's unique advantage, and the schema covers the rest. No major gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage for all 6 parameters, so the description doesn't need to add parameter-level detail. It adds context about file handling (splitting/compression) that informs the file_path parameter, but the schema already documents the rest adequately. Baseline 3 is appropriate.

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 it's an OCR tool that automatically handles oversized files, with specific behavior for PDFs (split/OCR/join) and images (compress). This distinguishes it from siblings like ocr_url and ocr_file, which likely handle direct OCR without auto-handling of size limits.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states 'Use this when you don't know if the file exceeds the size limit,' providing clear when-to-use guidance. It doesn't explicitly name alternatives but implies that for known under-limit files or URL-based OCR, other tools (ocr_file, ocr_url) would be more appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ocr_fileA

Extract text from a local image or PDF file using OCR.space API. Supports PNG, JPG, GIF, BMP, TIFF, PDF. Free tier: max 1 MB. PRO tier: max 5 MB (EU endpoint for GDPR). Optionally saves result to txt or json file.

ParametersJSON Schema
NameRequiredDescriptionDefault
tierNoAPI tier: 'free' (1MB limit, US servers) or 'pro' (5MB limit, EU/GDPR)free
scaleNoUpscale low-resolution images for better OCR
is_tableNoOptimize for table-like structures
languageNoOCR language code (e.g., 'eng', 'ger', 'fre'). Use 'auto' with Engine 2.eng
file_pathYesPath to the image or PDF file to OCR
ocr_engineNoEngine 1: Faster, Asian languages. Engine 2: Auto-detect, better accuracy.
output_pathNoOptional path to save extracted text (.txt) or full result (.json)
output_formatNoOutput format: 'txt' (text only) or 'json' (full API response)txt
detect_orientationNoAuto-rotate image based on detected text orientation
is_overlay_requiredNoInclude word coordinates/bounding boxes in response
is_create_searchable_pdfNoGenerate a searchable PDF (URL valid for 1 hour)

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the burden of behavioral disclosure. It adds valuable context: tier-based file size limits (1MB free, 5MB pro), EU endpoint for GDPR, and optional saving to txt/json. However, it does not explicitly state that the file is uploaded to a third-party API or describe return behavior when no output_path is given.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences with no fluff. It front-loads the primary action and packs in essential constraints (formats, size limits, GDPR, optional output) efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complex 11-parameter schema and no output schema, the description covers the core workflow (local input, API, optional saving) well. It misses an explicit statement about what the function returns when no output_path is provided, but 'Extract text' implies the text is returned, so the gap is minor.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so each parameter already has detailed descriptions (e.g., tier explains 1MB/5MB limits, output_path explains saving). The tool description adds only supported file formats, which is marginal. Baseline 3 is appropriate since the schema does the heavy lifting.

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 'Extract text from a local image or PDF file using OCR.space API', specifying the action, resource, and method. It also lists supported formats, making it distinct from sibling tools like ocr_url which handles URLs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context that this tool is for local files, distinguishing it from URL-based tools. However, it does not explicitly name alternative tools (e.g., 'use ocr_url for remote files') or specify when not to use it, so it stops short of full guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ocr_urlA

Extract text from an image or PDF at a URL using OCR.space API. The URL must be publicly accessible. Free tier: max 1 MB. PRO tier: max 5 MB.

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYesPublic URL of the image or PDF to OCR
tierNoAPI tier: 'free' (1MB limit, US servers) or 'pro' (5MB limit, EU/GDPR)free
scaleNoUpscale low-resolution images
is_tableNoOptimize for tables
languageNoOCR language code (e.g., 'eng', 'ger', 'fre'). Use 'auto' with Engine 2.eng
ocr_engineNoEngine 1: Faster, Asian languages. Engine 2: Auto-detect, better accuracy.
output_pathNoOptional path to save extracted text (.txt) or full result (.json)
output_formatNoOutput format: 'txt' (text only) or 'json' (full API response)txt
detect_orientationNoAuto-rotate image

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full transparency burden. It discloses that the tool uses an external API, requires public URL access, and has size limits based on tier. However, it does not mention output behavior, potential network/security implications, or what happens on failure. It adds some value but lacks richer behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences long, front-loaded with the main purpose, and each sentence adds meaningful information (action, URL requirement, size limits). No wasted words, and the structure is easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 9 parameters, no output schema, and no annotations, the description provides essential context: what it does, the external API dependency, and key constraints. The schema covers the remaining parameter details. It is reasonably complete for the tool's complexity, though it could mention error/edge cases or further usage context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (all 9 parameters have descriptions in the schema), so the baseline is 3. The tool description does not add additional parameter meaning beyond what the schema already provides; the schema thoroughly documents each parameter, so more detail in the description is unnecessary.

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 begins with 'Extract text from an image or PDF at a URL', which clearly specifies the action (extract text), the resource (image/PDF at a URL), and distinguishes it from the sibling tool ocr_file (which likely handles local files). It also names the underlying API (OCR.space) for additional context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description clearly indicates the tool is for URLs by stating the URL must be publicly accessible and provides size limits for free vs PRO tiers. This gives clear context for when to use the tool, though it does not explicitly mention alternatives or exclusions compared to sibling tools like ocr_file or ocr_auto.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

split_pdfA

Split a large PDF into smaller chunks that fit within API size limits. Useful for processing PDFs that exceed the 1 MB (free) or 5 MB (pro) limit. Each chunk contains as many pages as possible while staying under the limit.

ParametersJSON Schema
NameRequiredDescriptionDefault
tierNoTarget tier determines size limit: free=1MB, pro=5MBfree
file_pathYesPath to the PDF file to split
output_dirNoDirectory for output chunks (uses temp dir if not specified)

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden. It discloses the splitting behavior ('Each chunk contains as many pages as possible while staying under the limit') and limits, but it does not mention whether the original file is preserved or detail output chunk naming/structure. This is a moderate transparency level for a utility tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is composed of two concise sentences that front-load the action and then provide necessary context. No filler or repetition of schema information. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple preprocessing tool with 3 parameters and no output schema, the description covers purpose, use case, and behavioral nuances. It lacks explicit notes on whether the original is modified and how chunks are consumed downstream, but these are not critical given the tool's simplicity and the schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already has 100% parameter coverage, describing file_path, tier (with enum values and size limits), and output_dir. The description adds no parameter-specific details beyond the schema, but the schema is rich enough; the 'as many pages as possible' behavior is contextual, not parameter semantics. Baseline 3 is appropriate.

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 uses a specific verb 'Split' and clear resource 'large PDF into smaller chunks', and explicitly ties it to API size limits. It distinguishes from sibling OCR tools by focusing on preprocessing. The purpose is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description states when to use it: 'Useful for processing PDFs that exceed the 1 MB (free) or 5 MB (pro) limit.' This provides clear context, though it does not explicitly mention when not to use it or name alternatives. However, siblings are unrelated OCR tools, so this is sufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.4/5.0
Disambiguation5/5

Each tool has a distinct purpose: URL-based OCR, file-based OCR, auto-handling of oversized files, PDF splitting, language listing, and tier status check. There is no overlap between these operations.

Naming Consistency5/5

All tool names follow a consistent snake_case verb_noun pattern (e.g., ocr_url, split_pdf, list_languages). The 'ocr_' prefix for the three OCR variations and clear verbs for helpers make the set easy to predict.

Tool Count5/5

With 6 tools, the server is well-scoped: three OCR methods, one PDF utility, and two informational tools. This is neither too sparse nor overloaded for the domain.

Completeness5/5

The toolset covers the core OCR lifecycle end-to-end: extracting from URL or file, handling oversized inputs via auto-splitting/compression, splitting PDFs manually, and providing necessary supporting info (languages, tier status). No obvious gaps remain.

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/agentic-ai-forge/ocr-space-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server