Metadata-Version: 2.4
Name: mcpcn-image-cutout
Version: 0.1.2
Summary: MCP服务器：图像编辑工具，提供显著性分割、背景移除等图像处理功能
Project-URL: Homepage, https://github.com/fengjinchao/mcp-image-cutout
Project-URL: Repository, https://github.com/fengjinchao/mcp-image-cutout
Project-URL: Documentation, https://github.com/fengjinchao/mcp-image-cutout#readme
Project-URL: Issues, https://github.com/fengjinchao/mcp-image-cutout/issues
Author-email: fengjinchao <fengjinchao@example.com>
License: MIT
License-File: LICENSE
Keywords: ai,computer-vision,cutout,image,mcp,volcengine
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: mcp[cli]>=1.12.0
Requires-Dist: volcengine>=1.0.0
Description-Content-Type: text/markdown

# MCP 图像抠图服务器

这是一个基于Model Context Protocol (MCP)的服务器，专门提供火山引擎图像抠图功能。

## 功能特性

- **智能抠图**: 使用火山引擎的显著性分割技术，自动识别并抠出图像中的主要对象
- **批量处理**: 支持同时处理多张图像
- **直接返回**: 抠图结果以base64格式直接返回，不在MCP内部上传图片
- **高精度**: 基于显著性检测的精确分割算法

## 安装

### 从 PyPI 安装

```bash
pip install mcp-image-cutout
```

### 从源码安装

```bash
git clone https://github.com/fengjinchao/mcp-image-cutout.git
cd mcp-image-cutout
pip install -e .
```

### 2. 配置API密钥

推荐使用环境变量设置API密钥：

```bash
export VOLC_ACCESS_KEY="your_access_key"
export VOLC_SECRET_KEY="your_secret_key"
```

或者在代码中直接设置（不推荐用于生产环境）。

### 3. 运行服务器

```bash
# 使用命令行工具
mcp-image-cutout

# 或直接运行模块
python -m mcp_image_cutout.server
```

## 在Claude Desktop中使用

在Claude Desktop的配置文件中添加以下配置：

**macOS/Linux**: `~/Library/Application Support/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "抠图工具": {
      "command": "mcp-image-cutout",
      "env": {
        "VOLC_ACCESS_KEY": "your_access_key",
        "VOLC_SECRET_KEY": "your_secret_key"
      }
    }
  }
}
```

## 可用工具

### image_cutout
智能图像抠图，使用显著性分割自动识别并抠出图像中的主要对象，直接返回base64图片数据。

**参数**:
- `image_url`: 图像URL

**返回**:
- `data` 为base64图片数据
- `encoding`: `base64`
- `mime_type`: `image/png`

**示例**:
```
请帮我抠出这张图片中的主要对象：https://example.com/image.jpg
```

```
批量抠图这些图片：
- https://example.com/image1.jpg
- https://example.com/image2.jpg
```

## 抠图原理

使用的 `saliency_seg` 显著性分割算法：
- 基于视觉显著性检测图像中最重要的区域
- 精确分割显著对象的轮廓
- 生成高质量的抠图结果
- 适用于各种复杂背景的图像处理

## 返回格式

抠图完成后，系统会直接返回base64编码的PNG图片数据，不会把待处理图片或处理结果上传到MCP内部的文件服务器。

**返回格式示例**：
```json
{
    "success": true,
    "data": "iVBORw0KGgoAAAANSUhEUg...",
    "encoding": "base64",
    "mime_type": "image/png",
    "message": "处理成功，共返回 1 张base64图片",
    "processed_count": 1,
    "total_count": 1
}
```

## 注意事项

1. 确保图像URL可以公开访问
2. 处理结果会以base64格式返回，大图像可能需要较长处理时间
3. API调用有频率限制，请合理使用
4. 生产环境中请使用环境变量设置API密钥

## 故障排除

### 常见问题

1. **服务器无法启动**
   - 检查Python版本（需要3.10+）
   - 确认所有依赖已正确安装

2. **API调用失败**
   - 验证API密钥是否正确
   - 检查网络连接
   - 确认图像URL可访问

3. **Claude Desktop中看不到工具**
   - 检查配置文件语法
   - 确认路径是绝对路径
   - 重启Claude Desktop

### 日志查看

服务器日志会输出到stderr，可以通过以下方式查看：

```bash
# 查看Claude Desktop的MCP日志
tail -f ~/Library/Logs/Claude/mcp-server-图像编辑.log
```

## 开发

如需修改或扩展功能，请参考：
- [MCP官方文档](https://modelcontextprotocol.io/)
- [API文档](https://www.volcengine.com/docs/6791/65681)
