Back to MCP directory
publicPublicdnsLocal runtime

draw-things-mcp-cursor

Draw Things API与Cursor的集成工具,通过MCP协议实现AI图像生成功能

article

README

🚀 绘制事物 MCP

本项目可使用模型上下文协议(MCP)将Draw Things API集成到Cursor中,为图像生成提供便利,让用户能在Cursor环境下轻松生成所需图像。

🚀 快速开始

要使用本项目,需要满足一定的先决条件,完成安装,并进行相应的集成设置。

✨ 主要特性

  • 可将Draw Things API集成到Cursor中,方便在Cursor环境下使用。
  • 支持多种参数设置,如图像的宽高、生成步骤数、使用的模型等,满足不同的图像生成需求。
  • 提供了清晰的响应格式,便于处理成功和错误情况。

📦 安装指南

全局安装

npm install -g draw-things-mcp-cursor

直接运行

npx draw-things-mcp-cursor

💻 使用示例

基础用法

在Cursor中使用

要在Cursor中设置此工具,请参阅cursor-setup.md中的详细指南。快速设置步骤如下:

  1. 创建或编辑~/.cursor/claude_desktop_config.json
{
  "mcpServers": {
    "draw-things": {
      "command": "draw-things-mcp-cursor",
      "args": []
    }
  }
}
  1. 重启Cursor
  2. 在Cursor中使用:generateImage({"prompt": "a cute cat"})

在CLI中使用

echo '{"prompt": "your prompt here"}' | npx draw-things-mcp-cursor

高级用法

CLI中使用更多参数

echo '{
  "prompt": "a happy smiling dog, professional photography",
  "negative_prompt": "ugly, deformed, blurry",
  "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目录中,文件名为:<sanitized_prompt>_<timestamp>.png

📚 详细文档

参数说明

| 参数 | 详情 | |------|------| | 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。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client