关于 Mcp Drawthings
Mcp Drawthings 是连接 Draw Things 与 LLM 的 MCP 服务,让 Mac 上的图像生成和转换可由 MCP 客户端调用。它提供模型与设置查询,并在本地处理图像。
主要功能
- 01根据提示词生成图像
- 02通过提示词转换图像
- 03查询当前配置和已加载模型
- 04在 Mac 本地处理图像生成
适用场景
- 01从文字描述生成图像
- 02基于现有图像制作变体
- 03检查 Draw Things 服务和模型状态
MCP 相关
该 MCP 服务向客户端提供状态检查、配置查询、文生图和图生图工具,并通过 HTTP 调用 Draw Things。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
4收录的工具列表 · 更新于 2 周前
此工具无需参数。
详细介绍
mcp-drawthings
适用于 Draw Things 的 MCP(Model Context Protocol)服务——让大模型能够在 Mac 上使用 Stable Diffusion 和其他 AI 模型本地生成图像。
功能
- 文本生成图像 - 使用 Draw Things 中当前加载的模型,根据文本提示词生成图像
- 图像转换 - 使用文本提示词转换现有图像
- 配置访问 - 查询当前 Draw Things 设置和已加载的模型
- 本地处理 - 所有图像生成均在 Mac 上使用 Apple Silicon(M1/M2/M3/M4)本地运行
前提条件
- 搭载 Apple Silicon(M1/M2/M3/M4)的 macOS
- 已安装 Draw Things 应用
- Node.js 18 或更高版本
设置
1. 启用 Draw Things API 服务
- 打开 Draw Things
- 点击齿轮图标(⚙️)打开设置
- 启用 API Server / HTTP Server
- 服务默认运行在端口 7860
确认服务正在运行:
curl http://localhost:7860
2. 配置 MCP 客户端
Claude Desktop
添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"drawthings": {
"command": "npx",
"args": ["-y", "mcp-drawthings"]
}
}
}
Cursor
添加到项目中的 .cursor/mcp.json 或全局配置中:
{
"mcpServers": {
"drawthings": {
"command": "npx",
"args": ["-y", "mcp-drawthings"]
}
}
}
3. 重启 MCP 客户端
重启 Claude Desktop 或 Cursor,以加载新的 MCP 服务。
可用工具
check_status
检查 Draw Things API 服务是否正在运行且可访问。
get_config
获取当前 Draw Things 配置,包括已加载的模型和设置。
generate_image
根据文本提示词生成图像。
参数:
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
prompt | string | 是 | 要生成图像的文本描述 |
negative_prompt | string | 否 | 要从生成图像中排除的元素 |
width | number | 否 | 图像宽度(像素,默认值:512) |
height | number | 否 | 图像高度(像素,默认值:512) |
steps | number | 否 | 推理步数(默认值:20) |
cfg_scale | number | 否 | 引导比例(默认值:7.5) |
seed | number | 否 | 用于复现结果的随机种子(-1 表示随机) |
output_path | string | 否 | 保存图像的自定义文件路径 |
示例:
Generate an image of a futuristic city at sunset with flying cars
transform_image
使用文本提示词转换现有图像(img2img)。
参数:
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
prompt | string | 是 | 所需转换效果的文本描述 |
image_path | string | 否* | 源图像文件的路径 |
image_base64 | string | 否* | Base64 编码的源图像 |
negative_prompt | string | 否 | 要排除的元素 |
denoising_strength | number | 否 | 转换强度 0.0-1.0(默认值:0.75) |
steps | number | 否 | 推理步数(默认值:20) |
cfg_scale | number | 否 | 引导比例(默认值:7.5) |
seed | number | 否 | 随机种子(-1 表示随机) |
output_path | string | 否 | 保存结果的自定义文件路径 |
*必须提供 image_path 或 image_base64。
配置
环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
DRAWTHINGS_HOST | localhost | Draw Things API 主机 |
DRAWTHINGS_PORT | 7860 | Draw Things API 端口 |
DRAWTHINGS_OUTPUT_DIR | ~/Pictures/drawthings-mcp | 生成图像的目录 |
架构
┌─────────────────┐ stdio ┌──────────────────┐ HTTP ┌─────────────┐
│ MCP Client │◄──────────────►│ mcp-drawthings │◄────────────►│ Draw Things │
│ (Claude/Cursor) │ JSON-RPC │ │ localhost │ App │
└─────────────────┘ └──────────────────┘ :7860 └─────────────┘
│
▼
┌──────────────┐
│ File System │
│ (images) │
└──────────────┘
开发
# Clone the repository
git clone https://github.com/james-see/mcp-drawthings
cd mcp-drawthings
# Install dependencies
npm install
# Build
npm run build
# Run in development mode
npm run dev
故障排除
“无法连接到 Draw Things API”
- 确保 Draw Things 正在运行
- 检查 Draw Things 设置中是否已启用 API Server
- 确认服务可访问:
curl http://localhost:7860 - 检查 Draw Things 是否配置了其他端口
无法生成图像
- 确保 Draw Things 中已加载模型
- 检查 Draw Things 中是否有任何错误消息
- 先尝试直接在 Draw Things 中生成图像
保存图像时出现权限错误
请检查输出目录是否可写。你可以使用 DRAWTHINGS_OUTPUT_DIR 环境变量设置自定义目录。
许可证
MIT
相关项目
- Draw Things - 适用于 Mac/iOS 的 AI 图像生成应用
- Model Context Protocol - 协议规范
- @modelcontextprotocol/sdk - MCP 的 TypeScript SDK
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。