返回市场
绘图事物mcp光标

绘图事物mcp光标

作者:jaokuohsuan12 星标更新:2025-03-12

项目介绍

Draw Things MCP

使用模型上下文协议(MCP)将Draw Things API集成到Cursor中。

预备条件

安装

# 全局安装
npm install -g draw-things-mcp-cursor

# 或直接运行
npx draw-things-mcp-cursor

Cursor集成

要在Cursor中设置此工具,请参阅此处的详细指南

快速设置:

  1. 创建或编辑~/.cursor/claude_desktop_config.json
{
  "mcpServers": {
    "draw-things": {
      "command": "draw-things-mcp-cursor",
      "args": []
    }
  }
}
  1. 重启Cursor
  2. 在Cursor中使用: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

MCP工具集成

当作为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
}

故障排除

如果遇到问题:

  • 确保Draw Things API在http://127.0.0.1:7888上运行
  • 如果与Cursor一起使用,请检查~/.cursor/logs中的日志文件
  • 确保src/index.js具有执行权限:chmod +x src/index.js

许可证

MIT