本项目可使用模型上下文协议(MCP)将Draw Things API集成到Cursor中,为图像生成提供便利,让用户能在Cursor环境下轻松生成所需图像。
要使用本项目,需要满足一定的先决条件,完成安装,并进行相应的集成设置。
npm install -g draw-things-mcp-cursor
npx draw-things-mcp-cursor
要在Cursor中设置此工具,请参阅cursor-setup.md中的详细指南。快速设置步骤如下:
~/.cursor/claude_desktop_config.json:{
"mcpServers": {
"draw-things": {
"command": "draw-things-mcp-cursor",
"args": []
}
}
}
generateImage({"prompt": "a cute cat"})echo '{"prompt": "your prompt here"}' | npx draw-things-mcp-cursor
echo '{
"prompt": "a happy smiling dog, professional photography",
"negative_prompt": "ugly, deformed, blurry",
"width": 360,
"height": 360,
"steps": 4
}' | npx draw-things-mcp-cursor
当作为Cursor中的MCP工具使用时,工具将注册为generateImage,具有以下参数:
{
prompt: string; // 必需 - 生成图像的提示文本
negative_prompt?: string; // 可选 - 负面提示
width?: number; // 可选 - 图像宽度(默认:360)
height?: number; // 可选 - 图像高度(默认:360)
model?: string; // 可选 - 模型名称
steps?: number; // 可选 - 步骤数(默认:8)
}
生成的图像将保存在images目录中,文件名为:
| 参数 | 详情 |
|---|---|
prompt |
必需,生成图像的文字提示 |
negative_prompt |
可选,负面提示用于生成图像 |
width |
可选,图像宽度,默认值为360 |
height |
可选,图像高度,默认值为360 |
steps |
可选,生成步骤数,默认值为8 |
model |
可选,使用的生成模型,默认值为"flux_1_schnell_q5p.ckpt" |
sampler |
可选,抽样方法,默认值为"DPM++ 2M AYS" |
{
"type": "success",
"content": [{
"type": "image",
"data": "base64编码的图像数据",
"mimeType": "image/png"
}],
"metadata": {
"parameters": { ... }
}
}
{
"type": "error",
"error": "错误信息",
"code": 500
}
本项目使用模型上下文协议(MCP)将Draw Things API集成到Cursor中。当作为Cursor中的MCP工具使用时,工具会注册为generateImage,并根据传入的参数进行图像生成。生成的图像会以指定的文件名保存在images目录中。同时,项目提供了清晰的响应格式,方便用户处理成功和错误情况。
本项目采用MIT许可证。
⚠️ 重要提示
遇到问题时,请确保Draw Things API在http://127.0.0.1:7888上运行;如果使用Cursor,请检查
~/.cursor目录中的日志文件;确保Node.js版本为>=14.0.0。