LM Studio + ComfyUI: local image generation setup

Learn to connect LM Studio to ComfyUI through a Python MCP server on Windows, using an API workflow export and a model with tool calling.

Player not loading? Watch on YouTube

This tutorial connects LM Studio's chat interface to a ComfyUI text-to-image workflow through a Python MCP server. The presenter demonstrates the setup on Windows and describes the resulting image generation as local and offline. The setup process includes downloads and uses Claude to generate the bridge code.

The walkthrough starts with Python, including the Windows option to add it to PATH, then installs MCP dependencies. The presenter uses Stability Matrix to launch ComfyUI and instructs viewers to start it before LM Studio. In ComfyUI, viewers enable developer mode and export their workflow with Export API. Workflow filenames and folder paths need to match the bridge configuration.

The supplied code-generation prompt requests a Python script that reads the workflow, replaces its positive prompt and polls until image generation finishes. It also requests an mcp.json configuration for LM Studio. Viewers provide their workflow path, output directory and ComfyUI address, shown as http://127.0.0.1:8188.

LM Studio needs a local LLM with tool calling, identified in the tutorial by a hammer icon. The presenter recommends a smaller language model because it runs alongside the image model. After enabling the MCP tool and approving access, the demonstration returns an image file location. Hardware capacity affects workflow choice; image editing and image-to-image generation fall outside this tutorial's scope.