MCP server for image analysis using OpenRouter
Project description
MCP OpenVision
Overview
MCP OpenVision is a Model Context Protocol (MCP) server that provides image analysis capabilities powered by OpenRouter vision models. It enables AI assistants to analyze images via a simple interface within the MCP ecosystem.
Installation
Using pip
pip install mcp-openvision
Using UV (recommended)
uv pip install mcp-openvision
Configuration
MCP OpenVision requires an OpenRouter API key and can be configured through environment variables:
- OPENROUTER_API_KEY (required): Your OpenRouter API key
- OPENROUTER_DEFAULT_MODEL (optional): The default vision model to use
Supported Models
qwen/qwq-32b:free(default)anthropic/claude-3-5-sonnetanthropic/claude-3-opusanthropic/claude-3-sonnetopenai/gpt-4o
Usage
Testing with MCP Inspector
The easiest way to test MCP OpenVision is with the MCP Inspector tool:
npx @modelcontextprotocol/inspector uvx mcp-openvision
Integration with Claude Desktop or Cursor
-
Edit your MCP configuration file:
- Windows:
%USERPROFILE%\.cursor\mcp.json - macOS:
~/.cursor/mcp.jsonor~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
-
Add the following configuration:
{
"mcpServers": {
"openvision": {
"command": "uvx",
"args": ["mcp-openvision"],
"env": {
"OPENROUTER_API_KEY": "your_openrouter_api_key_here",
"OPENROUTER_DEFAULT_MODEL": "anthropic/claude-3-sonnet"
}
}
}
}
Running Locally for Development
# Set the required API key
export OPENROUTER_API_KEY="your_api_key"
# Run the server module directly
python -m mcp_openvision
Features
MCP OpenVision provides the following core tool:
- image_analysis: Analyze images with vision models, supporting various parameters:
image: Can be provided as:- Base64-encoded image data
- Image URL (http/https)
- Local file path
prompt: Analysis instructionmodel: Vision model to usetemperature: Controls randomness (0.0-1.0)max_tokens: Maximum response length
Example Usage
# Analyze an image from a URL
result = await image_analysis(
image="https://example.com/image.jpg",
prompt="Describe this image in detail"
)
# Analyze an image from a local file
result = await image_analysis(
image="path/to/local/image.jpg",
prompt="What objects are in this image?"
)
# Analyze with a base64-encoded image
result = await image_analysis(
image="SGVsbG8gV29ybGQ=...", # base64 data
prompt="Analyze this image"
)
Image Input Types
The image_analysis tool accepts several types of image inputs:
- Base64-encoded strings
- Image URLs - must start with http:// or https://
- File paths:
- Absolute paths: full paths starting with / (Unix) or drive letter (Windows)
- Relative paths: paths relative to the current working directory
- Relative paths with project_root: use the
project_rootparameter to specify a base directory
Using Relative Paths
When using relative file paths (like "examples/image.jpg"), you have two options:
- The path must be relative to the current working directory where the server is running
- Or, you can specify a
project_rootparameter:
# Example with relative path and project_root
result = await image_analysis(
image="examples/image.jpg",
project_root="/path/to/your/project",
prompt="What is in this image?"
)
This is particularly useful in applications where the current working directory may not be predictable or when you want to reference files using paths relative to a specific directory.
Development
Setup Development Environment
# Clone the repository
git clone https://github.com/modelcontextprotocol/mcp-openvision.git
cd mcp-openvision
# Install development dependencies
pip install -e ".[dev]"
Run Tests
pytest
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_openvision-0.3.0.tar.gz.
File metadata
- Download URL: mcp_openvision-0.3.0.tar.gz
- Upload date:
- Size: 113.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00edd5955faa17488444105f4cdce2e90bd83ee30936f5ca865ab7f20eff738a
|
|
| MD5 |
aaf3297b4d8aa9fe98bf4f29543dbeab
|
|
| BLAKE2b-256 |
3b1a42540f752dc657b7bb5dc53ff9f92dfac61c1285b05095a26e0a925be8fa
|
File details
Details for the file mcp_openvision-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mcp_openvision-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ff30391b5a527ba24cc83be0f5d6b94952f4edccd887832e90d8568e15604b3
|
|
| MD5 |
52fde52fd4f07b9de668da471a8ec552
|
|
| BLAKE2b-256 |
fca3a86e75b8b0a0ad1b63e2646571642e42b40a9b97a7dbe12e326a61fec865
|