Skip to main content
Glama

OCR Beans

Extrator de texto de processos judiciais brasileiros — via MCP (Claude, ZCode e qualquer cliente MCP), CLI, API web e app desktop.

PDFs de tribunais brasileiros (TJ-SP, TRT, STJ) frequentemente usam fontes proprietárias que nenhuma IA consegue ler: aparentam ter texto, mas a extração devolve lixo. O OCR Beans detecta automaticamente essas fontes corrompidas e aplica OCR somente onde precisa — o resto sai do texto nativo, instantâneo e perfeito.

100% offline. Nenhum dado do processo sai da máquina. LGPD por construção.

Instalação como plugin MCP (Claude Code / Cowork / ZCode)

Os manifests estão na raiz deste repositório (.claude-plugin/ e .zcode-plugin/) — aponte o marketplace ou adicione direto:

# Claude Code (local, sem servidor):
claude mcp add ocr-beans -- uv run --no-project --python 3.12 \
  --with pymupdf==1.28.2 --with pytesseract==0.3.13 \
  --with Pillow==12.3.0 --with mcp==2.3.0 \
  python3 ocr_beans/mcp_server.py

O uv (um bin único) provisiona o Python 3.12 e as dependências automaticamente na primeira execução. Tesseract é opcional: sem ele o texto nativo funciona; para páginas escaneadas, apt install tesseract-ocr tesseract-ocr-por (Linux), brew install tesseract tesseract-lang (macOS) ou o instalador UB-Mannheim (Windows, marcar Portuguese).

Related MCP server: document-intelligence-mcp

Ferramentas (MCP)

Tool

O que faz

check_legibility

Diagnóstico em < 1s: o PDF precisa de OCR?

ocr_pdf

Processo inteiro; ≤30 págs devolve o texto, maiores salvam .txt + resumo

ocr_page

Páginas específicas ("1-5", "3,7,9") — para processos de milhares de fls.

ocr_image

Prints de decisões, fotos de documentos, scans avulsos

batch_ocr

Pasta inteira de PDFs (até 50 por vez)

Cada página sai marcada como TEXTO ou OCR, com o número da folha (fls. N) pronto para citação em petição.

Qualidade — números medidos, não estimados

  • 475/475 páginas com decisão e conteúdo 100% idênticos ao motor do executável original (OCRBeans.exe) — comparação página a página em processos reais do TJSP; motor conferido contra o bytecode do .exe (29 funções, idênticas)

  • 20 páginas/segundo em texto nativo · 1,76 s por página corrompida (Tesseract 300 DPI, por, --psm 6)

  • Determinístico: mesmo arquivo, mesmo texto — sem alucinação de acentos (modelos de visão erraram "DE DIREito" e "JUNDIAI" nesta mesma página que o motor extrai perfeita)

  • Segurança: validação de caminho anti-traversal, limites de DPI/páginas/ tamanho/tamanho de lote, zero chamadas de rede no código

  • Bateria de produção 16/16 (autenticação, 5 tools, rejeições de segurança, concorrência) no conector remoto

Conector remoto (opcional)

Para quem prefere zero instalação: https://mcp.beanstech.io/mcp (MCP Streamable HTTP, autenticação OIDC/Keycloak, hospedado em São Paulo — território nacional). O plugin local não depende dele.

O que mais está incluído

Interface

Uso

Público

MCP Server

tools para Claude Code / agentes AI

Agentes AI

API Web

