This repository provides a specialized Computer Vision Model Context Protocol (MCP) server that integrates computer vision capabilities with language models. It enables easy communication between vision tools and language models through a standardized protocol.
Clone the repository:
git clone https://github.com/username/cv-mcp-tools.git
cd cv-mcp-tools
Create and activate a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
Install the required dependencies:
pip install -r requirements.txt
Create a configuration file named config.yaml
with the following structure:
server:
host: "127.0.0.1"
port: 8000
models:
vision_model:
type: "resnet"
weights: "path/to/model/weights.pth"
logging:
level: "INFO"
file: "logs/server.log"
Start the MCP server with:
python server.py --config config.yaml
By default, the server will run on http://127.0.0.1:8000
unless specified otherwise in your configuration.
Send images to the server for processing:
import requests
import base64
from PIL import Image
import io
# Prepare the image
image = Image.open("example.jpg")
buffered = io.BytesIO()
image.save(buffered, format="JPEG")
img_str = base64.b64encode(buffered.getvalue()).decode()
# Send request to the server
response = requests.post(
"http://127.0.0.1:8000/process",
json={
"image": img_str,
"settings": {
"model": "vision_model",
"task": "detection"
}
}
)
# Process the response
results = response.json()
print(results)
/process
- Main endpoint for image processing/models
- Lists available vision models/health
- Server health check/metrics
- Server performance metricsThe /process
endpoint accepts the following parameters:
image
: Base64 encoded image datasettings
: Configuration object with:
model
: The vision model to use (string)task
: The type of vision task (detection, classification, segmentation)threshold
: Confidence threshold (float, 0-1)max_detections
: Maximum number of detections to return (integer)There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.