Tesseract PDF MCP Server
Provides OCR capabilities to extract text from PDF documents using Tesseract, with support for multiple languages including English and Simplified Chinese.
README
Tesseract PDF MCP Server
A Model Context Protocol (MCP) server that provides OCR capabilities for PDF documents using Tesseract OCR. This server allows AI assistants to extract text from PDF files, supporting multiple languages including English and Simplified Chinese out of the box.
Features
- PDF to Text Conversion: Extract text from PDF documents using OCR technology
- Multi-language Support: Process documents in multiple languages (English and Simplified Chinese by default)
- Dockerized Solution: Easy deployment with Docker
- MCP Integration: Seamlessly integrates with AI assistants that support the Model Context Protocol
Prerequisites
- Docker installed on your system
Build Instructions
Build the Docker image with the following command:
docker build -t tesseract-pdf-mcp .
Running the Server
Run the MCP server with the following command:
docker run -it --rm \
-v /path/to/your/pdfs:/pdfs \
tesseract-pdf-mcp
Important Notes:
- The
-v /path/to/your/pdfs:/pdfsoption mounts a volume from your host system to the Docker container, allowing the server to access PDF files. - Replace
/path/to/your/pdfswith the actual path to the directory containing your PDF files. - The server will be accessible via standard input/output (stdio) as specified in the MCP protocol.
Usage
The server provides a tool called convert_pdf that can be used to extract text from PDF files.
Input
The convert_pdf tool accepts the following JSON input:
{
"file_path": "/pdfs/document.pdf",
"language": "eng"
}
Parameters:
file_path(required): Path to the PDF file to process. This should be the path inside the container (e.g.,/pdfs/document.pdf).language(optional): Language for OCR processing. Default is"eng"(English).- Available languages by default:
"eng"(English),"chi_sim"(Simplified Chinese)
- Available languages by default:
Output
The tool returns a JSON response with the following structure:
{
"status": "success",
"output_path": "/pdfs/document.txt"
}
On success:
status: Will be"success"output_path: The absolute path to the generated text file
On error:
status: Will be"error"message: Error descriptionoutput_path: Will benull
Example Usage
When connected to an AI assistant that supports MCP:
- The assistant can use the
convert_pdftool to extract text from a PDF file - The text file will be created in the same directory as the PDF file
- The assistant can then access the text file to analyze its contents
Connecting to AI Tools
To connect this MCP server to AI tools that support the Model Context Protocol, you'll need to configure the tool with the appropriate settings.
Configuration Example
Add the following configuration to your AI tool's settings:
{
"mcpServers": {
"tesseract-pdf-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"/path/to/your/pdfs:/pdfs",
"tesseract-pdf-mcp"
],
"disabled": false,
"autoApprove": []
}
}
}
Make sure to replace /path/to/your/pdfs with the actual path to your PDF files directory.
Usage with AI Tools
Once connected:
- The AI tool will have access to the
convert_pdftool provided by this MCP server - You can ask the AI to extract text from PDF documents
- The AI will use the MCP server to process the PDFs and access the resulting text
Adding More Languages
The server comes with English (eng) and Simplified Chinese (chi_sim) language support by default. To add more languages:
- Modify the
Dockerfileby adding additional language packs to theapt-get installcommand:
RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-chi-sim \
tesseract-ocr-fra \ # Add French
tesseract-ocr-deu \ # Add German
tesseract-ocr-spa \ # Add Spanish
poppler-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
- Rebuild the Docker image:
docker build -t tesseract-pdf-mcp .
Available Language Codes
Some common language codes for Tesseract OCR:
eng: Englishchi_sim: Simplified Chinesechi_tra: Traditional Chinesefra: Frenchdeu: Germanspa: Spanishita: Italianjpn: Japanesekor: Koreanrus: Russian
For a complete list of available language packs, refer to the Tesseract documentation.
Debugging Inside the Container
If you need to debug or test the PDF conversion logic directly inside the container, follow these steps:
Starting an Interactive Shell
Launch an interactive shell session in the container with the following command:
docker run --rm -it -v /path/to/your/pdfs:/data tesseract-pdf-mcp /bin/bash
This command:
- Creates a container from the
tesseract-pdf-mcpimage - Mounts your local PDF directory to
/datainside the container - Overrides the default command to start a bash shell
- Removes the container automatically when you exit (
--rm)
Working Inside the Container
Once inside the container's shell, you can:
- Navigate the filesystem using standard Linux commands (
cd,ls, etc.) - Access your mounted PDFs in the
/datadirectory - Run Python scripts or start an interactive Python session
Testing the Conversion Function
You can test the PDF to text conversion directly using Python's interactive shell:
# Start Python interactive shell
python3
# Import the conversion function
from ocr.converter import pdf_to_text
# Process a PDF file (replace with your actual filename)
output_path = pdf_to_text('/data/my_document.pdf', lang='eng')
# Verify the result
print(f"Conversion successful. Output saved to: {output_path}")
# Exit Python shell
exit()
The converted text file will be saved in the same directory as your PDF file (in the /data directory), making it accessible from your host machine as well.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。