docs/version3.x/deployment/mcp_server.en.md
PaddleOCR provides a lightweight Model Context Protocol (MCP) server designed to integrate PaddleOCR’s text recognition, layout parsing, and other capabilities into various large-model applications.
The following showcases creative use cases built with PaddleOCR MCP server combined with other tools:
In Claude for Desktop, extract handwritten content from images and save to note-taking software Notion. The PaddleOCR MCP server extracts text, formulas and other information from images while preserving document structure.
<div align="center"> </div>In VSCode, convert handwritten ideas or pseudocode into runnable Python scripts that comply with project coding standards with one click, and upload them to GitHub repositories. The PaddleOCR MCP server extracts explicitly handwritten code from images for subsequent processing.
<div align="center"> </div>In Claude for Desktop, convert PDF documents or images containing complex tables, formulas, handwritten text and other content into locally editable files.
Convert complex PDF documents with tables and watermarks to editable doc/Word format:
<div align="center"> </div>Convert images containing formulas and tables to editable csv/Excel format:
<div align="center"> </div>This section explains how to install the paddleocr-mcp library via pip.
paddleocr-mcp, you also need to install the PaddlePaddle framework and PaddleOCR by referring to the PaddleOCR installation guide.paddleocr-mcp[local]: includes PaddleOCR (without the PaddlePaddle framework).paddleocr-mcp[local-cpu]: based on local, additionally includes the CPU version of the PaddlePaddle framework.uvx. For details, please refer to the instructions in 2. Using with Claude for Desktop.To install paddleocr-mcp using pip:
# Install from PyPI
pip install -U paddleocr-mcp
# Install from source
git clone https://github.com/PaddlePaddle/PaddleOCR.git
pip install -e mcp_server
# Install with optional extras (choose ONE of the following if you prefer convenience installs)
# Install PaddleOCR together with the MCP server (framework not included):
pip install "paddleocr-mcp[local]"
# Install PaddleOCR and CPU PaddlePaddle framework together:
pip install "paddleocr-mcp[local-cpu]"
To verify successful installation:
paddleocr_mcp --help
If the help message is printed, the installation succeeded.
This section explains how to use the PaddleOCR MCP server within Claude for Desktop. The steps are also applicable to other MCP hosts with minor adjustments.
Install paddleocr-mcp
Refer to 1. Installation. To avoid dependency conflicts, it is strongly recommended to install in an isolated virtual environment.
Install PaddleOCR
Install the PaddlePaddle framework and PaddleOCR, as per the PaddleOCR installation documentation.
Add MCP Server Configuration
Locate the claude_desktop_config.json configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.jsonEdit the file as follows:
{
"mcpServers": {
"paddleocr": {
"command": "paddleocr_mcp",
"args": [],
"env": {
"PADDLEOCR_MCP_PIPELINE": "OCR",
"PADDLEOCR_MCP_PPOCR_SOURCE": "local"
}
}
}
}
Notes:
PADDLEOCR_MCP_PIPELINE should be set to the pipeline name. See Section 4 for more details.
PADDLEOCR_MCP_PIPELINE_CONFIG is optional; if not set, the default pipeline configuration will be used. If you need to adjust the configuration, such as changing the model, please refer to the PaddleOCR documentation to export the pipeline configuration file, and set PADDLEOCR_MCP_PIPELINE_CONFIG to the absolute path of this configuration file.
Inference Performance Tips:
If you encounter issues such as long inference time or insufficient memory during use, you may consider adjusting the pipeline configuration according to the following recommendations.
OCR Pipeline: It is recommended to switch to the mobile series models. For example, you can modify the pipeline configuration file to use PP-OCRv5_mobile_det for detection and PP-OCRv5_mobile_rec for recognition.
PP-StructureV3 Pipeline:
use_formula_recognition to False to disable formula recognition.mobile version or switching to a lightweight formula recognition model like PP-FormulaNet-S.The following sample code can be used to obtain the pipeline configuration file, in which most optional features of the PP-StructureV3 pipeline are disabled, and some key models are replaced with lightweight versions.
from paddleocr import PPStructureV3
pipeline = PPStructureV3(
use_doc_orientation_classify=False, # Disable document image orientation classification
use_doc_unwarping=False, # Disable text image unwarping
use_textline_orientation=False, # Disable text line orientation classification
use_formula_recognition=False, # Disable formula recognition
use_seal_recognition=False, # Disable seal text recognition
use_table_recognition=False, # Disable table recognition
use_chart_recognition=False, # Disable chart parsing
# Use lightweight models
text_detection_model_name="PP-OCRv5_mobile_det",
text_recognition_model_name="PP-OCRv5_mobile_rec",
layout_detection_model_name="PP-DocLayout-S",
)
# The configuration file is saved to `PP-StructureV3.yaml`
pipeline.export_paddlex_config_to_yaml("PP-StructureV3.yaml")
For PaddleOCR-VL series, it is note recommended to use CPUs for inference.
Important:
paddleocr_mcp is not in your system's PATH, set command to the absolute path of the executable.Restart the MCP Host
Restart Claude for Desktop. The paddleocr server should now be available in the application.
In the configuration file for Claude for Desktop, you need to define how the MCP server is started. The key fields are as follows:
command: paddleocr_mcp (if the executable can be found in the PATH) or the absolute path.args: Configurable command-line arguments, such as ["--verbose"]. See 4. Parameter Reference for details.env: Configurable environment variables. See 4. Parameter Reference for details.You can configure the MCP server according to your requirements to run in different working modes. The operational procedures vary for different modes, which will be explained in detail below.
See 2.1 Quick Start.
Install paddleocr-mcp.
Obtain the service base URL and AI Studio Community access token.
On this page, click "API" in the upper-left corner. Copy the API_URL corresponding to "Text Recognition (PP-OCRv5)", and remove the trailing endpoint (/ocr) to get the base URL of the service (e.g., https://xxxxxx.aistudio-app.com). Also copy the TOKEN, which is your access token. You may need to register and log in to your PaddlePaddle AI Studio Community account.
Refer to the configuration example below to modify the contents of the claude_desktop_config.json file.
Restart the MCP host.
Configuration example:
{
"mcpServers": {
"paddleocr": {
"command": "paddleocr_mcp",
"args": [],
"env": {
"PADDLEOCR_MCP_PIPELINE": "OCR",
"PADDLEOCR_MCP_PPOCR_SOURCE": "aistudio",
"PADDLEOCR_MCP_SERVER_URL": "<your-server-url>",
"PADDLEOCR_MCP_AISTUDIO_ACCESS_TOKEN": "<your-access-token>"
}
}
}
}
Notes:
PADDLEOCR_MCP_PIPELINE should be set to the pipeline name. See Section 4 for more details.<your-server-url> with your service base URL.<your-access-token> with your access token.Important:
paddleocr-mcp.claude_desktop_config.json file according to the configuration example below. Set PADDLEOCR_MCP_QIANFAN_API_KEY to your Qianfan platform API key.Configuration example:
{
"mcpServers": {
"paddleocr": {
"command": "paddleocr_mcp",
"args": [],
"env": {
"PADDLEOCR_MCP_PIPELINE": "PaddleOCR-VL",
"PADDLEOCR_MCP_PPOCR_SOURCE": "qianfan",
"PADDLEOCR_MCP_SERVER_URL": "https://qianfan.baidubce.com/v2/ocr",
"PADDLEOCR_MCP_QIANFAN_API_KEY": "<your-api-key>"
}
}
}
}
Note:
PADDLEOCR_MCP_PIPELINE should be set to the pipeline name. See Section 4 for more details. The Qianfan platform service currently only supports PP-StructureV3 and PaddleOCR-VL.paddleocr-mcp where the MCP server will run.claude_desktop_config.json file. Set PADDLEOCR_MCP_SERVER_URL (e.g., "http://127.0.0.1:8000").Configuration example:
{
"mcpServers": {
"paddleocr": {
"command": "paddleocr_mcp",
"args": [],
"env": {
"PADDLEOCR_MCP_PIPELINE": "OCR",
"PADDLEOCR_MCP_PPOCR_SOURCE": "self_hosted",
"PADDLEOCR_MCP_SERVER_URL": "<your-server-url>"
}
}
}
}
Note:
PADDLEOCR_MCP_PIPELINE should be set to the pipeline name. See Section 4 for more details.<your-server-url> with your service’s base URL (e.g., http://127.0.0.1:8000).uvxPaddleOCR also supports starting the MCP server via uvx. With this approach, manual installation of paddleocr-mcp is not required. The main steps are as follows:
claude_desktop_config.json. Examples:Self-hosted mode:
```json
{
"mcpServers": {
"paddleocr": {
"command": "uvx",
"args": [
"--from",
"paddleocr-mcp",
"paddleocr_mcp"
],
"env": {
"PADDLEOCR_MCP_PIPELINE": "OCR",
"PADDLEOCR_MCP_PPOCR_SOURCE": "self_hosted",
"PADDLEOCR_MCP_SERVER_URL": "<your-server-url>"
}
}
}
}
```
Local mode (inference on CPUs, using the `local-cpu` extra):
```json
{
"mcpServers": {
"paddleocr": {
"command": "uvx",
"args": [
"--from",
"paddleocr_mcp[local-cpu]",
"paddleocr_mcp"
],
"env": {
"PADDLEOCR_MCP_PIPELINE": "OCR",
"PADDLEOCR_MCP_PPOCR_SOURCE": "local"
}
}
}
}
```
For information on local mode dependencies, performance tuning, and production configuration, please refer to the [3.1 Quick Start](#21-quick-start) section.
Due to the use of a different startup method, the `command` and `args` settings in the configuration file differ from the previously described approach. However, the command-line arguments and environment variables supported by the MCP service (such as `PADDLEOCR_MCP_SERVER_URL`) can still be set in the same way.
In addition to MCP hosts like Claude for Desktop, you can also run the PaddleOCR MCP server via the CLI.
To view help:
paddleocr_mcp --help
Example commands:
# OCR + PaddleOCR official service + stdio
PADDLEOCR_MCP_AISTUDIO_ACCESS_TOKEN=xxxxxx paddleocr_mcp --pipeline OCR --ppocr_source aistudio --server_url https://xxxxxx.aistudio-hub.baidu.com
# PP-StructureV3 + local Python library + stdio
paddleocr_mcp --pipeline PP-StructureV3 --ppocr_source local
# OCR + self-hosted service + Streamable HTTP
paddleocr_mcp --pipeline OCR --ppocr_source self_hosted --server_url http://127.0.0.1:8080 --http
You can find all the supported parameters of the PaddleOCR MCP server in 4. Parameter Reference.
You can control the MCP server via environment variables or CLI arguments.
| Environment Variable | CLI Argument | Type | Description | Options | Default |
|---|---|---|---|---|---|
PADDLEOCR_MCP_PIPELINE | --pipeline | str | Pipeline to run. | "OCR", "PP-StructureV3", "PaddleOCR-VL", "PaddleOCR-VL-1.5" | "OCR" |
PADDLEOCR_MCP_PPOCR_SOURCE | --ppocr_source | str | Source of PaddleOCR capabilities. | "local" (local Python library), "aistudio" (PaddleOCR official service), "qianfan" (Qianfan platform service), "self_hosted" (self-hosted service) | "local" |
PADDLEOCR_MCP_SERVER_URL | --server_url | str | Base URL for the underlying service (required for aistudio, qianfan, or self_hosted modes). | - | None |
PADDLEOCR_MCP_AISTUDIO_ACCESS_TOKEN | --aistudio_access_token | str | AI Studio access token (required for aistudio mode). | - | None |
PADDLEOCR_MCP_TIMEOUT | --timeout | int | Read timeout for the underlying requests (seconds). | - | 60 |
PADDLEOCR_MCP_DEVICE | --device | str | Device for inference (local mode only). | - | None |
PADDLEOCR_MCP_PIPELINE_CONFIG | --pipeline_config | str | Path to pipeline config file (local mode only). | - | None |
| - | --http | bool | Use Streamable HTTP instead of stdio (for remote/multi-client use). | - | False |
| - | --host | str | Host for the Stremable HTTP mode. | - | "127.0.0.1" |
| - | --port | int | Port for the Streamable HTTP mode. | - | 8000 |
| - | --verbose | bool | Enable verbose logging for debugging. | - | False |
file_type prompt, and may fail to process some complex URLs.