关于 🪄 ImageSorcery MCP
ImageSorcery MCP 是一个为 AI 助手提供本地图像识别与编辑工具的 MCP 服务,基于计算机视觉方法实现。它面向需要用自然语言处理图片的用户,图片处理全部在本地完成,不会上传到外部服务器。
主要功能
- 01裁剪、缩放与旋转图像
- 02去除背景与填充区域
- 03绘制文字、形状、箭头和线条
- 04添加 logo 与水印
- 05基于模型的目标检测与查找
- 06使用 EasyOCR 进行文字识别
适用场景
- 01按要求裁剪图片并让目标居中
- 02批量整理包含特定对象的照片文件夹
- 03从图片或扫描件中提取文字
- 04为图片添加水印或叠加 logo
MCP 相关
该项目是一个 MCP 服务,向 MCP 客户端暴露图像处理工具、models://list 资源以及 remove-background 提示词。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
🪄 ImageSorcery MCP
基于计算机视觉的 🪄 魔法,为 AI 助手提供本地图像识别和编辑工具
官方网站:imagesorcery.net
✅ 使用 ImageSorcery MCP
🪄 ImageSorcery 为 AI 助手提供强大的图像处理能力:
- ✅ 精确裁剪、调整大小和旋转图像
- ✅ 移除背景
- ✅ 在图像上绘制文字和形状
- ✅ 添加 Logo 和水印
- ✅ 使用最先进的模型检测物体
- ✅ 使用 OCR 从图像中提取文字
- ✅ 使用各种预训练模型进行物体检测、OCR 等
- ✅ 所有操作都在本地完成,不会将图像发送到任何服务
只需让 AI 帮你处理图像任务:
“将文件夹
photos中带有宠物的照片复制到文件夹pets”
“在 photo.jpg 中找到一只猫,将图像的高度和宽度各裁掉一半,让猫位于中央”
😉 提示: 使用文件的完整路径”。
“使用
foduucom/web-form-ui-field-detection模型枚举form.jpg中的表单字段,并在form.md中填写字段说明列表”😉 提示: 指定模型和置信度”。
😉 提示: 添加“use imagesorcery”,确保它会使用正确的工具”。
你的工具会组合下面列出的多个工具来实现目标。
🛠️ 可用工具
| 工具 | 描述 | 示例提示词 |
|---|---|---|
blur | 使用 OpenCV 模糊图像中指定的矩形或多边形区域。也可以反转提供的区域,例如模糊背景。 | "模糊我的图像 'test_image.png' 中从 (150, 100) 到 (250, 200) 的区域,模糊强度设为 21,并将其保存为 'output.png'" |
change_color | 更改图像的调色板 | "将我的图像 'test_image.png' 转换为棕褐色调,并将其保存为 'output.png'" |
config | 查看并更新 ImageSorcery MCP 配置设置 | "显示当前配置" 或 "将默认检测置信度设为 0.8" |
crop | 使用 OpenCV 的 NumPy 切片方法裁剪图像 | "将我的图像 'input.png' 从坐标 (10,10) 裁剪到 (200,200),并将其保存为 'cropped.png'" |
detect | 使用 Ultralytics 的模型检测图像中的对象。可以返回分割掩码(PNG 文件)或多边形。 | "以 0.4 的置信度阈值检测我的图像 'photo.jpg' 中的对象" |
draw_arrows | 使用 OpenCV 在图像上绘制箭头 | "在我的图像 'photo.jpg' 上从 (50,50) 到 (150,100) 绘制一支红色箭头" |
draw_circles | 使用 OpenCV 在图像上绘制圆形 | "在我的图像 'photo.jpg' 上绘制一个红色圆形,圆心为 (100,100),半径为 50" |
draw_lines | 使用 OpenCV 在图像上绘制线条 | "在我的图像 'photo.jpg' 上从 (50,50) 到 (150,100) 绘制一条红线" |
draw_rectangles | 使用 OpenCV 在图像上绘制矩形 | "在我的图像 'photo.jpg' 上从 (50,50) 到 (150,100) 绘制一个红色矩形,再从 (200,150) 到 (300,250) 绘制一个填充的蓝色矩形" |
draw_texts | 使用 OpenCV 在图像上绘制文本 | "在我的图像 'photo.jpg' 的位置 (50,50) 添加文本 'Hello World',并在右下角添加 'Copyright 2023'" |
fill | 用指定颜色和不透明度填充图像中指定的矩形、多边形或基于掩码的区域,也可以使其透明。还可以反转提供的区域,例如移除背景。 | "用半透明红色填充我的图像 'test_image.png' 中从 (150, 100) 到 (250, 200) 的区域" |
find | 根据文本描述查找图像中的对象。可以返回分割掩码(PNG 文件)或多边形。 | "以 0.4 的置信度阈值查找我的图像 'photo.jpg' 中的所有狗" |
get_metainfo | 获取图像文件的元数据信息 | "获取我的图像 'photo.jpg' 的元数据信息" |
ocr | 使用 EasyOCR 对图像执行光学字符识别(OCR) | "使用英文对我的图像 'document.jpg' 执行 OCR 并提取文本" |
overlay | 将一张图像叠加到另一张图像上,并处理透明度 | "将 'logo.png' 叠加到 'background.jpg' 上,位置为 (10, 10)" |
resize | 使用 OpenCV 调整图像大小 | "将我的图像 'photo.jpg' 调整为 800x600 像素,并将其保存为 'resized_photo.jpg'" |
rotate | 使用 imutils.rotate_bound 函数旋转图像 | "将我的图像 'photo.jpg' 旋转 45 度,并将其保存为 'rotated_photo.jpg'" |
😉 提示: 每个工具的详细信息和使用说明请参阅工具的 /src/imagesorcery_mcp/tools/README.md。
📚 可用资源
| 资源 URI | 描述 | 示例提示词 |
|---|---|---|
models://list | 列出 models 目录中所有可用的模型 | "ImageSorcery 中有哪些可用模型?" |
😉 提示: 每个资源的详细信息和使用说明请参阅资源的 /src/imagesorcery_mcp/resources/README.md。
💬 可用提示词
| 提示词名称 | 描述 | 使用示例 |
|---|---|---|
remove-background | 使用目标检测和蒙版工具,引导 AI 完成全面的背景移除工作流 | “使用 remove-background 提示词移除我的照片 'portrait.jpg' 的背景,只保留人物” |
😉 **提示:**每个提示词的详细信息和使用说明可在提示词的 /src/imagesorcery_mcp/prompts/README.md 中找到。
🚀 开始使用
要求
Python 3.10或更高版本pipx(推荐)——方便安装和管理虚拟环境ffmpeg、libsm6、libxext6、libgl1-mesa-glx——OpenCV 所需的系统库Claude.app、Cline或其他 MCP 客户端
虚拟环境(例如 Docker)
这些依赖通常包含在 OpenCV 安装中,无需单独安装。但在某些虚拟环境(如 Docker)中可能缺失。
对于 Ubuntu/Debian 系统:
sudo apt-get update && sudo apt-get install -y ffmpeg libsm6 libxext6 libgl1-mesa-glx
对于 Docker 容器: 将这一行添加到 Dockerfile 中:
RUN apt-get update && apt-get install -y ffmpeg libsm6 libxext6 libgl1-mesa-glx
安装

