MCP Mistral OCR
Provides OCR capabilities for images and PDFs using Mistral AI's OCR API, supporting both local files and URLs with output in markdown or JSON format.
README
MCP Mistral OCR
An MCP server that provides OCR capabilities using Mistral AI's OCR API. Supports stdio (for Claude Desktop / Smithery) and streamable HTTP (for remote clients). Runs with or without Docker.
Features
- Dual transport: streamable HTTP (default) or stdio for Claude Desktop / Smithery
- Process local files (images and PDFs) and files from URLs
- Primary flow: Call
process_url_filewith a URL to get OCR output (markdown or full JSON) - No Docker required: run locally with
uv runand optionalOCR_DIR - Results saved as timestamped
.json(full Mistral response) and.md(extracted markdown) inOCR_DIR/output/(optional; setOCR_SAVE_RESULTS=falseto disable). When saving is on, the tool returns only the download links (over HTTP) or file paths (over stdio): no full content in the response. Over streamable HTTP, use the returned URLs to download the JSON and Markdown files (e.g.http://127.0.0.1:8000/output/<filename>.json). - Docker optional for deployment
Usage
The main use case is URL in, OCR out. Call the process_url_file tool with a document or image URL. You can omit file_type if the URL has a .pdf or image extension (e.g. .jpg, .png). Use output_format="markdown" to get only the extracted text, or output_format="full" (default) for the full Mistral response JSON.
Download URLs: To get clickable "Download JSON" and "Download Markdown" URLs in the tool response, set OCR_DOWNLOAD_BASE_URL (e.g. in .env). Use a different port than the MCP server (e.g. 8001) so they don't conflict. One-command start: from the project root run uv run python run_servers.py to start both the file server (8001) and the MCP server (8000); Ctrl+C stops both.
Google Drive: View/share links (e.g. https://drive.google.com/file/d/FILE_ID/view?usp=sharing) are supported. The server rewrites them to the direct-download URL so the OCR API receives the file content. For Drive links, file_type can be omitted and defaults to pdf; for images in Drive, pass file_type="image". URLs are trimmed before detection. File type inference: If the URL has no extension and is not a known Drive link, the server sends a HEAD request to the URL and infers type from the Content-Type header (e.g. application/pdf → pdf); if still unknown, it defaults to pdf so the first API call usually succeeds without requiring file_type.
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
MISTRAL_API_KEY |
Yes | — | Your Mistral AI API key |
OCR_DIR |
No | ./ocr_data |
Directory for local files and output/ subdir |
OCR_SAVE_RESULTS |
No | true |
Set to false to disable saving results to OCR_DIR/output/ |
OCR_DOWNLOAD_BASE_URL |
No | — | Base URL for download links. Use a port other than MCP (e.g. http://127.0.0.1:8001). Run python -m http.server 8001 --directory ocr_data from project root so GET /output/<filename> serves the files. |
MCP_TRANSPORT |
No | streamable-http |
stdio or streamable-http |
MCP_HTTP_HOST |
No | 127.0.0.1 |
Bind host when using streamable HTTP |
MCP_HTTP_PORT |
No | 8000 |
Port when using Streamable HTTP or SSE |
MCP_HTTP_PATH |
No | mcp |
URL path (e.g. /mcp → http://host:8000/mcp) |
Running without Docker
Python: This project uses Python 3.10–3.13 (not 3.14+) so dependencies like pydantic-core use pre-built wheels. If you only have Python 3.14, install 3.12 (e.g. from python.org) and run:
uv sync --python 3.12
Stdio (e.g. Claude Desktop, Smithery)
- Install uv and run:
cd mistral-ocr-mcp
uv sync
-
Set
MISTRAL_API_KEYand optionallyOCR_DIR(defaults to./ocr_data). -
Run the server (stdio):
# Windows (PowerShell)
$env:MISTRAL_API_KEY="your_key"
uv run python -m src.main
# Windows (CMD) / Unix
set MISTRAL_API_KEY=your_key # CMD
export MISTRAL_API_KEY=your_key # Bash
uv run python -m src.main
Or with a custom OCR directory:
export OCR_DIR=/path/to/your/files # or set on Windows
uv run python -m src.main
Streamable HTTP (for MCP Inspector, HTTP clients)
Start the server with streamable HTTP:
export MISTRAL_API_KEY=your_key
export MCP_TRANSPORT=streamable-http
export MCP_HTTP_PORT=8000
uv run python -m src.main
Then connect clients to http://127.0.0.1:8000/mcp (Streamable HTTP; e.g. MCP Inspector: npx -y @modelcontextprotocol/inspector).
Optional: bind all interfaces and custom path:
export MCP_TRANSPORT=streamable-http
export MCP_HTTP_HOST=0.0.0.0
export MCP_HTTP_PORT=8000
export MCP_HTTP_PATH=/mcp
uv run python -m src.main
Claude Desktop configuration
Option A: No Docker (stdio)
Point Claude to the project and use stdio:
{
"mcpServers": {
"mistral-ocr": {
"command": "uv",
"args": ["run", "python", "-m", "src.main"],
"cwd": "C:\\path\\to\\mistral-ocr-mcp",
"env": {
"MISTRAL_API_KEY": "<YOUR_MISTRAL_API_KEY>",
"MCP_TRANSPORT": "stdio",
"OCR_DIR": "C:\\path\\to\\your\\files"
}
}
}
}
(Adjust cwd and OCR_DIR for your machine. Omit OCR_DIR to use default ./ocr_data.)
Option B: Docker (stdio)
{
"mcpServers": {
"mistral-ocr": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"MISTRAL_API_KEY",
"-e",
"OCR_DIR",
"-v",
"C:/path/to/your/files:/data/ocr",
"mcp-mistral-ocr:latest"
],
"env": {
"MISTRAL_API_KEY": "<YOUR_MISTRAL_API_KEY>",
"OCR_DIR": "C:/path/to/your/files"
}
}
}
}
Build and run:
docker build -t mcp-mistral-ocr .
docker run -e MISTRAL_API_KEY=your_key -e OCR_DIR=/data/ocr -v C:/path/to/files:/data/ocr mcp-mistral-ocr
Smithery
Install via Smithery (stdio):
npx -y @smithery/cli install @everaldo/mcp/mistral-crosswalk --client claude
Available tools
- process_url_file(url, file_type=None, output_format="full", pages=None, table_format=None, extract_header=False, extract_footer=False) – Primary tool: process a file from a URL.
file_typeis optional if the URL has a.pdfor image extension.output_format:"full"(default) returns full JSON;"markdown"returns only the extracted text.pages: optional list of 0-based page indices to process.table_format:"markdown"or"html"for tables.extract_header/extract_footer: set toTrueto extract header/footer. - process_local_file(filename, output_format="full", pages=None, table_format=None, extract_header=False, extract_footer=False) – Process a file from
OCR_DIR(e.g.document.pdf,image.png). Same optional parameters as above.
Limits: 50MB max file size, 1000 pages (Mistral API).
Output
When OCR_SAVE_RESULTS is true (default), results are written to OCR_DIR/output/ as JSON:
- Local:
{filename_stem}_{YYYYMMDD_HHMMSS}.json - URL:
{url_path_stem}_{timestamp}.jsonorurl_document_{timestamp}.json
Set OCR_SAVE_RESULTS=false to return OCR only to the client without writing files.
Supported file types
- Images: JPG, JPEG, PNG, GIF, WebP
- Documents: PDF and other formats supported by Mistral OCR
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。