使用模型上下文协议(MCP)将Draw Things API集成到Cursor中。
# 全局安装
npm install -g draw-things-mcp-cursor
# 或直接运行
npx draw-things-mcp-cursor
要在Cursor中设置此工具,请参阅此处的详细指南。
快速设置:
~/.cursor/claude_desktop_config.json:{
"mcpServers": {
"draw-things": {
"command": "draw-things-mcp-cursor",
"args": []
}
}
}
generateImage({"prompt": "一只可爱的猫"})echo '{"prompt": "在这里输入提示"}' | npx draw-things-mcp-cursor
prompt: 图像生成的文本提示(必需)negative_prompt: 图像生成的负面提示width: 图像宽度(默认:360)height: 图像高度(默认:360)steps: 生成步骤数(默认:8)model: 用于生成的模型(默认:"flux_1_schnell_q5p.ckpt")sampler: 抽样方法(默认:"DPM++ 2M AYS")示例:
echo '{
"prompt": "一只快乐微笑的狗,专业摄影",
"negative_prompt": "丑陋、畸形、模糊",
"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目录中,文件名格式为:
<已清理提示>_<时间戳>.png
成功:
{
"type": "success",
"content": [{
"type": "image",
"data": "base64编码的图像数据",
"mimeType": "image/png"
}],
"metadata": {
"parameters": { ... }
}
}
错误:
{
"type": "error",
"error": "错误消息",
"code": 500
}
如果遇到问题:
~/.cursor/logs中的日志文件chmod +x src/index.jsMIT