Integrations
Comfy MCP Server
A server using FastMCP framework to generate images based on prompts via a remote Comfy server.
Overview
This script sets up a server using the FastMCP framework to generate images based on prompts using a specified workflow. It interacts with a remote Comfy server to submit prompts and retrieve generated images.
Prerequisites
- uv package and project manager for Python.
- Workflow file exported from Comfy UI. This code includes a sample
Flux-Dev-ComfyUI-Workflow.json
which is only used here as reference. You will need to export from your workflow and set the environment variables accordingly.
You can install the required packages for local development:
Configuration
Set the following environment variables:
COMFY_URL
to point to your Comfy server URL.COMFY_WORKFLOW_JSON_FILE
to point to the absolute path of the API export json file for the comfyui workflow.PROMPT_NODE_ID
to the id of the text prompt node.OUTPUT_NODE_ID
to the id of the output node with the final image.OUTPUT_MODE
to eitherurl
orfile
to select desired output.
Optionally, if you have an Ollama server running, you can connect to it for prompt generation.
OLLAMA_API_BASE
to the url where ollama is running.PROMPT_LLM
to the name of the model hosted on ollama for prompt generation.
Example:
Usage
Comfy MCP Server can be launched by the following command:
Example Claude Desktop Config
Functionality
generate_image(prompt: str, ctx: Context) -> Image | str
This function generates an image using a specified prompt. It follows these steps:
- Checks if all the environment variable are set.
- Loads a prompt template from a JSON file.
- Submits the prompt to the Comfy server.
- Polls the server for the status of the prompt processing.
- Retrieves and returns the generated image once it's ready.
generate_prompt(topic: str, ctx: Context) -> str
This function generates a comprehensive image generation prompt from specified topic.
Dependencies
mcp
: For setting up the FastMCP server.json
: For handling JSON data.urllib
: For making HTTP requests.time
: For adding delays in polling.os
: For accessing environment variables.langchain
: For creating simple LLM Prompt chain to generate image generation prompt from topic.langchain-ollama
: For ollama specific modules for LangChain.
License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
The Comfy MCP Server uses the FastMCP framework to generate images from prompts by interacting with a remote Comfy server, allowing automated image creation based on workflow configurations.
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityAn intelligent MCP server with a fully automated batch pipeline for web-ready images. Features include noise reduction, auto levels/curves, JPEG artifact removal, 4K resizing, smart sharpening with shadow/highlight enhancement, and advanced WebP conversion.Last updated -15JavaScriptMIT License
- -securityFlicense-qualityServer for using Dify. It achieves the invocation of the Dify workflow by calling the tools of MCP.Last updated -189Python
- AsecurityFlicenseAqualityEnables users to generate images from text prompts using Replicate's model, with configurable parameters and full MCP protocol compliance.Last updated -163TypeScript
- -securityAlicense-qualityMCP Tool Server for Logo Generation. This server provides logo generation capabilities using FAL AI, with tools for image generation, background removal, and image scaling.Last updated -159PythonGPL 3.0
Appeared in Searches
- Instructions for accessing Gmail messages programmatically using a cursor
- Exploring text-to-image generation techniques
- A flexible and user-friendly UI tool for extended functionalities
- A platform for finding and downloading stock images using keywords
- A platform for downloading images from Unsplash using specified keywords