MCP Image Server

MCP Image Server

An intelligent MCP server that searches for images, labels them, combines them into a composite image, and uses Google's Gemini 2.0 Flash AI to select the best match for your query.

Category
Visit Server

README

MCP Image Server

An intelligent MCP (Model Context Protocol) server that searches for images, labels them, combines them into a composite image, and uses Google's Gemini 2.0 Flash AI to select the best match for your query.

Features

  • šŸ” Image Search: Searches multiple sources (Unsplash, Pexels, with fallback to Lorem Picsum)
  • šŸ·ļø Smart Labeling: Labels each image (1-20) with black borders for easy identification
  • šŸ–¼ļø Image Composition: Combines all images into a single grid view
  • šŸ¤– AI Selection: Uses Google's Gemini 2.0 Flash to intelligently select the best matching image
  • šŸ“¦ Base64 Output: Returns images as base64 for easy integration

Installation

  1. Clone or download this repository

  2. Install dependencies:

    npm install
    
  3. Copy the environment template:

    copy .env.example .env
    
  4. Edit .env and add your API keys:

    GOOGLE_AI_API_KEY=your_google_ai_api_key_here
    UNSPLASH_ACCESS_KEY=your_unsplash_access_key_here
    PEXELS_API_KEY=your_pexels_api_key_here
    

Getting API Keys

Google AI API Key (Required for AI selection)

  1. Go to Google AI Studio
  2. Create a new API key
  3. Add it to your .env file as GOOGLE_AI_API_KEY

Unsplash API Key (Optional but recommended)

  1. Go to Unsplash Developers
  2. Create a new application
  3. Get your Access Key
  4. Add it to your .env file as UNSPLASH_ACCESS_KEY

Pexels API Key (Optional but recommended)

  1. Go to Pexels API
  2. Create a free account and get your API key
  3. Add it to your .env file as PEXELS_API_KEY

Usage

Development Mode

npm run dev

Build and Run

npm run build
npm start

Using with Claude Desktop

Add this server to your Claude Desktop configuration:

{
  "mcpServers": {
    "mcp-image-server": {
      "command": "node",
      "args": ["C:/path/to/your/project/build/index.js"]
    }
  }
}

Available Tools

search_and_select_best_image

Searches for images matching your query and returns the AI-selected best match.

Parameters:

  • query (string, required): The search query for images
  • maxImages (number, optional): Maximum number of images to search (1-20, default: 20)

Example usage in Claude:

"Search for the best image of a sunset over mountains"

How It Works

  1. Search: Queries multiple image APIs (Unsplash, Pexels) for relevant images
  2. Download: Downloads up to 20 images and resizes them to thumbnails
  3. Label: Adds numbered labels (1-20) with black borders to each image
  4. Compose: Combines all labeled images into a single grid
  5. AI Analysis: Sends the composite to Google's Gemini 2.0 Flash with your original query
  6. Select: AI analyzes each numbered image and selects the best match
  7. Return: Downloads and returns the selected image as base64

Error Handling

  • If no API keys are provided, the server uses placeholder images from Lorem Picsum
  • If Google AI API is not available, it uses a fallback selection algorithm
  • Failed image downloads are replaced with placeholder images
  • All errors are logged to stderr for debugging

Project Structure

src/
ā”œā”€ā”€ index.ts                    # Main MCP server entry point
└── services/
    ā”œā”€ā”€ ImageSearchService.ts   # Handles image search from various APIs
    ā”œā”€ā”€ ImageProcessingService.ts # Processes and combines images
    └── AISelectionService.ts   # Uses Google AI for selection

Development

  • npm run dev - Run in development mode with auto-restart
  • npm run build - Build TypeScript to JavaScript
  • npm run clean - Clean build directory

License

MIT License

Contributing

Feel free to submit issues and enhancement requests!

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured