File size: 2,312 Bytes
7bd14af
e169048
 
7bd14af
 
 
 
 
 
e169048
 
 
 
7bd14af
e169048
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7bd14af
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
title: Mcp Images Server
emoji:  πŸ–ΌοΈ
colorFrom: gray
colorTo: red
sdk: gradio
sdk_version: 5.34.0
app_file: app.py
pinned: false
tags:
  - images
  - mcp-server
  
---
  

# Image Analysis MCP Server

This Gradio application serves as an MCP (Model Control Protocol) server that provides image analysis tools for LLMs like Claude.

## πŸ”§ Available Tools

- **analyze_image**: Comprehensive image analysis including dimensions, format, colors, and orientation
- **get_image_orientation**: Determine if an image is portrait, landscape, or square
- **count_colors**: Analyze color information and identify dominant colors
- **extract_text_info**: Basic analysis for potential text content in images

## πŸš€ Usage with Claude Desktop

To use this MCP server with Claude Desktop, add this configuration to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "image-analysis": {
      "url": "https://YOUR_USERNAME-image-analysis-mcp.hf.space/gradio_api/mcp/sse"
    }
  }
}
```

Replace `YOUR_USERNAME` with your actual HuggingFace username.

## πŸ“ Example Prompts

Once configured, you can ask Claude:

- "Analyze this image for me"
- "What are the dominant colors in this photo?"
- "Is this image portrait or landscape?"
- "Does this image contain text?"

Claude will automatically use these tools to provide detailed image analysis!

## πŸ” How It Works

1. Upload an image to Claude or paste an image
2. Claude automatically converts the image to base64
3. Claude calls the appropriate MCP tool on this server
4. The server processes the image using PIL (Python Imaging Library)
5. Results are returned to Claude and presented to you

## πŸ› οΈ Technical Details

- Built with **Gradio** and **PIL (Pillow)**
- Accepts images in various formats (JPEG, PNG, GIF, etc.)
- Automatically handles base64 image data from MCP clients
- Provides JSON-formatted analysis results
- Includes error handling for invalid inputs

## πŸ“‹ Requirements

- `gradio[mcp]>=4.0.0`
- `Pillow>=9.0.0`

## πŸ”— Links

- [MCP Documentation](https://modelcontextprotocol.io/)
- [Gradio MCP Guide](https://www.gradio.app/guides/building-an-mcp-server-with-gradio)
- [Claude Desktop](https://claude.ai/desktop)

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference