MCP server for image recognition using Anthropic and OpenAI vision APIs
Project description
MCP Image Recognition Server
An MCP server that provides image recognition capabilities using Anthropic and OpenAI vision APIs. Version 0.1.2.
Features
- Image description using Anthropic Claude Vision or OpenAI GPT-4 Vision
- Support for multiple image formats (JPEG, PNG, GIF, WebP)
- Configurable primary and fallback providers
- Base64 and file-based image input support
- Optional text extraction using Tesseract OCR
Requirements
- Python 3.8 or higher
- Tesseract OCR (optional) - Required for text extraction feature
- Windows: Download and install from UB-Mannheim/tesseract
- Linux:
sudo apt-get install tesseract-ocr - macOS:
brew install tesseract
Installation
- Clone the repository:
git clone https://github.com/mario-andreschak/mcp-image-recognition.git
cd mcp-image-recognition
- Create and configure your environment file:
cp .env.example .env
# Edit .env with your API keys and preferences
- Build the project:
build.bat
Usage
Running the Server
Spawn the server using python:
python -m image_recognition_server.server
Start the server using batch instead:
run.bat server
Start the server in development mode with the MCP Inspector:
run.bat debug
Available Tools
-
describe_image- Input: Base64-encoded image data and MIME type
- Output: Detailed description of the image
-
describe_image_from_file- Input: Path to an image file
- Output: Detailed description of the image
Environment Configuration
ANTHROPIC_API_KEY: Your Anthropic API key.OPENAI_API_KEY: Your OpenAI API key.VISION_PROVIDER: Primary vision provider (anthropicoropenai).FALLBACK_PROVIDER: Optional fallback provider.LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR).MAX_TOKENS: Maximum number of tokens generated in a vision response (default:1024).ENABLE_OCR: Enable Tesseract OCR text extraction (trueorfalse).TESSERACT_CMD: Optional custom path to Tesseract executable.OPENAI_MODEL: OpenAI Model (default:gpt-4o-mini). Can use OpenRouter format for other models (e.g.,anthropic/claude-3.5-sonnet:beta).OPENAI_BASE_URL: Optional custom base URL for the OpenAI API. Set tohttps://openrouter.ai/api/v1for OpenRouter.OPENAI_TIMEOUT: Optional custom timeout (in seconds) for the OpenAI API.
Using OpenRouter
OpenRouter allows you to access various models using the OpenAI API format. To use OpenRouter, follow these steps:
- Obtain an OpenAI API key from OpenRouter.
- Set
OPENAI_API_KEYin your.envfile to your OpenRouter API key. - Set
OPENAI_BASE_URLtohttps://openrouter.ai/api/v1. - Set
OPENAI_MODELto the desired model using the OpenRouter format (e.g.,anthropic/claude-3.5-sonnet:beta). - Set
VISION_PROVIDERtoopenai.
Default Models
- Anthropic:
claude-3.5-sonnet-beta - OpenAI:
gpt-4o-mini - OpenRouter: Use the
anthropic/claude-3.5-sonnet:betaformat inOPENAI_MODEL.
Development
Running Tests
Run all tests:
run.bat test
Run specific test suite:
run.bat test server
run.bat test anthropic
run.bat test openai
Docker Support
Build the Docker image:
docker build -t mcp-image-recognition .
Run the container:
docker run -it --env-file .env mcp-image-recognition
License
MIT License - see LICENSE file for details.
Release History
- 0.1.2 (2025-02-20): Improved OCR error handling and added comprehensive test coverage for OCR functionality
- 0.1.1 (2025-02-19): Added Tesseract OCR support for text extraction from images (optional feature)
- 0.1.0 (2025-02-19): Initial release with Anthropic and OpenAI vision support
Project details
Release history Release notifications | RSS feed
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_vision_recognition-0.1.2.tar.gz.
File metadata
- Download URL: mcp_vision_recognition-0.1.2.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3133418d495fe483b8d86d23a8bbcf7dad9596bbb565119d43d3cb7531a1bd4
|
|
| MD5 |
7f65e847adb295fcabd6de176430d56a
|
|
| BLAKE2b-256 |
9c5cc90e4cf1b8ba86173fc1e58fec7c920ae0a638c7bd279144cc12a33d9eca
|
File details
Details for the file mcp_vision_recognition-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mcp_vision_recognition-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26949c80106fb6e9ea04f8914a81b3df6260d908f0884adc04ed7c844c422d1e
|
|
| MD5 |
586469db4af3152d3a0d3efbc63a22b6
|
|
| BLAKE2b-256 |
df1268282a1151d811f8ba2ab316bd774abc745b590a41db3055c7ac9912b151
|