
lalanikarim/comfy-mcp-server
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
lalanikarim/comfy-mcp-server は [https://github.com/lalanikarim/comfy-mcp-server.] からインポートされた MCP サーバーの候補です
概要
lalanikarim/comfy-mcp-server は [https://github.com/lalanikarim/comfy-mcp-server.] からインポートされた MCP サーバーの候補です
概要(AI 翻訳)
リモートComfyサーバーを介してプロンプトに基づいて画像を生成するためにFastMCPフレームワークを使用してサーバー。
概要
このスクリプトは、FastMCPフレームワークを使用してサーバーを設定し、指定されたワークフローを使用してプロンプトに基づいて画像を生成します。 リモートのComfyサーバーと連携して、プロンプトを送信して生成された画像を取得できます。
前提条件
- Python用のUVパッケージとプロジェクトマネージャ。
- Comfy UIからエクスポートされたワークフローファイル。 このコードには、参照としてのみ使用しているサンプル[
Flux-Dev-ComfyUI-Workflow.jsonが含まれています。 ワークフローからエクスポートし、それに応じて環境変数を設定する必要があります。
ローカル開発に必要なパッケージをインストールできます。
設定
次の環境変数を設定します。
- [
COMFY_URL] で、Comfy サーバー URL を指す。 - [
COMFY_WORKFLOW_JSON_FILEは、comfyui ワークフローの API エクスポート json ファイルの絶対パスを指す。 PROMPT_NODE_IDテキストプロンプトノードの id へ。- [
OUTPUT_NODE_ID] は、出力ノードの id に最終イメージをつけます。 - [[
OUTPUT_MODE] または [file] のいずれかを選択して、目的の出力を選択します。
必要に応じて、Ollamaサーバーが稼働している場合は、プロンプト生成のために接続できます.
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
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.jsonwhich 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:
uvx mcp[cli]
Configuration
Set the following environment variables:
COMFY_URLto point to your Comfy server URL.COMFY_WORKFLOW_JSON_FILEto point to the absolute path of the API export json file for the comfyui workflow.PROMPT_NODE_IDto the id of the text prompt node.OUTPUT_NODE_IDto the id of the output node with the final image.OUTPUT_MODEto eitherurlorfileto select desired output.
Optionally, if you have an Ollama server running, you can connect to it for prompt generation.
OLLAMA_API_BASEto the url where ollama is running.PROMPT_LLMto the name of the model hosted on ollama for prompt generation.
Example:
export COMFY_URL=http://your-comfy-server-url:port
export COMFY_WORKFLOW_JSON_FILE=/path/to/the/comfyui_workflow_export.json
export PROMPT_NODE_ID=6 # use the correct node id here
export OUTPUT_NODE_ID=9 # use the correct node id here
export OUTPUT_MODE=file
Usage
Comfy MCP Server can be launched by the following command:
uvx comfy-mcp-server
Example Claude Desktop Config
{
"mcpServers": {
"Comfy MCP Server": {
"command": "/path/to/uvx",
"args": [
"comfy-mcp-server"
],
"env": {
"COMFY_URL": "http://your-comfy-server-url:port",
"COMFY_WORKFLOW_JSON_FILE": "/path/to/the/comfyui_workflow_export.json",
"PROMPT_NODE_ID": "6",
"OUTPUT_NODE_ID": "9",
"OUTPUT_MODE": "file",
}
}
}
}
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
インストール
uvx mcp[cli]設定
{
"mcpServers": {
"Comfy MCP Server": {
"command": "/path/to/uvx",
"args": [
"comfy-mcp-server"
],
"env": {
"COMFY_URL": "http://your-comfy-server-url:port",
"COMFY_WORKFLOW_JSON_FILE": "/path/to/the/comfyui_workflow_export.json",
"PROMPT_NODE_ID": "6",
"OUTPUT_NODE_ID": "9",
"OUTPUT_MODE": "file",
}
}
}
}