ocr-beans-api — UI estilo iLovePDF + REST em /api/*

Programas e humanos

CLI

ocr_beans <comando> — terminal

Scripts e automação

App Desktop

ocr_beans_app.py — GUI (Windows/macOS/Linux; .exe com Tesseract embutido via OCR Beans.spec)

Usuário final

Conversões de PDF (estilo iLovePDF)

  • Imagens → PDF · PDF → imagens (zip por página) · PDF → Word (DOCX)

  • Juntar, dividir, extrair páginas, girar, comprimir (−33,6% medido em contrato real), marca d'água, extrair imagens embutidas

Instalação da suíte completa

# Linux
sudo apt install tesseract-ocr tesseract-ocr-por
pip install .            # ou: pip install -r requirements.txt

# Docker (MCP remoto / API)
docker build -t ocr-beans . && docker run -p 8080:8080 ocr-beans

Docs completas em docs/ (API, CLI, MCP, instalação, arquitetura, privacidade).

Licença

MIT — ver LICENSE. Dependências: PyMuPDF (AGPL/comercial), Tesseract (Apache-2.0), Pillow (HPND), MCP SDK (MIT).


BeansTech · https://beanstech.io

Available Tools

5 tools
batch_ocrA

Processa todos os PDFs de um diretório via OCR.

Salva cada resultado como .txt (no mesmo diretório ou em output_directory).
Retorna um resumo com a lista de arquivos processados.

Args:
    directory: Caminho do diretório contendo os PDFs.
    output_directory: Diretório de saída (opcional). Se não informado, salva ao lado dos PDFs.
    dpi: Resolução para OCR (150, 200, 300 ou 400). Default: 300.
ParametersJSON Schema
NameRequiredDescriptionDefault
dpiNo
directoryYes
output_directoryNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/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 usefully discloses the write side-effect (each PDF saved as .txt) and the return summary, but says nothing about overwrite behavior, permissions, recursion into subdirectories, or what happens to non-PDF/failed files in the directory.

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?

Front-loaded with the core action and side-effect in two short sentences, followed by a clean Args block. Well organized, no filler.

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

Completeness3/5

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

An output schema exists so return-value detail is not required, and the params are fully covered. However, for an unannotated batch mutation tool, the description omits failure/overwrite/permission semantics that an agent would need to invoke it safely.

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?

Schema coverage is 0%, so the description must compensate, and it documents all three parameters: directory purpose, optional output_directory with its default behavior (saved beside the PDFs), and dpi with allowed values (150/200/300/400) and default 300 — detail the schema's bare integer type lacks.

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?

States a specific verb+resource+scope: OCR every PDF in a directory, writing .txt results. The batch scope ('todos os PDFs de um diretório') implicitly separates it from the single-file siblings (ocr_pdf, ocr_image), though no sibling is named.

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?

Usage is implied by the batch-directory scope, but there is no explicit when-to-use/when-not guidance and no mention of the sibling tools (ocr_pdf, ocr_page, check_legibility) to route the agent. The agent must infer that this is for multi-file batches.

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

check_legibilityA

Diagnóstico rápido: verifica se um PDF tem fontes corrompidas/proprietárias.

Não faz OCR — apenas analisa o texto nativo da primeira página para determinar
se o documento precisará de OCR. Operação rápida (< 1 segundo).

Args:
    pdf_path: Caminho absoluto do arquivo PDF.
ParametersJSON Schema
NameRequiredDescriptionDefault
pdf_pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does disclose meaningful traits: it performs no OCR, analyzes only the native text of the FIRST page (a real scope limitation), and runs in under one second. It omits whether it mutates anything or requires special permissions, but as a pure read/analysis diagnostic that gap is minor.

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?

Front-loads the purpose, then the key limitation, then performance, then the argument — every sentence earns its place with no redundancy. Structure is clean, though the args block is slightly verbose for a single parameter.

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 one-parameter diagnostic with an output schema (so return values need not be explained), the description covers purpose, scope limitation, performance, and the argument's semantics. Nothing essential to correct invocation is missing, though it could note expected output direction.

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?

Schema coverage is 0% and the property is just a bare string, but the description compensates by specifying 'Caminho absoluto do arquivo PDF' — the absolute-path requirement is real semantic value the schema does not provide. One well-explained parameter warrants a 4.

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?

States a specific verb and resource ('verifica se um PDF tem fontes corrompidas/proprietárias') and explicitly contrasts itself with the OCR siblings by declaring 'Não faz OCR'. An agent can distinguish this diagnostic tool from ocr_pdf/ocr_page/ocr_image/batch_ocr without opening any schema.

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 situates the tool clearly as a pre-OCR diagnostic ('determinar se o documento precisará de OCR'), which tells the agent when it is relevant. However, it never names a specific alternative or states an explicit when-not-to-use rule beyond the implicit 'if you actually need OCR, use a different tool'.

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

ocr_imageA

Extrai texto de uma imagem via OCR (Tesseract).

Útil para prints de decisões, páginas escaneadas salvas como imagem,
fotos de documentos etc.

Args:
    image_path: Caminho absoluto da imagem (png, jpg, jpeg, tif, tiff, bmp, webp, gif).
    lang: Idioma do Tesseract (por, eng, por+eng). Default: por.
    psm: Modo de segmentação (3=auto, 6=bloco uniforme, 11=texto esparso). Default: 6.
ParametersJSON Schema
NameRequiredDescriptionDefault
psmNo
langNopor
image_pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full behavioral burden. It discloses the OCR engine (Tesseract) and the mode defaults, but says nothing about error/failure behavior for low-legibility images, whether the operation is read-only/side-effect-free, or resource/time constraints — gaps that matter for an OCR tool.

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 purpose is front-loaded in the first line, followed by a short use-case sentence and a clean Args block. The use-case sentence is mildly expendable but structured, and nothing is padded or circular.

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

Completeness3/5

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

With an output schema present, return values need not be explained, and the parameters are well covered. The remaining gap is sibling disambiguation (single image vs batch vs PDF vs page) and any statement about failure handling, leaving the agent to guess which OCR tool to pick in a five-tool family.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate, and it does: image_path is documented with accepted formats and an absolute-path requirement, lang lists valid values (por, eng, por+eng) with its default, and psm decodes the integer enum (3=auto, 6=uniform block, 11=sparse text). This adds meaning the bare schema cannot convey.

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 states a specific verb+resource: extract text from an image via OCR (Tesseract), and even enumerates concrete use cases (screenshots, scanned pages, document photos). It does not, however, differentiate itself from the sibling tools (batch_ocr, ocr_page, ocr_pdf), so an agent must infer the boundary from the resource noun alone.

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 'Útil para...' sentence gives implied usage context (screenshots, scanned pages, document photos), which is better than nothing. But it never names alternatives or exclusions, so nothing tells the agent when to prefer batch_ocr (multiple images) or ocr_pdf (PDF input) over this single-image tool.

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

ocr_pageA

Extrai texto de páginas específicas de um PDF.

Útil para PDFs grandes onde você só precisa de algumas páginas,
ou para follow-up após usar ocr_pdf em um documento grande.

Args:
    pdf_path: Caminho absoluto do arquivo PDF.
    pages: Páginas a extrair. Formatos aceitos: "1", "1-5", "1,3,7", "2-4,8".
    dpi: Resolução para OCR (150, 200, 300 ou 400). Default: 300.
ParametersJSON Schema
NameRequiredDescriptionDefault
dpiNo
pagesYes
pdf_pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/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 behavioral burden. It discloses useful operational detail (accepted page-range syntax, DPI choices and default) but says nothing about permissions, local file requirements, cost/time of OCR, or read-only nature, leaving real behavioral gaps.

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?

Purpose is front-loaded in the first sentence, followed by a usage sentence and a clean Args block. Every element is informative, though the structure is conventional rather than tight.

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?

An output schema exists, so return values need not be explained. For a three-parameter OCR tool, the description covers purpose, usage context, and all parameter syntax adequately; nothing an agent needs to invoke it correctly is missing.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate, and it does: it defines pdf_path as an absolute path, enumerates accepted page formats with four concrete examples, and lists the valid DPI values plus the default. This is richer than the bare schema types.

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?

States a specific verb and resource (extract text from specific PDF pages) and immediately scopes it against the whole-document sibling by framing it as page-selective. An agent can tell this apart from ocr_pdf and batch_ocr without opening a schema.

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 gives two use cases: large PDFs where only a few pages are needed, and follow-up after running ocr_pdf on a large document. It names the alternative it complements, though it never states when *not* to use it (e.g., for whole documents, prefer ocr_pdf).

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

ocr_pdfA

Extrai texto de um PDF. Detecta automaticamente fontes corrompidas (comum em PDFs judiciais brasileiros) e aplica OCR quando necessário.

Para PDFs pequenos (<=30 páginas), retorna o texto completo.
Para PDFs grandes, salva em .txt e retorna o caminho + resumo.

Args:
    pdf_path: Caminho absoluto do arquivo PDF.
    dpi: Resolução para OCR (150, 200, 300 ou 400). Default: 300.
    save_to_file: Forçar salvamento em arquivo .txt mesmo para PDFs pequenos.
ParametersJSON Schema
NameRequiredDescriptionDefault
dpiNo
pdf_pathYes
save_to_fileNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full behavioral burden and does substantial work: it discloses automatic corrupted-font detection, conditional OCR application, the <=30-page threshold, and divergent return behavior (full text vs .txt path + summary). It omits permission/authorization needs, failure behavior, and runtime cost, keeping it short of a 5.

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 opening sentence leads with the core action, and the small-vs-large behavior follows logically before the Args block. It is slightly list-like in the Args section but every line carries information; no filler sentences.

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?

An output schema exists, so return structure needn't be documented, yet the description usefully explains the two return modes. Given no annotations and a mutation-adjacent side effect (writing .txt files), the omission of error handling and file-write implications is a minor gap, but the definition is otherwise complete for calling the tool.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must fully document parameters, and it does: pdf_path is specified as an absolute path, dpi is given the allowed enum values (150/200/300/400) and its default, none of which appear in the schema, and save_to_file's override semantics are explained. It fully compensates for the schema gap.

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 states a specific verb and resource ('Extrai texto de um PDF') plus the differentiator that it auto-detects corrupted fonts and applies OCR when needed. It is clear what the tool does, but it never names or distinguishes itself from the sibling tools (ocr_image, batch_ocr, ocr_page), which is required for a 5.

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 explains internal OCR-triggering behavior and the small-vs-large PDF branching, which implies when the tool is relevant. However, it gives no explicit guidance on when to choose this over ocr_image or ocr_page, nor any exclusions or prerequisites. Usage is implied rather than stated.

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.

  1. 5 tool updatesv2.0.0
    • First observedbatch_ocr
    • First observedcheck_legibility
    • First observedocr_image
    • First observedocr_page
    • First observedocr_pdf

TDQS

A3.9/5.0

Scored across 5 tools

Disambiguation4/5

Each tool has a fairly distinct target: ocr_image (images), check_legibility (diagnostic), batch_ocr (directory batch), ocr_pdf (full PDF), and ocr_page (specific pages). The only mild overlap is ocr_pdf vs ocr_page, but the descriptions clearly delineate the full-document vs page-subset use cases.

Naming Consistency4/5

Three tools share the 'ocr_' prefix (ocr_image, ocr_pdf, ocr_page) and the rest use clear verb_noun forms (check_legibility, batch_ocr). Mostly readable and predictable, though the prefix/suffix placement of 'ocr' varies slightly.

Tool Count5/5

Five tools is a tight, well-scoped set for an OCR/PDF extraction domain. Every tool covers a distinct entry point (single image, single PDF, page subset, batch directory, pre-flight diagnostic) with no redundancy.

Completeness4/5

The surface covers the core OCR lifecycle well: images, full PDFs, page subsets, batch directories, and a legibility diagnostic. Minor gaps remain (e.g. batch image processing or configurable output formats), but the main workflows are fully supported.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables interaction with Brazil's Electronic Judicial Process (PJe) system to search for legal processes, view case details, and download court documents. Supports secure JWT authentication and process lookup by CPF/CNPJ or party name.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Local document intelligence for AI agents — extract text, detect tables, read metadata, analyze structure, search keywords, and detect language from PDF and DOCX files. No cloud API required, no API key needed.
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables AI agents to inspect PDFs, merge or extract pages, and clean text entirely offline through the Model Context Protocol, with no uploads, API keys, or network calls.
    4
    36 npm
    MIT
  • F
    license
    B
    quality
    A
    maintenance
    Enables local, offline document extraction and manipulation—PDF first but also HTML, DOCX, XLSX, PPTX, EML, EPUB, Markdown, and plain text—through tools for probing, locating, extracting, converting, assembling, OCR, protecting, and redacting documents, with nothing leaving the machine.
    7
    -