Skip to main content
Glama

Comfy MCP Server

by lalanikarim

快適なMCPサーバー

FastMCP フレームワークを使用して、リモート Comfy サーバー経由のプロンプトに基づいて画像を生成するサーバー。

概要

このスクリプトは、FastMCPフレームワークを使用してサーバーを設定し、指定されたワークフローを使用してプロンプトに基づいて画像を生成します。リモートのComfyサーバーと連携してプロンプトを送信し、生成された画像を取得します。

前提条件

  • Python 用のuvパッケージとプロジェクト マネージャー。
  • Comfy UIからエクスポートされたワークフローファイル。このコードには、ここでは参照用としてのみ使用されるサンプルのFlux-Dev-ComfyUI-Workflow.jsonが含まれています。ワークフローからエクスポートし、環境変数を適切に設定する必要があります。

ローカル開発に必要なパッケージをインストールできます。

uvx mcp[cli]

構成

次の環境変数を設定します。

  • COMFY_URL Comfy サーバーの URL を指します。
  • COMFY_WORKFLOW_JSON_FILE 、comfyui ワークフローの API エクスポート json ファイルの絶対パスを指します。
  • PROMPT_NODE_IDテキストプロンプトノードの ID に設定します。
  • OUTPUT_NODE_ID最終画像を含む出力ノードの ID に設定します。
  • OUTPUT_MODE``urlまたはfileに設定して、必要な出力を選択します。

オプションとして、 Ollamaサーバーが実行中の場合は、プロンプトを生成するためにサーバーに接続できます。

  • OLLAMA_API_BASE ollama が実行されている URL に設定します。
  • PROMPT_LLMプロンプト生成用の ollama でホストされているモデルの名前に設定します。

例:

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

使用法

Comfy MCP Server は次のコマンドで起動できます。

uvx comfy-mcp-server

Claude デスクトップ設定の例

{ "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", } } } }

機能性

generate_image(prompt: str, ctx: Context) -> Image | str

この関数は、指定されたプロンプトを使用して画像を生成します。以下の手順に従います。

  1. すべての環境変数が設定されているかどうかを確認します。
  2. JSON ファイルからプロンプト テンプレートを読み込みます。
  3. プロンプトを Comfy サーバーに送信します。
  4. プロンプト処理のステータスをサーバーにポーリングします。
  5. 生成された画像が準備できたら取得して返します。

generate_prompt(topic: str, ctx: Context) -> str

この関数は、指定されたトピックから包括的な画像生成プロンプトを生成します。

依存関係

  • mcp : FastMCP サーバーをセットアップします。
  • json : JSON データを処理します。
  • urllib : HTTP リクエストを行うため。
  • time : ポーリングに遅延を追加します。
  • os : 環境変数にアクセスします。
  • langchain : トピックから画像生成プロンプトを生成するためのシンプルな LLM プロンプト チェーンを作成します。
  • langchain-ollama : LangChain の ollama 固有のモジュール用。

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

-
security - not tested
A
license - permissive license
-
quality - not tested

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.

Comfy MCP サーバーは、FastMCP フレームワークを使用して、リモート Comfy サーバーと対話することでプロンプトからイメージを生成し、ワークフロー構成に基づいてイメージを自動的に作成できるようにします。

  1. 概要
    1. 前提条件
      1. 構成
        1. 使用法
          1. Claude デスクトップ設定の例
        2. 機能性
          1. generate_image(prompt: str, ctx: Context) -> Image | str
          2. generate_prompt(topic: str, ctx: Context) -> str
        3. 依存関係
          1. ライセンス

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              An 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 -
              1
              5
              JavaScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              Server for using Dify. It achieves the invocation of the Dify workflow by calling the tools of MCP.
              Last updated -
              189
              Python
            • A
              security
              F
              license
              A
              quality
              Enables users to generate images from text prompts using Replicate's model, with configurable parameters and full MCP protocol compliance.
              Last updated -
              1
              63
              TypeScript
            • -
              security
              A
              license
              -
              quality
              MCP 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 -
              159
              Python
              GPL 3.0
              • Apple
              • Linux

            View all related MCP servers

            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/lalanikarim/comfy-mcp-server'

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