npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fatih0411/mistral-ocr

v0.1.0

Published

PDF data extracting

Readme

Creating Custom MCP Servers (with Mistral OCR Example)

Overview

This guide explains how to create custom Model Context Protocol (MCP) servers, focusing on a Python implementation style inspired by the "Claude Reads LinkedIn Profiles" YouTube tutorial. It also includes a real-world example: a custom MCP server that wraps the Mistral OCR API.


1. What is an MCP Server?

An MCP server exposes tools and resources to extend AI assistants like Claude, Cursor, or WindSurf. It acts as a bridge to APIs, databases, or custom logic.


2. Prerequisites

  • Python 3.8+
  • uv package manager (recommended, replaces pip/venv)
  • mcp-cli Python SDK
  • httpx for async HTTP requests
  • Mistral API key

3. Setup Environment

# Create project directory
mkdir mistral-ocr-mcp-server
cd mistral-ocr-mcp-server

# Initialize virtual environment
uv venv

# Activate environment
source .venv/bin/activate  # macOS/Linux
# .\.venv\Scripts\activate  # Windows

# Install dependencies
uv pip install mcp-cli httpx python-dotenv mistralai

4. MCP Server Implementation (Python)

4.1. Environment Variables

Create a .env file:

MISTRAL_API_KEY=LybX5GSEXVmDEeQjlEZyTUog5tUmmqcO

4.2. Server Code (server.py)

import os
import asyncio
from dotenv import load_dotenv
import httpx
from mistralai import Mistral
from mcp import fast_mcp, tool, run, Stdio

load_dotenv()
api_key = os.environ["MISTRAL_API_KEY"]
client = Mistral(api_key=api_key)

mcp_server = fast_mcp(
    name="mistral-ocr-server",
    description="MCP server for Mistral OCR API"
)

@tool(
    name="extract_ocr_from_file",
    description="Upload a PDF/image, perform OCR, and return extracted text",
    input_schema={
        "type": "object",
        "properties": {
            "file_path": {
                "type": "string",
                "description": "Local path to the PDF or image file"
            }
        },
        "required": ["file_path"]
    }
)
async def extract_ocr_from_file(file_path: str):
    # Upload file
    with open(file_path, "rb") as f:
        uploaded_pdf = client.files.upload(
            file={
                "file_name": os.path.basename(file_path),
                "content": f
            },
            purpose="ocr"
        )
    # Get signed URL
    signed_url = client.files.get_signed_url(file_id=uploaded_pdf.id)
    # Perform OCR
    ocr_response = client.ocr.process(
        model="mistral-ocr-latest",
        document={
            "type": "document_url",
            "document_url": signed_url.url
        },
        include_image_base64=False
    )
    return ocr_response

if __name__ == "__main__":
    asyncio.run(run(mcp_server, transport=Stdio()))

5. Configure MCP Client

Edit your MCP settings file:

/Users/macbook202201/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

Add:

{
  "mcpServers": {
    "mistral-ocr-server": {
      "command": "/path/to/uv",  // Use `which uv` to get path
      "args": [
        "run",
        "/Users/macbook202201/Documents/Cline/MCP/mistral-ocr-mcp-server/server.py"
      ],
      "env": {
        "MISTRAL_API_KEY": "LybX5GSEXVmDEeQjlEZyTUog5tUmmqcO"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

6. Usage

Once configured and running, the MCP server exposes a tool:

extract_ocr_from_file

  • Input: { "file_path": "/path/to/your/document.pdf" }
  • Output: OCR result JSON from Mistral API.

7. Notes

  • You can extend this server with more tools (e.g., chat with document, batch OCR).
  • The same approach applies to other APIs.
  • Inspired by the YouTube tutorial's Python style: uv, mcp-cli, decorators, async HTTP.

8. References