Get the FREE Ultimate OpenClaw Setup Guide →

opencv

OpenCV MCP Server provides OpenCV's image and video processing capabilities through the Model Context Protocol (MCP). Access powerful computer vision tools for tasks ranging from basic image manipulation to advanced object detection and tracking.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio gongrzhe-opencv-mcp-server uvx opencv-mcp-server \
  --env MCP_TRANSPORT="Transport method (default: stdio)" \
  --env CV_HAAR_CASCADE_DIR="Directory for Haar cascade files (optional)" \
  --env OPENCV_DNN_MODELS_DIR="Directory for storing DNN models (default: ./models)"

How to use

The OpenCV MCP Server provides a suite of computer vision tools exposed through the MCP interface. It enables AI assistants and language models to perform image and video processing tasks using OpenCV, including image manipulation, color-space conversions, resizing, edge detection, contour analysis, and object detection with pre-configured DNN models (such as face detection and YOLO-based object detection). The server exposes a collection of tools like save_image_tool, convert_color_space_tool, resize_image_tool, crop_image_tool, get_image_stats_tool, apply_filter_tool, detect_edges_tool, apply_threshold_tool, detect_contours_tool, and find_shapes_tool, among others. You can initialize a client in your code (for example, in Python) and call these tools to operate on image data or video frames, returning processed results and metadata for downstream consumption by your AI assistant. To run the server locally, you start the UVX-based service and then interact with it via the MCP transport defined in your environment or configuration. The tooling supports both basic image operations and advanced CV tasks such as real-time object detection using pre-configured models located in OPENCV_DNN_MODELS_DIR.

How to install

Prerequisites:

  • Python 3.8 or newer
  • Git
  • Optional: a virtual environment tool (venv is included with Python)

Installation steps:

  1. Clone the repository: git clone https://github.com/yourusername/opencv-mcp-server.git cd opencv-mcp-server

  2. Create and activate a virtual environment: python -m venv .venv

    macOS/Linux

    source .venv/bin/activate

    Windows

    ..venv\Scripts\activate

  3. Install the package in editable mode (development mode): pip install -e .

  4. Install the MCP transport client (UVX) prerequisites if not already installed. For Claude Desktop integration, the guide uses UVX, so install it via a package manager:

    macOS (Homebrew)

    brew install uv

  5. Start the MCP server via UVX (from project root): uvx opencv-mcp-server

  6. Verify the server starts and is reachable via the configured MCP transport. If you run with stdio, ensure your client is connected accordingly.

Note: If you plan to customize model directories or CV resources, configure environment variables as described in the configuration guidance (MCP_TRANSPORT, OPENCV_DNN_MODELS_DIR, CV_HAAR_CASCADE_DIR).

Additional notes

Tips and common issues:

  • Ensure the OPENCV_DNN_MODELS_DIR contains the pre-configured models (e.g., YOLO weights/configs and face detection models) or point to a directory with your own models.
  • If you encounter model load errors, verify that the files exist and have correct permissions in OPENCV_DNN_MODELS_DIR.
  • The MCP_TRANSPORT setting controls how the server communicates with clients (stdio by default). Adjust if your environment uses another transport (e.g., sockets).
  • When using Claude Desktop or other clients, ensure the correct command and arguments are provided in the mcp_config (uvx + package name) and restart the client after changes.
  • For real-time video processing, ensure sufficient compute resources and that your input video frames are delivered with the expected format.
  • If you modify environment variables, restart the MCP server to apply changes.

Related MCP Servers

Sponsor this space

Reach thousands of developers