Document OCR MCP Server
An AI-powered MCP server that extracts structured data from Indian identity documents (Aadhaar, Passport, PAN, Driving License) using OCR, enabling Claude Desktop to read and process document images locally.
README
šŖŖ Document OCR MCP Server
An AI-powered MCP (Model Context Protocol) server that extracts structured data from Indian identity documents using OCR. Connect it to Claude Desktop and let Claude read your documents!
š Supported Documents
| Document | Extracted Fields |
|---|---|
| šŖŖ Aadhaar Card | Name, DOB, Gender, Aadhaar Number*, Address, Pincode |
| š Passport | Name, Passport Number*, Nationality, DOB, Expiry, Sex, MRZ |
| š PAN Card | Name, Father's Name, DOB, PAN Number* |
| š Driving License | Name, DOB, DL Number*, Validity, Address, Vehicle Classes |
| š Any Image | Raw text + auto-detected document type + key-value pairs |
* Sensitive fields are masked by default for privacy.
š Quick Start
Step 1: Install Tesseract OCR (Windows)
Tesseract must be installed separately ā it's the OCR engine under the hood.
- Download from: https://github.com/UB-Mannheim/tesseract/wiki
- Run the installer (choose Additional script data ā Hindi if needed)
- Default install path:
C:\Program Files\Tesseract-OCR\tesseract.exe - Add to PATH, or set in your environment:
$env:TESSDATA_PREFIX = "C:\Program Files\Tesseract-OCR\tessdata"
Step 2: Install Python Dependencies
cd d:\mcp
pip install -r requirements.txt
Step 3: Test the Server
# Run the MCP Inspector (opens browser UI to test tools)
fastmcp dev server.py
Or test directly:
python server.py
š¤ Connect to Claude Desktop
-
Find your Claude Desktop config file:
C:\Users\<YourName>\AppData\Roaming\Claude\claude_desktop_config.json -
Add this to the config:
{ "mcpServers": { "document-ocr": { "command": "python", "args": ["d:\\mcp\\server.py"] } } } -
Restart Claude Desktop
-
You'll see the š tools icon ā your OCR tools are ready!
š¬ Example Claude Prompts
Once connected, you can ask Claude:
Extract all information from my Aadhaar card at C:/Users/me/aadhaar.jpg
What's the expiry date on my passport? Image is at D:/docs/passport.png
Read the PAN card image at C:/scans/pan.jpg and tell me the PAN number
Auto-detect what type of document this is and extract all fields:
C:/Downloads/document.jpg
Get raw text from this image: C:/photos/certificate.png
š ļø MCP Tools Reference
extract_aadhaar(image_path, show_full=False)
Extract data from Aadhaar card front or back.
extract_passport(image_path, show_full=False)
Extract data from passport bio-data page. Uses MRZ parsing for high accuracy.
extract_pan_card(image_path, show_full=False)
Extract data from PAN card.
extract_driving_license(image_path, show_full=False)
Extract data from Driving License (front side recommended).
extract_any_document(image_path, document_type="auto", show_full=False)
Auto-detect document type and extract accordingly.
ocr_raw_text(image_path, language="eng")
Get raw OCR text from any image. Supports multi-language:
"eng"ā English"hin"ā Hindi"eng+hin"ā English + Hindi"eng+tam"ā English + Tamil
š Privacy & Security
- Aadhaar numbers are masked to
XXXX XXXX 1234by default - PAN numbers are partially masked to
AB*****4Fby default - Passport numbers are partially masked by default
- MRZ lines are redacted by default
- Pass
show_full=Trueto any tool to disable masking - All processing is 100% local ā no data is sent to any cloud service
š Project Structure
d:\mcp\
āāā server.py # FastMCP server (entry point)
āāā requirements.txt # Python dependencies
āāā pyproject.toml # Project config
ā
āāā tools/
ā āāā aadhaar.py # Aadhaar OCR
ā āāā passport.py # Passport OCR + MRZ parser
ā āāā pan_card.py # PAN Card OCR
ā āāā driving_license.py # Driving License OCR
ā āāā generic_ocr.py # Generic + auto-detect OCR
ā
āāā utils/
ā āāā image_preprocess.py # OpenCV preprocessing pipeline
ā āāā validators.py # Pydantic output models
ā āāā privacy.py # PII masking utilities
ā
āāā samples/ # Place test images here
ā ļø Troubleshooting
| Issue | Fix |
|---|---|
TesseractNotFoundError |
Tesseract not in PATH ā see Step 1 above |
| Low accuracy on Hindi text | Install Hindi language pack for Tesseract |
ModuleNotFoundError: fastmcp |
Run pip install -r requirements.txt |
| Image not readable | Check file path is absolute and image is not corrupted |
| Missing fields in output | Image quality too low ā try a higher resolution scan |
š License
MIT License ā free to use and modify.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.