MCP 图像抠图服务器
这是一个基于Model Context Protocol (MCP)的服务器,专门提供火山引擎图像抠图功能。
功能特性
- 智能抠图: 使用火山引擎的显著性分割技术,自动识别并抠出图像中的主要对象
- 批量处理: 支持同时处理多张图像
- 自动上传: 抠图结果自动上传到服务器并返回URL链接
- 本地保存: 可选择保存抠图结果到本地文件
- 高精度: 基于显著性检测的精确分割算法
安装
从 PyPI 安装
pip install mcp-image-cutout
从源码安装
git clone https://github.com/fengjinchao/mcp-image-cutout.git
cd mcp-image-cutout
pip install -e .
2. 配置API密钥
推荐使用环境变量设置API密钥:
export VOLC_ACCESS_KEY="your_access_key"
export VOLC_SECRET_KEY="your_secret_key"
或者在代码中直接设置(不推荐用于生产环境)。
3. 运行服务器
# 使用命令行工具
mcp-image-cutout
# 或直接运行模块
python -m mcp_image_cutout.server
在Claude Desktop中使用
在Claude Desktop的配置文件中添加以下配置:
macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"抠图工具": {
"command": "mcp-image-cutout",
"env": {
"VOLC_ACCESS_KEY": "your_access_key",
"VOLC_SECRET_KEY": "your_secret_key"
}
}
}
}
可用工具
image_cutout
智能图像抠图,使用显著性分割自动识别并抠出图像中的主要对象,自动上传到服务器并返回图片URL。
参数:
image_urls: 图像URL列表,支持多张图像同时处理
返回:
- 单张图片:直接返回图片URL
- 多张图片:返回所有图片URL的列表
示例:
请帮我抠出这张图片中的主要对象:https://example.com/image.jpg
批量抠图这些图片:
- https://example.com/image1.jpg
- https://example.com/image2.jpg
抠图原理
使用的 saliency_seg 显著性分割算法:
- 基于视觉显著性检测图像中最重要的区域
- 精确分割显著对象的轮廓
- 生成高质量的抠图结果
- 适用于各种复杂背景的图像处理
上传功能
抠图完成后,系统会自动:
- 将base64编码的图像数据转换为PNG文件
- 上传到指定服务器:
https://www.mcpcn.cc/api/fileUploadAndDownload/uploadMcpFile - 返回可访问的图片URL链接
- 支持批量上传多张抠图结果
上传接口返回格式:
{
"code": 0,
"data": {
"url": "https://juezhi.oss-cn-shanghai.aliyuncs.com/file/uploads/mcp/xxx.webp"
},
"msg": "成功"
}
注意事项
- 确保图像URL可以公开访问
- 处理结果会以base64格式返回,大图像可能需要较长处理时间
- API调用有频率限制,请合理使用
- 生产环境中请使用环境变量设置API密钥
故障排除
常见问题
-
服务器无法启动
- 检查Python版本(需要3.10+)
- 确认所有依赖已正确安装
-
API调用失败
- 验证API密钥是否正确
- 检查网络连接
- 确认图像URL可访问
-
Claude Desktop中看不到工具
- 检查配置文件语法
- 确认路径是绝对路径
- 重启Claude Desktop
日志查看
服务器日志会输出到stderr,可以通过以下方式查看:
# 查看Claude Desktop的MCP日志
tail -f ~/Library/Logs/Claude/mcp-server-图像编辑.log
开发
如需修改或扩展功能,请参考:
Metadata
Release files for mcp-image-cutout 0.2.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcp_image_cutout-0.2.9.tar.gz | 10.1 kB | Without provenance | Details for mcp_image_cutout-0.2.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_image_cutout-0.2.9-py3-none-any.whl | Python 3 | none | any | Details for mcp_image_cutout-0.2.9-py3-none-any.whl |
Total release size: 20.3 kB
Release files / mcp_image_cutout-0.2.9.tar.gz
| Download URL | mcp_image_cutout-0.2.9.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5bce3b57b8383cb3b5f7ae1ac53643834406ddf46720757fe4dac938bf7d9f1
|
|
BLAKE2b-256 checksum How to use checksums |
02d0ec6a6577ccc93cdc06774421f12df2cf7ba04c0d3ecb77c95b86e4b85851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.18
|
Release files / mcp_image_cutout-0.2.9-py3-none-any.whl
| Download URL | mcp_image_cutout-0.2.9-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7afbe55176fde7a2a8fdd300a7454bf866e8618a2146ac62b4aaa329a2e56a4
|
|
BLAKE2b-256 checksum How to use checksums |
564835889c095e5c3d2877eaecca9a234fbfab4b1ca9db172c38168ee4dfc560
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.18
|
Security for mcp-image-cutout 0.2.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.