Video Still Capture MCP Server for OpenCV Cameras
Capture high-quality video stills from OpenCV cameras with an easy-to-deploy MCP server for webcams and other video sources.
npx -y @13rac1/videocapture-mcpOverview
This MCP (Model Context Protocol) server captures high-quality still frames from OpenCV-compatible video sources (webcams, USB cameras, RTSP/HTTP streams) and exposes them as simple HTTP/MCP tools. It is designed for developers who need deterministic single-frame captures for testing, dataset collection, monitoring, or to provide visual context to agent workflows. Deploying the server gives you a low-latency API that can be called by local scripts, CI jobs, or agent systems that support MCP-style tool integrations.
The server focuses on predictable frame grabs: it configures capture parameters (resolution, pixel format, exposure hints) and returns images in a format convenient for downstream processing (binary image response, base64 payload, or a small JSON metadata envelope). Because it leverages OpenCV, you can use it with nearly any camera source supported by your OS and OpenCV build.
Features
- Capture a single, high-quality still frame from a selected OpenCV video source
- Support for webcams, USB cameras, and network streams (RTSP/HTTP)
- Configurable capture parameters: camera index/URL, width, height, exposure hints, color conversion
- Multiple output formats: image file (JPEG/PNG), base64-encoded image in JSON, or direct binary image response
- Simple HTTP API compatible with MCP-style tool invocation patterns
- Lightweight Python implementation using OpenCV and a minimal web framework (Flask/FastAPI)
- Docker-friendly for easy deployment
Installation / Configuration
Prerequisites:
- Python 3.8+
- OpenCV (opencv-python or opencv-python-headless)
- A camera device or accessible video stream
Install with pip:
Run locally (example with Flask-based server script named server.py):
# device index or RTSP/HTTP URL
Docker deploy (example Dockerfile usage):
FROM python:3.10-slim
WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
ENV CAMERA_SOURCE=0 WIDTH=1280 HEIGHT=720 PORT=8080
CMD ["python", "server.py"]
Build and run:
Environment variables and common options:
| Variable | Default | Description |
|---|---|---|
| CAMERA_SOURCE | 0 | OpenCV camera index or stream URL (rtsp://, http://) |
| WIDTH | 1280 | Desired capture width |
| HEIGHT | 720 | Desired capture height |
| PORT | 8080 | HTTP port to listen on |
| FORMAT | jpeg | Output format: jpeg or png |
| TIMEOUT_MS | 2000 | Capture timeout in milliseconds |
Available Tools / Resources
The server provides a small set of HTTP endpoints suitable for programmatic use:
- GET /health
- Returns 200 when server and camera are accessible.
- POST /capture
- Request body (JSON) options: camera_source, width, height, format, encode_base64 (bool)
- Response: image binary (Content-Type: image/jpeg/png) or JSON with base64 image and metadata.
- GET /capture?camera_source=…&width=…&height=…&format=…
- Shortcut for quick GET-based captures.
Example JSON response (when encode_base64=true):
Repository and reference:
- GitHub: https://github.com/13rac1/videocapture-mcp
Usage Examples
Simple curl request to get a JPEG image:
Capture as JSON with base64 image (useful for embedding in MCP messages):
| |
Python client example:
=
=
=
Use Cases
- Dataset collection: programmatically capture labeled frames for training CV models without manual camera control.
- Agent visual context: provide on-demand snapshots to an ML agent through an MCP-compatible tool to augment text-based context with images.
- Remote troubleshooting: grab stills from remote or embedded cameras for diagnostics and logs.
- Automated monitoring: schedule single-frame captures for periodic quality checks or visual records.
- Robotics and control systems: snapshot camera frames for debugging control loops without streaming full video.
This server is intended as a lightweight, reproducible component you can add to pipelines that need reliable single-frame captures from any OpenCV-supported source. The API and configuration make it straightforward to integrate into CI, agent runtimes, or edge deployments.