OCR MCP
An HTTP MCP server that receives a file and a JSON schema, extracts text via local OCR, and fills the JSON values, with optional LLM fallback for unresolved fields.
README
OCR MCP
An HTTP (Streamable) MCP server written in Node.js that receives a file and a structured JSON object with empty values, extracts the file's content using local OCR / text extraction (no cloud, no API keys), and fills in the JSON values.
Supported file types:
| Type | How it's read |
|---|---|
| Image | Tesseract OCR (tesseract.js) — png, jpg, gif, bmp, tiff, webp |
Embedded text (pdf-parse); falls back to rendering + OCR if scanned |
|
| DOCX | Direct text extraction (mammoth) |
| DOC | Not supported (convert to DOCX/PDF/image) |
How field filling works
Filling happens in two passes:
- Heuristic parser (always on, local). Matches each JSON key to a label in the
document text, e.g. a key
invoiceNumbermatches lines likeInvoice Number: INV-2026orinvoice_number - INV-2026. Nested objects are supported. - LLM fallback (optional). For any field the heuristic could not resolve, a
configured LLM is asked to fill the remaining values from the extracted text. It only
fills still-empty fields and never overrides values already found. Enable it via
.env(see below); leave it disabled to stay fully local.
Fields that remain empty after both passes are returned in an unfilled list.
Requirements
- Node.js 18+ (developed on v24)
Install
npm install
cp .env.example .env # then edit .env if you want the LLM fallback
Configuration (.env)
| Variable | Description |
|---|---|
PORT |
Server port (default 3000). |
MCP_PATH |
MCP endpoint path (default /mcp). |
LLM_PROVIDER |
openai | anthropic | ollama. Empty = LLM fallback disabled. |
LLM_MODEL |
Model name, e.g. gpt-4o-mini, claude-3-5-sonnet-latest, llama3.1. |
LLM_API_KEY |
Provider API key (not required for ollama). |
LLM_BASE_URL |
Optional base URL override. |
Provider defaults for LLM_BASE_URL:
openai→https://api.openai.com/v1anthropic→https://api.anthropic.comollama→http://localhost:11434/v1
openai and ollama use the OpenAI-compatible Chat Completions API; anthropic uses
the Messages API. Any OpenAI-compatible endpoint (Azure OpenAI, LM Studio, vLLM, etc.)
works by pointing LLM_PROVIDER=openai at a custom LLM_BASE_URL.
Run
npm start
# OCR MCP server (Streamable HTTP) listening on http://localhost:3000/mcp
# LLM fallback enabled: openai / gpt-4o-mini (or "disabled")
Health check: GET /health.
MCP tool
fill_json_from_file
| Argument | Type | Required | Description |
|---|---|---|---|
fileBase64 |
string | yes | File content encoded as base64. |
mimeType |
string | one of* | MIME type, e.g. image/png, application/pdf. |
filename |
string | one of* | Original filename, used to detect the type. |
schema |
object | yes | JSON object with the desired keys and empty values. |
language |
string | no | Tesseract language code(s), e.g. ind+eng or eng+fra (default ind+eng). |
* Provide at least one of mimeType or filename.
Returns JSON (as text + structuredContent):
{
"data": { "name": "Acme Corp", "invoiceNumber": "INV-2026", "missingField": "" },
"unfilled": ["missingField"],
"extractedTextLength": 41,
"usedLlm": false
}
usedLlm indicates whether the LLM fallback was invoked. If a fallback call fails, an
llmError field is included and the heuristic result is still returned.
Connecting from an MCP client
Point a Streamable-HTTP-capable MCP client at http://localhost:3000/mcp. Example VS
Code mcp.json:
{
"servers": {
"ocr": {
"type": "http",
"url": "http://localhost:3000/mcp"
}
}
}
Example (raw HTTP)
# 1. initialize -> read the mcp-session-id response header
# 2. POST notifications/initialized with that session id
# 3. POST tools/call with the base64 file + schema
# See the curl handshake used in development; Accept must include
# "application/json, text/event-stream".
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。