Skip to main content

MCP server for image analysis using OpenRouter

Project description

MCP OpenVision

CI PyPI version Python Versions License: MIT

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-sonnet
  • anthropic/claude-3-opus
  • anthropic/claude-3-sonnet
  • openai/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

  1. Edit your MCP configuration file:

    • Windows: %USERPROFILE%\.cursor\mcp.json
    • macOS: ~/.cursor/mcp.json or ~/Library/Application Support/Claude/claude_desktop_config.json
  2. 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 instruction
    • model: Vision model to use
    • temperature: 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"
)

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

mcp_openvision-0.2.0.tar.gz (112.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_openvision-0.2.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file mcp_openvision-0.2.0.tar.gz.

File metadata

  • Download URL: mcp_openvision-0.2.0.tar.gz
  • Upload date:
  • Size: 112.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcp_openvision-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fe63bbb21c27237bee3b21fe193ee102fe1d35ee216ef195961ae780c24ba0d1
MD5 9bc18e23c82ae1db022e7fbd0e32c157
BLAKE2b-256 e7e76904f73992eaa753a5ee0aa0d05a7448c29f3601060bd2db89285bf7c21f

See more details on using hashes here.

File details

Details for the file mcp_openvision-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_openvision-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcp_openvision-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0f08d168463d3b10f45f98b9e713cb80d7661c046b8995b8e8ed608d92604a2
MD5 6860f1db634202b39624a66638d5135b
BLAKE2b-256 95efab2fd6d35e7ba73c2095708df60d933f5c9efb511e61fa89032e20b5e5f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page