The RapidOCR MCP Server provides optical character recognition (OCR) capabilities through an easy-to-use interface. It's based on the RapidOCR library and follows the Model Context Protocol (MCP) specification, allowing for straightforward integration with applications that need text extraction from images.
To install the RapidOCR MCP Server, you'll need to have Python installed on your system. Then run:
pip install rapidocr-mcp
This will install the server and its dependencies.
Once installed, you can start the server using the following command:
uvx run rapidocr-mcp
The server will start and listen for incoming OCR requests.
The RapidOCR MCP Server provides two main methods for text recognition:
Extract text from an image provided as base64-encoded content:
# Example of calling the ocr_by_content method
import base64
import requests
# Load image and convert to base64
with open("image.jpg", "rb") as image_file:
base64_data = base64.b64encode(image_file.read()).decode("utf-8")
# Send request to the server
response = requests.post(
"http://localhost:8000/ocr_by_content",
json={"base64_data": base64_data}
)
# Process results
results = response.json()
for text_content in results:
print(f"Text: {text_content['text']}")
print(f"Position: {text_content['position']}")
Extract text from an image file located on the server's filesystem:
# Example of calling the ocr_by_path method
import requests
# Send request to the server with the path to the image
response = requests.post(
"http://localhost:8000/ocr_by_path",
json={"path": "/path/to/image.jpg"}
)
# Process results
results = response.json()
for text_content in results:
print(f"Text: {text_content['text']}")
print(f"Position: {text_content['position']}")
Both methods return a list of recognized text items. Each item contains:
text
: The recognized text stringposition
: The coordinates of the text in the image (typically in the format [[x1,y1], [x2,y2], [x3,y3], [x4,y4]])By default, the server runs on port 8000. To configure different server parameters, you can set environment variables before starting the server:
# Example of setting a custom port
export MCP_PORT=9000
uvx run rapidocr-mcp
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "rapidocr-mcp" '{"command":"uvx","args":["run","rapidocr-mcp"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"rapidocr-mcp": {
"command": "uvx",
"args": [
"run",
"rapidocr-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"rapidocr-mcp": {
"command": "uvx",
"args": [
"run",
"rapidocr-mcp"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect