Skip to main content
Glama

LM Studio → ComfyUI Image Generator

ComfyUI MCP Server

An MCP(模型上下文协议)服务器,将 ComfyUI 的图像和 3D 生成功能暴露为单一工具。
它会自动分类你的提示词(人物、建筑、通用或 3D),并自动选择正确的工作流。

非常适合 AI 助手 – 通过 MCP 连接,让你的 LLM 直接生成资源。


功能

  • 🧠 智能提示词分类 – 检测你想要的是一张人物、建筑还是 3D 模型。

  • 🖼️ 2D 生成 – 使用你自己的 ComfyUI 工作流(generalpeoplebuildings)。

  • 🤖 3D 生成(Hunyuan3D) – 首先生成参考图,然后运行 3D 工作流。

  • 🔌 MCP 工具 – 向任何 MCP 客户端暴露 generate_asset_tool(prompt, workflow_type, size)

  • 📂 工作流文件夹 – 将你的 .json 工作流放入 ./workflows/


设置

1. 先决条件

  • Python 3.10+

  • ComfyUI 在本地运行并启用 API(默认 http://127.0.0.1:8188)。

  • 你的 ComfyUI 工作流导出为 .json 文件。

2. 安装依赖

pip install -r requirements.txt

3. 放置你的工作流

将你的 ComfyUI 工作流 JSON 文件放入 workflows/ 文件夹。 文件名必须完全匹配:

general.json

people.json

buildings.json

3d_simple.json

⚠️ 3D 重要提示:你的 3d_simple.json 必须包含一个 ID 为 "26" 的 LoadImage 节点。代码会将上传的参考图像注入到 workflow["26"]["inputs"]["image"] 中。

  1. 配置(可选) 创建一个 .env 文件来覆盖 ComfyUI URL:

text COMFY_URL=http://127.0.0.1:8188 如果未设置,则默认为 http://127.0.0.1:8188

用法 运行 MCP 服务器 bash python mcp_server.py 服务器将启动并注册工具 generate_asset_tool。

工具参数 prompt (str, required):要生成内容的描述。

workflow_type (str, optional):"people"、"buildings"、"general" 或 "3d_simple"。如果省略 – 自动检测。

size (str, optional):"512x512"、"512x768" 或 "768x512"。如果省略 – 自动选择。

来自 MCP 客户端的示例 json { "tool": "generate_asset_tool", "arguments": { "prompt": "a futuristic cyberpunk girl with neon hair" } } → 自动检测为人物,使用 people.json,尺寸 512x768,返回图像 URL。

json { "tool": "generate_asset_tool", "arguments": { "prompt": "turn this into a 3d model: a wooden chair", "workflow_type": "3d_simple" } } → 生成参考图像(通过 general),然后对其运行 3d_simple.json。返回两个 URL。

工作原理 分类 – 扫描你的提示词中的关键词(girl、building、3d 等),以选择正确的工作流和分辨率。

提示词注入 – 查找 CLIPTextEncode 节点,并填充正向提示词(用户提示词)和负向提示词(内置预设)。

随机种子 – 随机化 KSampler 种子,确保每次结果都独一无二。

队列与轮询 – 通过 /prompt 将工作流发送到 ComfyUI,并轮询 /history 直到结果准备就绪。

输出 – 返回完整的 URL,用于查看/下载生成的文件。

错误处理 如果 ComfyUI 未运行 – 返回 ERROR

失败时 – 自动重试最多 2 次。

详细日志会打印到控制台。

-
license - not tested
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • MCP server for Wan AI video generation

  • MCP server for Flux AI image generation

  • MCP server for Hailuo (MiniMax) AI video generation

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vovchanskuy2/Comfy-Generation-tool-for-lmstudio'

If you have feedback or need assistance with the MCP directory API, please join our Discord server