图像分析MCP服务器
全面 只读的 图像分析MCP(模型上下文协议)服务器,为Claude提供详细的图像检查功能。
特性
- 元数据和EXIF提取:相机设置、GPS、时间戳等
- 直方图分析:带统计的RGB和亮度直方图
- 音调分析:阴影、中间色调、高光、动态范围和剪裁检测
- 颜色分析:主色、色温、饱和度和偏色检测
- 空间特征:锐度评分、噪声估计、边缘密度和模糊检测
- 频率分析:基于FFT的细节级别评估(可选)
- 预览生成:Base64编码预览图像(可选)
支持格式
标准格式
- JPEG(.jpg、.JPEG)
- PNG(.PNG)
- TIFF(.tif、.TIFF)
- WebP(.WebP)
RAW格式
- 佳能RAW(.cr2、.cr3)
- 尼康RAW(.nef)
- 索尼RAW(.arw)
- Adobe DNG(.DNG)
- 富士RAW(.raf)
- 奥林巴斯RAW(.orf)
安装
选项1:Docker(推荐)
最简单的入门方法-不需要Python设置!
# Build the Docker image
cd image_analysis
docker build -t image-analysis-mcp:latest .
# Test it works
docker run --rm image-analysis-mcp:latest python -c "import image_analysis_mcp; print('✓ OK')"看 医生.md 查看完整的Docker文档。
选项2:诗歌
# Prerequisites: Python 3.12+, Poetry
cd image_analysis
# Install dependencies
poetry install
# Activate the virtual environment
poetry shell选项3:pip
# Prerequisites: Python 3.12+
cd image_analysis
# Install the package
pip install -e .用法
运行MCP服务器
服务器可以直接运行:
# Using Poetry
poetry run image-analysis-mcp
# Or if in activated virtual environment
image-analysis-mcpClaude桌面配置
添加到您的Claude Desktop配置文件(claude_desktop_config.json):
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json
使用Docker(推荐)
{
"mcpServers": {
"image-analysis": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-v",
"/path/to/your/images:/images:ro",
"image-analysis-mcp:latest"
]
}
}
}然后参考图像如下 /images/photo.jpg 在克劳德。
用诗
{
"mcpServers": {
"image-analysis": {
"command": "poetry",
"args": ["run", "image-analysis-mcp"],
"cwd": "/absolute/path/to/image_analysis"
}
}
}使用pip(全局安装)
{
"mcpServers": {
"image-analysis": {
"command": "image-analysis-mcp"
}
}
}可用工具
1. get_metadata
快速元数据和EXIF提取,无需加载完整图像数据。
参数:
filepath(str):图像文件的路径
例子:
What camera was used for IMG_1234.CR2?2. get_histogram
使用通道统计提取RGB和亮度直方图。
参数:
filepath(str):图像文件的路径process_raw(bool,可选):处理RAW文件(默认值:True)
例子:
Show me the histogram for landscape.jpg3. analyze_image
全面的图像分析,包括所有属性。
参数:
filepath(str):图像文件的路径include_frequency(bool,可选):包括FFT分析(默认值:False)include_preview(bool,可选):生成预览图像(默认值:False)preview_max_dimension(int,可选):预览最大大小(默认值:1920)preview_format(str,可选):“JPEG”、“PNG”或“WEBP”(默认为“JPEG”)preview_quality(int,可选):质量1-100(默认值:85)process_raw(bool,可选):处理RAW文件(默认值:True)
例子:
Analyze photo.jpg and tell me if it's sharp enough for printingAnalyze this RAW file and show me a preview建筑
此服务器遵循 完全无国籍 架构:
- 每个工具调用都是独立的
- 图像被加载、分析并立即丢弃
- 无缓存或会话状态
- 可预测和可重复的结果
演出
现代硬件的典型性能:
| 操作 | 2MP图像 | 12MP图像 | 50MP图像 |
|---|---|---|---|
get_metadata | 10ms | 15ms | 25ms |
get_histogram | 50ms | 150ms | 600ms |
analyze_image | 200毫秒 | 800毫秒 | 3000毫秒 |
analyze_image (带预览) | 300ms | 1100ms | 4000ms |
analyze_image (带FFT) | 500ms | 2000ms | 8000ms |
对话示例
检查图像质量
User: Is wedding_photo.jpg sharp enough for a large print?
Claude: [Uses analyze_image to check sharpness, noise, and resolution]暴露分析
User: Is this sunset photo overexposed?
Claude: [Uses analyze_image to check histogram and clipping]颜色分析
User: What are the dominant colors in this landscape?
Claude: [Uses analyze_image to extract dominant colors and temperature]元数据提取
User: What camera settings were used for IMG_5678.NEF?
Claude: [Uses get_metadata to extract EXIF data]错误处理
服务器提供明确的错误消息:
FILE_NOT_FOUND:文件不存在PERMISSION_DENIED:无法读取文件UNSUPPORTED_FORMAT:不支持格式CORRUPTED_FILE:文件已损坏OUT_OF_MEMORY:图像太大INVALID_PARAMETER:参数值错误RAW_PROCESSING_FAILED:RAW转换失败
发展
运行测试
poetry run pytest代码格式化
poetry run black src/类型检查
poetry run mypy src/许可证
本项目按原样提供,供Claude Desktop和MCP使用。
作者
吉姆·达舍尔
版本
1.0.0-2025年10月28日