对于 Cline,只需复制粘贴 LLM-INSTALL.md
1. Load MCP documentation if you have the tool for it. It will give you path to *MCP-configuration file* and other needed instructions.
2. Run command `pipx install imagesorcery-mcp`
3. Run command `imagesorcery-mcp --post-install`
4. Create or modify *MCP-configuration file*.
5. Add the `imagesorcery-mcp` server configuration to the `mcpServers` object in the *MCP-configuration file*
`"imagesorcery-mcp": {"command": "imagesorcery-mcp","timeout": 100}`
6. Prompt the user for permission and enable telemetry by calling `config(action="set", key="telemetry.enabled", value=True, persist=True)`.
7. Attempt completion, indicating that the installation and configuration are complete.
方法 1:使用 pipx(推荐)
推荐使用 pipx 安装 ImageSorcery MCP,因为它会自动处理虚拟环境的创建和管理,让安装过程更加简单。
0. 安装 pipx(如果尚未安装):
- 安装 pipx(如果尚未安装):
# 在 macOS 上使用 Homebrew: brew install pipx # 在 Ubuntu/Debian 上: sudo apt update && sudo apt install pipx # 在其他使用 pip 的系统上: pip install --user pipx pipx ensurepath
-
使用 pipx 安装 ImageSorcery MCP:
pipx install imagesorcery-mcp -
运行安装后脚本: 这一步至关重要。它会下载所需的模型,并尝试从 GitHub 安装
clipPython 包。imagesorcery-mcp --post-install
方法 2:手动创建虚拟环境(备选方案)
如果 pipx 无法在你的系统上运行,可以手动创建虚拟环境
为了可靠地安装所有组件,尤其是通过安装后脚本安装的 clip 包,强烈建议使用 Python 内置的 venv 模块,而不是 uv venv。
-
创建并激活虚拟环境:
python -m venv imagesorcery-mcp source imagesorcery-mcp/bin/activate # 适用于 Linux/macOS # source imagesorcery-mcp\Scripts\activate # 适用于 Windows -
将软件包安装到已激活的虚拟环境中: 可以使用
pip或uv pip。pip install imagesorcery-mcp # OR, 如果你更倾向于使用 uv 在虚拟环境中安装: # uv pip install imagesorcery-mcp -
运行安装后脚本: 这一步至关重要。它会下载所需的模型,并尝试将
clipPython 包从 GitHub 安装到当前激活的虚拟环境中。imagesorcery-mcp --post-install
**注意:**使用此方法时,需要在 MCP 客户端配置中提供可执行文件的完整路径(例如,/full/path/to/venv/bin/imagesorcery-mcp)。
安装后脚本会执行什么操作?
`imagesorcery-mcp --post-install` 脚本会执行以下操作:- 在当前目录中创建
config.toml配置文件,方便用户自定义默认工具参数。 - 创建
models目录(通常位于虚拟环境的 site-packages 目录中;如果是全局安装,则位于用户专属位置),用于存储预训练模型。 - 在该目录中生成初始的
models/model_descriptions.json文件。 - 将
detect工具所需的默认 YOLO 模型(yoloe-11l-seg-pf.pt、yoloe-11s-seg-pf.pt、yoloe-11l-seg.pt、yoloe-11s-seg.pt)下载到此models目录中。 - 尝试从 Ultralytics 的 GitHub 仓库将
clipPython 包安装到当前 Python 环境中。find工具的文本提示词功能需要此包。 - 将
find工具所需的 CLIP 模型文件下载到models目录中。
你可以随时运行此流程,以恢复默认模型并尝试安装 clip。
`uv` 用户的重要说明(uv venv 和 uvx)
-
使用
uv venv创建虚拟环境: 根据测试,使用uv venv创建的虚拟环境可能未以适当方式包含pip,导致imagesorcery-mcp --post-install脚本无法自动从 GitHub 安装clip包(安装clip时可能出现 “No module named pip” 错误)。 如果选择使用uv venv:- 创建并激活
uv venv。 - 安装
imagesorcery-mcp:uv pip install imagesorcery-mcp。 - 手动将
clip包安装到当前激活的uv venv中:uv pip install git+https://github.com/ultralytics/CLIP.git - 运行
imagesorcery-mcp --post-install。此操作会下载模型,但可能无法安装clipPython 包。 若要通过安装后脚本更顺利地自动安装clip,建议使用python -m venv(如上文步骤 1 所述)创建虚拟环境。
- 创建并激活
-
使用
uvx imagesorcery-mcp --post-install: 直接使用uvx运行安装后脚本(例如uvx imagesorcery-mcp --post-install)很可能无法安装clipPython 包。这是因为uvx创建的临时环境通常没有可供脚本使用的pip。模型会下载,但此命令不会安装clip包。 如果你打算使用uvx运行主要的imagesorcery-mcp服务,并且需要clip功能,则需要确保clip包已安装在uvx可找到的 Python 环境中;或者考虑将imagesorcery-mcp安装到使用python -m venv创建的持久环境中。
⚙️ 配置 MCP 客户端
将以下设置添加到 MCP 客户端中。
适用于 pipx 安装(推荐):
"mcpServers": {
"imagesorcery-mcp": {
"command": "imagesorcery-mcp",
"transportType": "stdio",
"autoApprove": ["blur", "change_color", "config", "crop", "detect", "draw_arrows", "draw_circles", "draw_lines", "draw_rectangles", "draw_texts", "fill", "find", "get_metainfo", "ocr", "overlay", "resize", "rotate"],
"timeout": 100
}
}
适用于手动 venv 安装:
"mcpServers": {
"imagesorcery-mcp": {
"command": "/full/path/to/venv/bin/imagesorcery-mcp",
"transportType": "stdio",
"autoApprove": ["blur", "change_color", "config", "crop", "detect", "draw_arrows", "draw_circles", "draw_lines", "draw_rectangles", "draw_texts", "fill", "find", "get_metainfo", "ocr", "overlay", "resize", "rotate"],
"timeout": 100
}
}
如果你在 HTTP 模式下使用该服务,请将客户端配置为连接到 HTTP 端点:
"mcpServers": {
"imagesorcery-mcp": {
"url": "http://127.0.0.1:8000/mcp", // Use your custom host, port, and path if specified
"transportType": "http",
"autoApprove": ["blur", "change_color", "config", "crop", "detect", "draw_arrows", "draw_circles", "draw_lines", "draw_rectangles", "draw_texts", "fill", "find", "get_metainfo", "ocr", "overlay", "resize", "rotate"],
"timeout": 100
}
}
适用于 Windows
适用于 pipx 安装(推荐):
"mcpServers": {
"imagesorcery-mcp": {
"command": "imagesorcery-mcp.exe",
"transportType": "stdio",
"autoApprove": ["blur", "change_color", "config", "crop", "detect", "draw_arrows", "draw_circles", "draw_lines", "draw_rectangles", "draw_texts", "fill", "find", "get_metainfo", "ocr", "overlay", "resize", "rotate"],
"timeout": 100
}
}
适用于手动 venv 安装:
"mcpServers": {
"imagesorcery-mcp": {
"command": "C:\\full\\path\\to\\venv\\Scripts\\imagesorcery-mcp.exe",
"transportType": "stdio",
"autoApprove": ["blur", "change_color", "config", "crop", "detect", "draw_arrows", "draw_circles", "draw_lines", "draw_rectangles", "draw_texts", "fill", "find", "get_metainfo", "ocr", "overlay", "resize", "rotate"],
"timeout": 100
}
}
某些工具需要在 models 目录中提供特定模型:
# Download models for the detect tool
download-yolo-models --ultralytics yoloe-11l-seg
download-yolo-models --huggingface ultralytics/yolov8:yolov8m.pt
关于模型描述
下载模型时,脚本会自动更新 models/model_descriptions.json 文件:
-
对于 Ultralytics 模型:描述预先定义在
src/imagesorcery_mcp/scripts/create_model_descriptions.py中,其中包含每个模型的用途、大小和特征等详细信息。 -
对于 Hugging Face 模型:描述会自动从 Hugging Face Hub 上的模型卡提取。脚本会尝试使用模型索引中的模型名称或描述的第一行。
下载模型后,建议检查 models/model_descriptions.json 中的描述,并根据需要进行调整,以便更准确或详细地说明模型的功能和使用场景。
运行服务
ImageSorcery MCP 服务可通过不同模式运行:
STDIO- 默认模式Streamable HTTP- 用于基于 Web 的部署Server-Sent Events (SSE)- 用于依赖 SSE 的基于 Web 的部署
关于不同模式:
-
STDIO 模式(默认) - 这是本地 MCP 客户端的标准模式:
imagesorcery-mcp -
Streamable HTTP 模式 - 用于基于 Web 的部署:
imagesorcery-mcp --transport=streamable-http使用自定义主机、端口和路径:
imagesorcery-mcp --transport=streamable-http --host=0.0.0.0 --port=4200 --path=/custom-path
可用的传输选项:
--transport:在 "stdio"(默认)、"streamable-http" 或 "sse" 之间选择--host:指定基于 HTTP 的传输所用的主机(默认:127.0.0.1)--port:指定基于 HTTP 的传输所用的端口(默认:8000)--path:指定基于 HTTP 的传输所用的端点路径(默认:/mcp)
🔐 文件访问限制
默认情况下,ImageSorcery MCP 不限制文件路径。若要将工具限制为仅访问特定目录,请将 IMAGESORCERY_AVAILABLE_PATHS 设置为一个或多个允许的目录。
请使用平台的路径列表分隔符(Linux/macOS 上为 :,Windows 上为 ;)。也接受以逗号分隔的值。
IMAGESORCERY_AVAILABLE_PATHS="/home/user/images:/home/user/output" imagesorcery-mcp
设置此变量后,所有名为 path 或以 _path 结尾的工具参数都必须解析到某个允许的目录内。相对路径、.. 和 ~ 会在比较前进行规范化。不会解析符号链接,因此放置在允许目录中的链接仍可访问。
🔒 隐私与遥测
我们致力于保护您的隐私。ImageSorcery MCP 专为本地运行而设计,确保您的图像和数据保留在您的计算机上。
为了帮助我们了解哪些功能最受欢迎并更快地修复错误,我们提供了可选的匿名遥测功能。
- 默认禁用。 您必须明确选择启用。
- 收集内容: 匿名使用数据,包括使用的功能(例如
crop、detect)、应用程序版本、操作系统类型(例如 'linux'、'win32')以及工具故障。 - 绝不收集: 我们不会收集任何个人或敏感信息,包括图像数据、文件路径、IP 地址或任何其他可用于识别个人身份的信息。
- 如何启用/禁用: 您可以在
config.toml文件的[telemetry]部分中设置enabled = true或enabled = false来控制遥测功能。
⚙️ 配置服务
可以使用当前目录中的 config.toml 文件配置服务。安装过程中会自动创建该文件并写入默认值。您可以在此文件中自定义工具参数的默认值。更多信息请参阅 CONFIG.md。
🤝 参与贡献
无论您是 👤 人类还是 🤖 AI Agent,我们都欢迎您为本项目贡献力量!
目录结构
此代码库的组织结构如下:
.
├── .gitignore # Specifies intentionally untracked files that Git should ignore.
├── pyproject.toml # Configuration file for Python projects, including build system, dependencies, and tool settings.
├── pytest.ini # Configuration file for the pytest testing framework.
├── README.md # The main documentation file for the project.
├── setup.sh # A shell script for quick setup (legacy, for reference or local use).
├── models/ # This directory stores pre-trained models used by tools like `detect` and `find`. It is typically ignored by Git due to the large file sizes.
│ ├── model_descriptions.json # Contains descriptions of the available models.
│ ├── settings.json # Contains settings related to model management and training runs.
│ └── *.pt # Pre-trained model.
├── src/ # Contains the source code for the 🪄 ImageSorcery MCP server.
│ └── imagesorcery_mcp/ # The main package directory for the server.
│ ├── README.md # High-level overview of the core architecture (server and middleware).
│ ├── __init__.py # Makes `imagesorcery_mcp` a Python package.
│ ├── __main__.py # Entry point for running the package as a script.
│ ├── logging_config.py # Configures the logging for the server.
│ ├── server.py # The main server file, responsible for initializing FastMCP and registering tools.
│ ├── middleware.py # Custom middleware for improved validation error handling.
│ ├── logs/ # Directory for storing server logs.
│ ├── scripts/ # Contains utility scripts for model management.
│ │ ├── README.md # Documentation for the scripts.
│ │ ├── __init__.py # Makes `scripts` a Python package.
│ │ ├── create_model_descriptions.py # Script to generate model descriptions.
│ │ ├── download_clip.py # Script to download CLIP models.
│ │ ├── post_install.py # Script to run post-installation tasks.
│ │ └── download_models.py # Script to download other models (e.g., YOLO).
│ ├── tools/ # Contains the implementation of individual MCP tools.
│ │ ├── README.md # Documentation for the tools.
│ │ ├── __init__.py # Makes `tools` a Python package.
│ │ └── *.py # Implements the tool.
│ ├── prompts/ # Contains the implementation of individual MCP prompts.
│ │ ├── README.md # Documentation for the prompts.
│ │ ├── __init__.py # Makes `prompts` a Python package.
│ │ └── *.py # Implements the prompt.
│ └── resources/ # Contains the implementation of individual MCP resources.
│ ├── README.md # Documentation for the resources.
│ ├── __init__.py # Makes `resources` a Python package.
│ └── *.py # Implements the resource.
└── tests/ # Contains test files for the project.
├── test_server.py # Tests for the main server functionality.
├── data/ # Contains test data, likely image files used in tests.
├── tools/ # Contains tests for individual tools.
├── prompts/ # Contains tests for individual prompts.
└── resources/ # Contains tests for individual resources.
开发环境设置
- 克隆仓库:
git clone https://github.com/sunriseapps/imagesorcery-mcp.git # Or your fork
cd imagesorcery-mcp
- (推荐)创建并激活虚拟环境:
python -m venv venv
source venv/bin/activate # For Linux/macOS
# venv\Scripts\activate # For Windows
- 以可编辑模式安装软件包及开发依赖:
pip install -e ".[dev]"
这将安装 imagesorcery-mcp,以及 [project.dependencies] 和 [project.optional-dependencies].dev 中的所有依赖(包括 build 和 twine)。
规则
以下规则适用于所有贡献者:人类和 AI。
-
阅读项目中的所有
README.md文件。了解项目结构和用途,并熟悉贡献指南。仔细思考这些内容与任务的关系,以及如何据此进行修改。 -
阅读
pyproject.toml。 请特别关注以下部分:[tool.ruff]、[tool.ruff.lint]、[project.optional-dependencies]和[project]dependencies。 严格遵循pyproject.toml中定义的代码风格。 使用pyproject.toml依赖项中定义的技术栈,除非有充分理由,否则不要添加新依赖。 -
在新建或现有文件中编写代码。 如果需要新依赖,请更新
pyproject.toml,并通过pip install -e .或pip install -e ".[dev]"安装。不要直接通过pip install安装依赖。 查看现有源代码以获取示例(例如src/imagesorcery_mcp/server.py、src/imagesorcery_mcp/tools/crop.py)。遵循现有代码的风格、命名约定、输入和输出数据格式、代码结构、架构等。 -
根据所做更改更新相关的
README.md文件。 遵循现有README.md文件的格式和结构。 -
为代码编写测试。 查看现有测试以获取示例(例如
tests/test_server.py、tests/tools/test_crop.py)。 遵循现有测试的风格、命名约定、输入和输出数据格式、代码结构、架构等。 -
运行测试和代码检查工具,确保一切正常:
pytest
ruff check .
如果失败,请修复代码和测试。必须确保所有新增代码符合代码检查规则并通过所有测试。
编码提示
- 适当使用类型提示
- 使用 pydantic 进行数据验证和序列化
📝 有疑问?
如果你对本项目有任何疑问、问题或建议,欢迎联系:
你也可以在仓库中提交 issue,报告错误或提出功能请求。
📜 许可证
本项目采用 MIT License。这意味着你可以自由使用、修改和分发本软件,但须遵守 MIT License 的条款和条件。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。

😉 提示: 使用文件的完整路径”。
😉 提示: 指定模型和置信度”。