Skip to main content

Mistral OCR

Project description

Mistral OCR MCP Server

A Model Context Protocol (MCP) server that provides OCR (Optical Character Recognition) functionality using Mistral's OCR API. This server allows you to extract text content from PDF files and images through MCP-compatible clients like Cursor and Claude Desktop.

📖 For more context and practical usage examples, read the related article: How I Use Mistral Document AI to Consolidate My Notes

Usage example flowchart

flow

Features

  • Extract text from PDF files and images (JPG, JPEG, PNG, TIFF, BMP)
  • Returns structured content with page-by-page breakdown
  • Integrates seamlessly with MCP clients
  • Built with FastMCP for optimal performance

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/lemopian/mistral-ocr-mcp.git
    cd mistral-ocr-mcp
    
  2. Install dependencies using uv:

    uv sync
    
  3. Set up environment variables: Create a .env file in the project root:

    echo "MISTRAL_API_KEY=your_mistral_api_key_here" > .env
    

Configuration for MCP Clients

Add the following configuration to your MCP client config file:

{
  "mcpServers": {
    "mistral-ocr": {
      "command": "/Users/yourusername/.local/bin/uv",
      "args": [
        "--directory",
        "/path/to/mistral-ocr-mcp",
        "run",
        "main.py"
      ]
    }
  }
}

Important: Replace /path/to/mistral-ocr-mcp with the actual path to your cloned repository.

Usage

Once configured, the server provides the following tool:

extract_file_content

Extracts text content from PDF files and images.

Parameters:

  • file_path (string): Local path to the PDF or image file

Returns:

  • Extracted text content as a string

Supported formats:

  • PDF files (.pdf)
  • Image files (.jpg, .jpeg, .png, .tiff, .bmp)

Example usage :

Please extract the text from this document: /path/to/your/document.pdf

Development

Running the server directly

uv run main.py

Project structure

mistral-ocr-mcp/
├── mistral_ocr/          # Package directory
│   ├── __init__.py       # Package initialization
│   └── extractor.py      # Mistral OCR functionality
├── docs/                 # Documentation
│   └── flowchart.png     # Architecture flowchart
├── main.py               # MCP server implementation
├── pyproject.toml        # Project dependencies and configuration
├── uv.lock              # Dependency lock file
├── .env                 # Environment variables (create this)
├── .gitignore           # Git ignore rules
└── README.md            # This file

Environment Variables

  • MISTRAL_API_KEY: Your Mistral API key (required)

Troubleshooting

  1. "MISTRAL_API_KEY must be set" error:

    • Ensure you've created a .env file with your Mistral API key
    • Verify the API key is valid
  2. "File not found" error:

    • Check that the file path is correct and accessible
    • Ensure the file format is supported
  3. MCP connection issues:

    • Verify the path to uv is correct in your MCP configuration
    • Ensure the repository path is absolute and correct
    • Check that all dependencies are installed with uv sync

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_lemopian_mistral_ocr-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_lemopian_mistral_ocr-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_lemopian_mistral_ocr-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_lemopian_mistral_ocr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a707a4145d5c67846b2ba97f8279d4017039c7fb09e1a3059aa4048e51619cc2
MD5 9884eaa3a8e614a84c25bc91f1f5a6f4
BLAKE2b-256 01de133c3b59eba2277040150b3aed15fb914d2c0cfd43cc1bc44c9a92b50ff5

See more details on using hashes here.

File details

Details for the file iflow_mcp_lemopian_mistral_ocr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_lemopian_mistral_ocr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_lemopian_mistral_ocr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e660d554bdd403044974366700b89b88891131fbfefe1c019ea9d5f03017bfad
MD5 1cd287a9ea3e54d03ebe7d68ca78fc9e
BLAKE2b-256 c6a31015c7340d71e9a457318718f7ff46ac35d7c7e5d818fbbecd884c5a3507

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page