Sponsored by Deepsite.site

Mistral OCR MCP Server

Created By
sathizz77 months ago
Mcp ocr server
Content

Mistral OCR MCP Server

A local OCR server using Mistral OCR, compliant with MCP principles. This server allows you to perform OCR on uploaded images and interact with it via a Model Context Protocol (MCP) interface.

Features

  • FastAPI Backend: Built with the modern, fast (high-performance) FastAPI framework.
  • OCR Processing: (Details about the specific Mistral OCR capabilities would go here - e.g., supported languages, image formats, accuracy).
  • Standard OCR Endpoint: Provides a regular HTTP endpoint (/v1/ocr) for direct file uploads and OCR.
  • Configuration Management: Uses Pydantic settings for easy configuration.
  • Logging: Integrated logging for monitoring and debugging.
  • Health Check: A simple /health endpoint to verify server status.

Project Structure

.
├── .gitignore
├── main.py                 # FastAPI application and MCP server setup
├── pyproject.toml          # Project metadata and dependencies
├── README.md               # This file
├── ocr/
│   ├── __init__.py
│   ├── config.py           # Configuration settings
│   ├── router.py           # Handles the OCR model routing and processing logic
│   ├── schemas.py          # Pydantic models for API requests and responses
│   └── adapters/           # (If you have model-specific adapter logic)
│       └── __init__.py
└── tests/                  # (If you have tests)
    └── ...

Prerequisites

  • Python 3.10 or higher
  • An environment with pip or uv for package management.

Installation

  1. Clone the repository (if applicable):

    # git clone <your-repository-url>
    # cd mistral-ocr-mcp-server
    
  2. Create and activate a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies: The project uses pyproject.toml to manage dependencies. You can install them using pip:

    pip install .
    

    For development, including tools for testing, linting, and formatting, install the dev extras:

    pip install .[dev]
    

Configuration

Configuration for the application (like supported file types, model settings, etc.) is managed in ocr/config.py using Pydantic settings. You can override these settings using environment variables. Refer to ocr/config.py for available settings and their corresponding environment variable names.

Default supported file types usually include common image formats (e.g., image/jpeg, image/png).

The maximum upload file size is set by default (e.g., 1MB in main.py lifespan function).

Running the Server

You can run the FastAPI server using Uvicorn:

uvicorn main:app --reload

This will typically start the server on http://127.0.0.1:8000. The --reload flag enables auto-reloading when code changes are detected, which is useful for development.

API Endpoints

1. OCR Endpoint

  • POST /v1/ocr
    • Description: Upload an image file to perform OCR.
    • Request Body: multipart/form-data with a file field containing the image.
    • Content-Type Header for file: Must be one of the settings.supported_file_types.
    • Response: OCRResult (JSON object containing the extracted text and other relevant information as defined in ocr.schemas.OCRResult).
    • Example using cURL:
      curl -X POST -F "file=@/path/to/your/image.png" http://127.0.0.1:8000/v1/ocr
      

2. MCP Endpoint

  • BASE_URL/mcp
    • Description: Provides MCP-compliant tools for interacting with the OCR service. The available tools and resources can be discovered by MCP clients.
    • This endpoint is automatically managed by fastapi-mcp.

3. Health Check

  • GET /health
    • Description: A simple endpoint to check if the server is running and healthy.
    • Response:
      {
        "status": "ok"
      }
      

Development

Running Type Checker

To check types with Mypy:

mypy .

(Ensure Mypy is configured in pyproject.toml to scan the correct paths, e.g., mypy ocr main.py)

Running Tests

If you have tests in a tests/ directory, you can run them using Pytest:

pytest

Coverage reports can also be generated if configured (see tool.pytest.ini_options in pyproject.toml).

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an issue. (Add more specific contribution guidelines if you have them).

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Playwright McpPlaywright MCP server
ChatWiseThe second fastest AI chatbot™
WindsurfThe new purpose-built IDE to harness magic
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
CursorThe AI Code Editor
DeepChatYour AI Partner on Desktop
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Amap Maps高德地图官方 MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Tavily Mcp
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Serper MCP ServerA Serper MCP Server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.