TE

TextIn MCP Server for OCR and Markdown

Extract text and OCR documents with the TextIn MCP server, then convert them into clean Markdown for easy editing and publishing.

Quick Install
npx -y @intsig-textin/textin-mcp

Overview

TextIn MCP Server is a lightweight server implementation that uses the Model Context Protocol (MCP) to orchestrate OCR (optical character recognition) and post-processing pipelines, producing clean Markdown output from images, PDFs, or raw extracted text. The server is intended for developers who need a reproducible, automatable way to convert scanned documents and pictures into editable, semantic Markdown suitable for notes, publishing, or ingestion into downstream systems.

Because document OCR often requires several discrete steps — image preprocessing, layout analysis, OCR, language detection and cleanup — TextIn MCP exposes these functions as composable tools and endpoints. This makes it easier to automate common flows such as receipt digitization, report conversion, and archival of scanned notes while keeping the output readable and Markdown-friendly.

Features

  • OCR pipeline that accepts images and PDFs and returns extracted text.
  • Layout-aware conversion to structured Markdown (headings, lists, tables, code blocks).
  • Pluggable OCR backends (e.g., Tesseract or external OCR services).
  • Image pre-processing (deskew, binarization, cropping) to improve OCR accuracy.
  • Language detection and basic normalization for multilingual documents.
  • HTTP API and MCP-compatible endpoints for integration with LLMs or automation frameworks.
  • Docker-friendly deployment and environment-driven configuration.

Installation / Configuration

Clone the repository, adjust configuration, and run with Docker or locally. Example steps:

  1. Clone the repo
git clone https://github.com/intsig-textin/textin-mcp.git
cd textin-mcp
  1. Create a .env file (example below)
# .env
PORT=8080
OCR_BACKEND=tesseract         # or "remote" for external OCR service
OCR_API_KEY=your_api_key_here # if using an external OCR provider
DATA_DIR=/var/lib/textin-mcp
LOG_LEVEL=info
  1. Run with Docker Compose (example)
# docker-compose.yml
version: "3.8"
services:
  textin-mcp:
    build: .
    ports:
      - "${PORT:-8080}:8080"
    environment:
      - OCR_BACKEND=${OCR_BACKEND}
      - OCR_API_KEY=${OCR_API_KEY}
      - DATA_DIR=${DATA_DIR}
      - LOG_LEVEL=${LOG_LEVEL}
    volumes:
      - ./data:${DATA_DIR}

Start:

docker-compose up --build -d

Run locally (example with Node/Python runtime):

# using npm or pip where the project supports it
npm install
npm run start
# or
pip install -r requirements.txt
python server.py

Environment variables and their purpose:

VariableDefaultDescription
PORT8080HTTP port for the server
OCR_BACKENDtesseractBackend engine: tesseract, remote, etc.
OCR_API_KEYAPI key if using remote OCR
DATA_DIR./dataDirectory for temp files and uploads
LOG_LEVELinfoLogging verbosity

Available Tools

The server exposes a set of modular tools that can be invoked via MCP-compatible calls or via HTTP API:

  • OCR Engine: extracts plain text and confidence metadata from images/PDFs.
  • Preprocessor: image cleanup (deskewing, denoising, binarization).
  • Layout Analyzer: detects headings, paragraphs, tables, and lists.
  • Markdown Converter: converts layout tokens into readable Markdown.
  • Language Detector: identifies document language and routes to appropriate OCR models.
  • Exporter: returns results as JSON, plain text, or Markdown file.

Each tool is implemented as a separate step so you can customize or replace backends without rewriting pipelines.

Use Cases

  • Receipt and invoice ingestion: Automatically OCR receipts, normalize fields (date, total), and produce a Markdown expense entry for bookkeeping.
  • Research article conversion: Convert scanned academic papers to Markdown with preserved headings and code blocks for faster note-taking and annotation.
  • Archival of handwritten notes: Preprocess phone-scanned notes, OCR them, and create a Markdown notebook that can be indexed and searched.
  • Knowledge base population: Feed digitized manuals or reports into a Markdown-based knowledge repo or static site generator.
  • Assistive workflows: Integrate with LLMs that accept MCP tools for richer context-aware post-processing and summarization.

Example API Requests

Below are illustrative examples (adjust endpoints and payloads to your deployment):

Extract text from an image (curl):

curl -X POST "http://localhost:8080/api/ocr" \
  -F "file=@/path/to/scan.jpg" \
  -H "Accept: application/json"

Convert extracted text to Markdown (curl):

curl -X POST "http://localhost:8080/api/convert/markdown" \
  -H "Content-Type: application/json" \
  -d '{"text": "Raw OCR text here", "language": "en"}'

Node.js example:

const fetch = require('node-fetch');
const fs = require('fs');

async function uploadImage(filePath) {
  const form = new FormData();
  form.append('file', fs.createReadStream(filePath));
  const res = await fetch('http://localhost:8080/api/ocr', { method: 'POST', body: form });
  return res.json();
}

Tips & Troubleshooting

  • If OCR quality is poor, enable image preprocessor and try different binarization or deskew settings.
  • For large PDFs, use server-side streaming or chunking to avoid memory spikes.
  • Replace or tune OCR_BACKEND if your documents require handwriting or non-Latin scripts.
  • Monitor logs (LOG_LEVEL) to inspect recognition confidence and layout decisions.

Repository and source code: https://github.com/intsig-textin/textin-mcp

This server is designed to be extended: swap OCR backends, add custom post-processors, or integrate the tools into larger MCP-driven LLM workflows for downstream summarization and knowledge extraction.