comfyui-loop-mcp
comfyui-loop-mcp

あなた自身の ComfyUI のためのループ対応 MCP サーバーです。 API を呼び出すだけではありません。ループを実行します: build → run → look → critique → fix、出力が実際にブリーフを満たすまで。
node_errors がゼロで実行されるグラフは、正しいのではなく、有効です。ゆがんだ手、ずれた背景、硬いマットエッジ、目に見えるタイルの継ぎ目 — そのどれもエラーログには現れません。ピクセルにのみ現れます。だからこそ、すべてのツール説明、すべてのツール応答、そしてサーバー自身の指示は、モデルがグラフを完成と宣言する前に look するよう促します。
他の誰も持っていない部分: ラチェットはツールであって、提案ではありません。 ほとんどのエージェントツールは ComfyUI を駆動します。これはループを管理します — 長いループではコンテキストが圧縮され、その瞬間に記憶されていた "best-so-far" は消えてしまいます: ラチェットは静かにラチェットを止め、モデルはすでに拒否した変更を再試行し、最終回答としてリグレッションを渡してしまうことがあります。だから、最良のグラフと台帳は、モデルのメモリではなく、ディスク上にあります。元に戻すことは、思い出しの行為ではなく、ツール呼び出しです。
loop_start ─▶ submit ─▶ get_result ─▶ get_image ─▶ compare_images ─▶ loop_record ─┐
▲ (LOOK) (what moved?) (ratchet) │
└─────────────────── revert to best, try something else ◀─────────────────┘
↓ can't name a defect?
loop_finish + loop_report → sign-offこの手法はサーバーに同梱されています。ループプロンプトと Claude Code スキルは comfy_loop/docs/ にあり、wheel にパッケージされているので、comfy_loop / comfy_skill / comfy_install はサーバーがインストールされている場所からそれらをそのまま提供します — 単一ソース、同期を保つものはありません。(これらはもともと comfyui-llm-onboarding-prompt で始まりましたが、そのリポジトリはもはやメンテナンスされておらず、現在はこのリポジトリで保管されています。)
Comfy 自身の MCP サーバーとの比較 — ローカルとクラウドの両方を正直に
デザインの位置づけ: 発見 vs 修復 — ローカルツールが本当に勝つ/負ける場所、そしてノーススター
Comfy 自身の MCP サーバーとの比較
ComfyUI は公式サーバーを 2つ 提供しています。これは、それらと並んで構築された3つ目の存在です — 独立して、そして問題の反対側から。
Comfy-Org/comfy-mcp (最初のコミットは 2026-07-01 で、このリポジトリの翌日ですが、公開はそちらが先でした) は、ローカルの ComfyUI を comfy-cli 経由で駆動します: すべてのツールは comfy バイナリを外部プロセスとして実行し、その JSON エンベロープを解析します。Comfy Cloud MCP (https://cloud.comfy.org/mcp) は、Comfy の GPU 上でグラフを実行するリモート HTTP サーバーです。どちらも ComfyUI チームによって構築・保守されています。
これは /prompt と /object_info に直接 HTTP で通信します — CLI もアカウントも不要、httpx 以外にインストールするものもありません — そして、その機能面を、グラフが実行された後に始まる仕事の半分に費やしています。
実際の違い
彼らのローカルサーバーは、管理対象として ComfyUI インストールを扱います: 起動、停止、別バージョンへの切り替え、サインイン、ホストされたパートナーモデルへのクレジット使用、ログの追跡、パックの更新。これはこのリポジトリが持つ範囲より本当に大きく、プラットフォームベンダーが所有するのに最も適した領域です — ComfyUI や comfy-cli、パートナー API が動くたびに変化します。必要なのが インストールを駆動して保守すること なら、彼らのものを使ってください。
こちらは、管理対象を出力とみなします — それが私たちが責任を負っていた部分だからです。これは Alienrobot 自身のプロダクション業務から生まれました。そこでは、グラフが実行されることが仕事の始まりであり、終わりではありません。ここにはプロセスを起動したりクレジットを消費したりするものは何もありません。その代わりに: ピクセルをモデルに返し、2つのパスを差分してドリフトが隠れない画像にし、ブリーフが実際に要求するものを採点し、そして圧縮されたコンテキストがそれを失わないように best-so-far(現時点での最良)をディスク上に保持します。それが他の誰も持っていない部分です — /view を呼ぶのが難しいからではなく、「エージェントに look させ、リグレッションの上に構築するのを止めさせる」ことが、エンドポイントではなく規律だからです。
this repo | Comfy-Org/comfy-mcp | |
ComfyUI との通信方法 | その HTTP API( |
|
追加依存 | なし( |
|
インストールしていない ComfyUI も扱える | はい — URL が到達できるものすべて(シェルを持たないボックスを含む) | 部分的に。一部のツールは構造上ローカルのみ |
結果を見る |
|
|
結果を評価する |
| — |
最良のものを保持する |
| — |
パラメータを探索する |
|
|
グラフの事前チェック |
|
|
サブグラフテンプレート | 展開され再配線される(昇格したウィジェットは保持) | クライアント側で展開 |
探索のトークンコスト | コンパクトなノード表記( | 明言された目標ではない |
不足分のインストール | ComfyUI-Manager: | レジストリ |
ゼロから稼働まで | エージェントが行う: | ターミナルで |
ComfyUI プロセスの実行 | いいえ — 再起動のみ(Manager 経由); シェルはエージェントが所有 |
|
ホスト型/パートナーモデル、アカウント、クレジット | 意図的になし |
|
ジョブ制御 |
| 1 つの |
MCP サーフェス | 43 ツール + 2 プロンプト + 3 リソース | 39 ツール |
サイズ / ライセンス | 約 3,700 行、MIT | 約 16,000 行、AGPL-3.0-or-later または商用 |
作者 | Alienrobot — 当社自身の VFX/生成的作業のために構築され、使用されている | ComfyUI チーム、プラットフォーム本体と並行して |
対応範囲 | ループ: 発見、変換、出力の評価 | インストール全体: ライフサイクル、アカウント、パートナー API、パック |
どちらを使うか
GPU なし → Cloud MCP。ローカルにあるものは、手元にないハードウェアに対抗できない。
「インストールして、実行して、動かし続ける」 → Comfy-Org/comfy-mcp。ライフサイクル、パートナーモデル、バックグラウンドダウンロード、バージョン固定。
「最初の結果は動く、そして訓練された目がそれを拒否する」 → これ。 6 本の指、ずれた背景、硬いマットエッジ、目に見えるタイルシーム、沸騰するクリップ。それがループであり、これは完全にそのループを中心に構築されたサーバーだ。
これらは組み合わせ可能です。両方を実行することを妨げるものは何もなく、ツール名も衝突しません。
(パッケージ名は衝突しました。このリポジトリも一時的に comfy-mcp という名前でした。これは ComfyUI の名前空間を所有する人々と争っても勝ち目のない議論です。そのため comfyui-loop-mcp となり、インポートパッケージは comfy_loop で、両方をサイドバイサイドでインストールできます。)
追加しないもの
競合他社の機能リストを丸ごと取り込むと、結局は平凡なツールが 2 つになるだけです。彼らから取り入れたものは、ループが必要とするもの — 事前チェック、ジョブ状態、ログの追跡、VRAM の余裕、アップデート — だけです。意図的に除外しているものは次のとおりです:
アカウント、クレジット、ホスト型パートナーモデル。 売り文句は「あなたのマシンから何も出て行かない、サインアップ不要、メーターなし」です。クレジットゲートはそれと矛盾します。Kling や Veo を使いたいなら、向こうのサーバーが同意ゲート付きで適切に行います。このリポジトリが再発明する理由はありません。
ComfyUI プロセスの起動と停止。 HTTP クライアントは実行していないサーバーを起動できません。また、シェルを持たないボックスにこれを向けることはエッジケースではなくサポート対象です。
restart_comfyui(Manager 経由)が正直な限界です — しかし「できない」は「助けない」と同じではありません。エージェントは通常シェルを持っているので、到達不能なサーバーはこのマシン用のインストール/起動コマンドを返し、エージェントがそれらを実行することを期待します。このサーバーも Comfy-Org のものも、あなたの代わりに ComfyUI をインストールしません(向こうはターミナルでcomfy installを実行するよう促します)。違いは、ここでは指示がツール呼び出しを通して返され、それに対応できる人に向けられていることです。ワークフローの保存/共有/サービスとしての再現。
save_workflowは往復検証済みのファイルを渡します。その後それがどこに置かれるかはあなた次第です。
Related MCP server: ComfyPilot
ループにマッピングされた 3 つの MCP プリミティブ
プリミティブ | 公開内容 | ループ工程 |
ツール |
| 推測するな、発見せよ |
| 拡張(テンプレートが必要とするものをインストール) | |
| GPUが関与する前に検証 | |
| 圧縮(トークン効率の高いグラフ) | |
| 上書き付きで実績のあるテンプレートを実行(グラフはコンテキスト不要) | |
| ビルド → 実行 | |
| 見る | |
| ラチェット+台帳、ディスク上 | |
| 制御 | |
プロンプト |
| 規律全体をひとつのコマンドで |
リソース |
| 真実+ドキュメント |
3つの点が、これを単なるAPIラッパーではなくループ対応にしている:
get_imageはレンダリング済みの出力をモデルに返す——これが「見る」を現実にするステップだ。モデルは文字通りピクセルを見る。ツールの応答がループを促進する。
submit_workflowは成功時に*「有効だが正しくはない——さあ見よ」と言い、拒否時には「イテレーションではない——指定されたノードを修正して再提出せよ」と言う。get_resultは指示で締めくくる:「ここで止まるな——見て、それからパラメータを1つ変更するか、ブリーフが満たされたと宣言せよ」*。サーバー指示にはループ優先ポリシー(下記参照)が含まれており、クライアントが接続時に注入する。
ループ優先ポリシー(サーバー指示)
ハンドシェイク時にサーバーはエージェントにいつループすべきか、いつすべきでないかを伝える:
常にJSONを書く前にライブAPIから発見し、実行して検証する;
node_errorsはイテレーションではない——修正して再提出する。ループを優先するのは、訓練された目が出力を拒否しうる場合——構図/数、類似性、マット/エッジ品質、アップスケール/レストア、再ライティング、テクスチャの継ぎ目、動画の時間的安定性、「見た目を良くする」など。
ラチェット——これまでの最良を保持し、それを上回る場合のみ変更を維持し、そうでなければ元に戻して別の方法を試す;プラトーではパラメータ → 配線 → モデルの順にピボットする。ブリーフに客観的テストがある場合のみそれをゲートとし、それ以外は目視で判断する。
ループをスキップするのは機械的なタスクのみ(フォーマット変換、純粋なAPIクエリ、またはユーザーが実行可能なグラフだけを明示的に望む場合)。
迷ったときは、完了を宣言する前に少なくとも1回は見て批評するパスを行う。
ラチェット/台帳/ピボットはKarpathyのAutoResearchループから適応したもので、主観的な画像作業向けに調整されている(客観的なゲートは存在する場合のみ;永久に走らせる代わりに人間の承認チェックポイントを置く)。これらのポリシー行はサーバーの instructions +ツール応答にあり、完全なメソッドは comfy_loop プロンプトにあり、リポジトリのループドキュメントをそのまま提供する。
MCPは強制できない——能力と指針を提供するだけだ。これによりループは、エージェントが繰り返し優先するよう指示される強力で明確に範囲設定されたデフォルトとなる。Claude Codeで確実な保証を得るには、同じテキストを常時オンのスキルとしてインストールせよ:
mkdir -p ~/.claude/skills/comfyui-workflows cp comfy_loop/docs/SKILL.md ~/.claude/skills/comfyui-workflows/スキル=常時オンの規律、MCP=それが駆動するツール。これは
comfy_skillプロンプトが提供するのと同じファイルなので、両者が矛盾することはない——そして独自の古いレシピを保持する代わりに、ブートストラップはcomfy_installに委ねる。
ツールリファレンス
発見
ツール | 引数 | 戻り値 |
| — | ループステップ 0、および実際の事前チェック。何も応答しない場合、このマシン固有の対処方法を返します — 見つかったインストールを開始するか、新規作成するか、リモート URL のトンネルを開くか(トラブルシューティング を参照)。応答する場合も、ここからレンダリング成功までの間に何が立ちはだかっているかを挙げます: CPU 上で動作している torch(すべてのレンダリングは動作しますが、約50倍遅く、エラーは報告されません)、ディスク上に重みがない(完全に機能する ComfyUI だが何もレンダリングできない)、ComfyUI-Manager がない(修正するための2つのコマンド付き。 |
|
| クラス名または表示名が一致するノード(スキルのクラス限定検索の厳密なスーパーセット)。キーワードを省略すると件数を返します。 |
|
| 1つのノードのインターフェースをコンパクトな |
|
| ローダーがディスク上で提供する実際のモデルファイル(グラウンドトゥルース)を、その enum から読み取ります。レガシーリストと |
|
| ダウンロード可能なモデルのカタログ(ComfyUI-Manager のリスト)。まだ持っていない checkpoints/LoRAs/VAEs/upscalers を見つけられます。各結果はインストール済みかどうかを示します。インストールは |
|
|
|
|
| テンプレートを取得します。 |
|
| FlowZip テキストを完全な litegraph JSON に展開し直します。 |
|
| FlowZip/litegraph → API/プロンプト形式( |
|
| テンプレートの上書き可能な入力(node_id → params + 現在の値)を完全なグラフを読み込まずに一覧表示します — サブグラフ内のパラメータも含みます。また、作者自身の Note/MarkdownNote テキストも返します。そこにはトリガーワードと必要な重みが実際に含まれており、命令としてではなく信頼できないデータとして引用符付きで示されます。 |
|
| 動作確認済みのテンプレートを |
拡張(テンプレートが必要とするものをインストール — ホストに ComfyUI-Manager が必要です)
ツール | 引数 | 戻り値 |
|
| ノードクラスを |
|
| ComfyUI-Manager のキューを介してパックをインストールします(信頼されたレジストリ、任意のコードは実行されません)。その後、再起動が必要です。 |
|
|
|
| — | ComfyUI を(Manager 経由で)再起動し、新しいノードが |
|
| Manager のキューを介して ComfyUI コアおよび/またはインストール済みのすべてのパックを更新し、その後再起動が必要だと伝えます。サードパーティのコードを実行します — 先にその旨を伝えてください。ループ途中では実行しないこと: 以前のパスが古いコードに対して測定されたラチェットの下にノードの動作を移します。 |
検証 — GPU が関与する前に知り得るすべて
ツール | 引数 | 戻り値 |
|
| "これはこのマシンで実行できるか" へのひとつの答え: 所持していないノードクラス(同じパスでパック ID に解決済み)、そのローダーのリストにないモデルファイル名(実際に持っている最も近いもの付き)、未設定のままの必須入力、存在しないノードを指す接続、ノードで宣言された範囲外の値、そして出力ノードのないグラフ — これはグリーンで実行され、表示するものが何も生成されません。 |
構築 → 実行 → 確認
ツール | 引数 | 戻り値 |
|
| ローカル画像を ComfyUI の |
|
| 成功時: |
|
|
|
|
| 実際の画像をモデルに返し、ピクセルを判断できるようにします。 |
|
| 比較結果を画像として返します。 |
|
| 平均/最大絶対差分 + 変化したピクセルの割合(%) — 「意図した箇所だけを変更した」ことを確認するゲート。フレームをこっそり書き換えてしまう「小さな調整」を捕捉します。 |
|
| 要件に客観的テストがある場合の、ラチェット用の客観的スコア。 |
|
| ビデオ出力の寸法、fps、フレーム数。フレームにインデックスを付ける前に呼び出してください — 範囲が必要ですし、比較しようとしている2つのクリップがそもそも同じ長さかどうかを知る必要があります。 |
|
| ビデオ出力の1フレームをフレームインデックス指定で画像として返します。 |
|
| 両クリップの同じフレームインデックスで同じ比較を行います。タイムスタンプで比較すると、長さが異なった時点で(フレーム上限、トリム、fps の違い)静かに誤ります — 無関係な2つの瞬間を完全な自信を持って比較することになります。フレーム数が一致しない場合、警告は画像に焼き付けられ、読み飛ばせるテキストとしては残りません。 |
|
| フレーム間の不安定性を数値化したもの — 「ボイル(チラつき)するか?」に対する客観的なゲートであり、これは単一の静止画では決して示せません。単純な連続フレーム差分なので、実際の動きもカウントされます。変更前後の同じクリップに対して使うか、静的であるべき領域に |
ループは永続的な状態として — ラチェットはツールであり、記憶の訓練ではない。 長いループは圧縮される。もし現時点での最良と台帳がモデルのコンテキストにしか存在しなければ、 ラチェットは静かにラチェット動作を停止し、モデルはすでに拒否した変更を再試行し、 退行を最終結果として渡すことになる。だからそれらはディスク上に置かれる。
ツール | 引数 | 戻り値 |
|
| 実行を開始 → |
|
| パスを記録し、ラチェットを適用する。 |
|
| 同じグラフを1つの入力の最大8つの値にわたって、1回の呼び出しで実行する — 推論で到達できない値(denoise、cfg、strength)のため。他のすべては同一に保たれるため、出力はちょうど1つの変数だけが異なる。値 → |
|
| 現時点での最良のグラフ。圧縮後の真実の源 — あなたの記憶ではない。 |
|
| 追記専用のループログ:すべてのパス、何が変わったか、それが何をしたか。圧縮後にスレッドを復元する。また、承認時にユーザーに渡すログでもある。 |
|
| 収束チェックポイントで閉じ、承認のために提示する最終的な台帳と最良のグラフを返す。 |
|
| 実行全体を1つの自己完結型HTMLページとしてレンダリングする — すべてのパス、何が保持されたか、何が元に戻されたか、サムネイルはbase64でインライン化され、ComfyUIをオフにしても開ける。最終画像は何も証明しない。捨てたパスこそが、ループが収束したことを示すのだ。 |
配信
ツール | 引数 | 戻り値 |
|
| API → UI/litegraph に変換し、人間が開いて編集できるようにし、ComfyUIのワークフローリストに保存する。ラウンドトリップ検証済み:結果はAPIに変換し直され、入力と差分比較される。 |
制御
ツール | 引数 | 戻り値 |
| — | デバイス / VRAM(解像度やバッチの調整時、またはOOM後に有用)。 |
| — | 実行中と保留中のもの。 |
|
| ブロックせずに1つの実行の状態:キュー済み(位置付き)、実行中、N個の出力で完了、またはそれを殺した実行エラー。複数が進行中の場合に必要なもの — たとえば |
|
| 1つのキュー済み実行を削除する。または、そのIDが実行中のものであれば中断する。IDなしでは保留キューをクリアし、実行中のジョブには触れない。 |
| — | 現在の実行をキャンセルする。 |
|
| モデルをアンロードし、エグゼキュータのキャッシュをリセットする( |
|
| ComfyUI自身のログの末尾を表示する。そこでは失敗が自ら説明する:ノード内のトレースバック、OOM、起動時にインポートに失敗したカスタムノード(それが |
プロンプト: comfy_loop(完全自律メソッド)と comfy_skill(コンパクトな
スキル)。どちらもリポジトリのmarkdownから逐語的に提供される。さらに comfy_install —
ブートストラップ手順。サーバーが実行されているマシンに対して生成される:
すでにインストールがある場合のインストール方法、venvを構築するためのインタープリタ
(このサーバー自身のもの。Pythonが解決の前提条件になることはない)、comfy-cli と
git が存在するかどうか、そしてこのボックスのアクセラレータが実際に必要とする
torchビルド(CUDA / ROCm / MPS / なし)。サーバーはそのどれも実行できない。
エージェントは実行できる。そしてそれが宛先だ。
リソース: comfyui://object_info(ライブの完全ダンプ)、comfyui://loop-method、
comfyui://skill。
ループが実際に動くのを見る
このMCPサーバーを通じて実際のComfyUI(RTX 4090、SD1.5)に対して完全に駆動される。 ブリーフ:「暖かい木のテーブルの上の1個の赤いりんごの、くっきりとシャープに焦点の合ったマクロスタジオ写真、細かい皮の質感、豊かなディテール。」 シードは42に固定され、各パスがちょうど1つのつまみを変更し、効果が帰属可能になる。 客観的指標はラプラシアン分散(標準的なシャープネス/焦点の尺度)。

パス | 1つの変更 | シャープネス (varLap) | 見た目による判定 |
1 | ベースライン — 6ステップ、cfg 2.5 | 425 | 柔らかく、平らで、マット。最も弱い。 |
2 | ステップ 6 → 24 | 1204 | よりシャープ — ただし高い数値は木目によるもので、りんごの皮はまだプラスチックのよう。 |
3 | cfg 2.5 → 7.5 | 515 | りんごは豊かになる(彩度が上がり、皮に斑点)— 背景が柔らかくなったため指標は下がる。 |
4 | euler → dpmpp_2m + karras | 740 | 勝者。 くっきりしたハイライト、目に見える皮目、信じられる木。 |
5 | ステップ 24 → 36 | 661 | ≈ パス4。収穫逓減 → 停止。 |
ループが基づいている教訓をライブで捉えた: メトリクスはパス 2 でピークに達したが、 パス 2 が最良の画像ではない — そのスコアはリンゴのディテールではなく背景テクスチャによって 水増しされていた。勝者(パス 4)は見ることで選ばれた。緑の数字は 有効であって、正しいわけではない。(example_apple.png がそのパス 4 の結果である。)
…そしてもう半分: モデル側が間違っている場合
リンゴの例はメトリクスを盲信できない理由を示している。この実行例は モデルを盲信できない理由を示している — これこそがラチェットがツールであり プロンプトのメモではない理由そのものである。
指示: "シームレスにタイル可能な石畳テクスチャ — ラップに目に見えるシームがない"
客観的ゲート付き(measure_image → tile_seam)。シードは全体で同じため、
各パスはちょうど 1 つのことだけを変更する。以下のすべてのテクスチャは
2×2 にタイルされている — シームは隠れる場所がない。

パス | 1 つの変更 |
| ラチェット |
1 | ベースライン SDXL | h 1.77 · v 1.23 → 境界値 | 保持(初回) |
2 |
| h 0.78 · v 1.12 → シームレス | 新記録 |
3 |
| h 1.03 · v 1.56 → シーム復活 | 差し戻し |
パス 3 でモデルは loop_record に結果が "better" だと伝えた。実際は違った:
x_only は水平にタイルし、垂直方向のラップは壊れたまま — 右の画像で
石が水平の継ぎ目に沿って平らに切り落とされているのが見える。客観スコアが
その主張を覆し、パス 2 を復元し、良いグラフを渡し返した。
これこそがこのサーバーが防ぐために存在する失敗である: 終わりたいエージェントは 回帰を改善と呼ぶ。 もし best-so-far がディスク上ではなくモデルのコンテキストに あったなら、その回帰が最終回答になっていただろう。
インストール
短いバージョン: エージェントにやってもらう。 これを Claude Code(または シェルを持つ任意の MCP クライアント)に貼り付けて、そこで止める:
https://github.com/huikku/comfyui-loop-mcp から ComfyUI loop MCP をセットアップ — クライアントに登録し、ComfyUI が動いていなければインストールと起動も行う。
あなたの手を借りずにそれを完了するために必要なものはすべて揃っている: サーバーの登録は
claude mcp add 1 つで、接続後には comfy_install プロンプトが
あなたのマシン用のブートストラップを返す — 既存の ComfyUI の起動コマンド、
venv を構築するインタープリタ、カードに実際に必要な torch ビルド、
ComfyUI-Manager、モデルの置き場所。check_comfyui はその後、まだ欠けているもの
(ウェイトなし、torch が CPU 上、Manager なし)をレポートではなく
エージェントが修正すべきものとして名指しする。
文章よりも設定を貼り付けたい場合、これはサーバーを GitHub から直接実行する —
クローンも pip install も不要:
{
"mcpServers": {
"comfyui": {
"command": "uvx",
"args": ["--from", "git+https://github.com/huikku/comfyui-loop-mcp", "comfyui-loop-mcp"],
"env": { "COMFYUI_URL": "http://localhost:8188" }
}
}
}Claude Code なら 1 行:
claude mcp add comfyui -- uvx --from git+https://github.com/huikku/comfyui-loop-mcp comfyui-loop-mcp代わりにリポジトリをクローンすると .mcp.json がすでにある —
Claude Code は最初のオープンでサーバーを提示し、コマンドは一切不要。
追加後はクライアントを再接続する; MCP サーバーは接続時に読み込まれる。
開発する場合:
git clone https://github.com/huikku/comfyui-loop-mcp && cd comfyui-loop-mcp
pip install -e . # or: uv tool install --editable .Python ≥ 3.10 と到達可能な ComfyUI が必要。mcp[cli]、httpx、
anyio、pillow をインストール。MCP SDK 1.x と 2.x の両方で動作 —
2.0 は FastMCP を MCPServer に改名し、Image ヘルパーを移動したが、
サーバーはどちらの方法でもインポートする。
comfy-mcpとしてインストールしていた場合? その名前は PyPI 上で Comfy-Org のサーバーのものであるため、 これは現在comfyui-loop-mcp(インポートパッケージcomfy_loop、コマンドcomfyui-loop-mcp)。最初にpip uninstall comfy-mcpを実行し、MCP クライアント設定を更新する。ディスク上の既存のループ実行は自動的に見つかる —COMFY_LOOP_STATE_DIRを別の場所に指定するまで、古い~/.comfy-mcp/runsが 引き続き使用される。
常時オンの規律(Claude Code)
このメソッドはスキルとしてもインストールされるため、頼まれるのを待つのではなく トリガーワードで読み込まれる — エージェントにもこれを頼むか、または:
mkdir -p ~/.claude/skills/comfyui-workflows
cp comfy_loop/docs/SKILL.md ~/.claude/skills/comfyui-workflows/comfy_skill プロンプトが提供するファイルと同じものなので、スキルとサーバーは
ずれることがない。
設定
環境変数 | デフォルト | 目的 |
|
| ComfyUI サーバー |
| このパッケージの上のリポジトリルート |
|
|
| オンラインテンプレートカタログが読み込む |
| 未設定 |
|
|
| ラチェットと台帳の置き場所。実行がすでにある場合は旧名の |
リモートの ComfyUI を指す
ComfyUI は通常 127.0.0.1 にバインドするため、別のマシン上の ComfyUI は
デフォルトではネットワーク越しに到達できない。2 つのオプションがある:
SSH トンネル(最も簡単、ComfyUI をプライベートに保つ): ポートを転送し、
COMFYUI_URLは localhost のままにする:ssh -N -L 8188:localhost:8188 your-remote-host # COMFYUI_URL stays http://localhost:8188ComfyUI をネットワークにバインドして直接指す(信頼できるネットワークのみ — 認証なしの API を公開することになる):
python main.py --listen 0.0.0.0 --port 8188 # COMFYUI_URL=http://<remote-ip>:8188
使用方法
エージェントで
comfy_loopプロンプトを読み込む(またはcomfyui://loop-methodリソースを読ませる)と、完全なメソッドが取り込まれる。 クライアントがサーバー指示を注入する場合、ループ優先ポリシーは すでに有効になっている。目標を与える。
check_comfyui→list_nodes/get_node/list_models→ API 形式の JSON を構築 →submit_workflow→get_result→get_imageを実行し、批判と反復を — パスごとに 1 つの変更 — 欠陥を名指しできなくなるまで行い、承認のために結果を提示する。
トラブルシューティング
「ComfyUI に到達できません」 — 返信は苦情ではなく一連の指示であり、 このサーバーにはないシェルを持つエージェント宛てである: このマシン上の ComfyUI(
$COMFYUI_PATH、comfy-cli のワークスペース、~/ComfyUI、~/comfy、~/code、~/github、/opt)を探し、そのインストールの venv python を使った 起動コマンドか、なければクローン + venv + Manager + 起動シーケンスを返す。COMFYUI_URLがリモートの場合、ローカルへのインストールは意図的に 提案しない — それは間違ったマシンに 2 つ目の未使用 ComfyUI を残すだけであり、 代わりに SSH トンネルを提示する。すべてのツールがこれを返す —check_comfyuiだけでなく、アドバイスはトランスポートに付加されている。ノード/モデルが見つからない — ComfyUI 側でパック/モデルをインストールし、 その後 ComfyUI を再起動して
/object_infoに反映させる(それまで API は 古い情報のまま)。get_imageが何も返さない — グラフにSaveImage/PreviewImageノードがあることを確認する;get_resultは実際に生成されたものを列挙する。install_node_packがブロックされる / 何もしない — インストールツールは ホストに ComfyUI-Manager が必要で、 Manager のセキュリティレベルが API インストールを許可している必要がある。 インストール後、/object_infoに新しいノードが表示される前にrestart_comfyuiが必要。find_missing_nodesが「間違った」パックを選ぶ — 複数のパックが同名の ノードをエクスポートできる; 解決は最初のレジストリ一致を取る。インストールが クラスを提供しない場合、報告されたパックを確認し、正しいものを明示的に インストールする。
ライセンス
MIT。
Available Tools
32 toolscheck_comfyuiA
Confirm ComfyUI is up and reachable (loop step 0).
Returns the installed-node count and device/VRAM. If this fails, ComfyUI isn't running or is on another port — do not start guessing node names.
Inputs: no named parameters. Returns: result
compare_imagesA
See what changed between two passes (loop step 3: LOOK — the comparison).
mode="side_by_side": both outputs on one canvas — what moved, at a glance.
mode="difference": 0.5 + 0.5*(a-b) — identical regions read FLAT MID-GRAY and
only real changes pop. This is how you answer "did the
background actually stay put?", which the eye is bad at.
Raise amplify (e.g. 4.0) to surface subtle drift.
Use it every pass against your best-so-far: a change that altered more than you intended is a regression even if the new bit looks nice.
Inputs: filename_a (required), filename_b (required), mode, amplify, +2 more.
find_missing_nodesA
Diff a template's nodes against what's installed, and resolve each missing node to the pack that provides it (via ComfyUI-Manager's registry mapping).
Fetches the template (same args as get_template), lists the node classes it uses, subtracts what /object_info already has, and for each missing class reports the installable pack id to pass to install_node_pack. Read-only.
Inputs: name, pack, source. Returns: result
flowzip_to_apiA
Convert FlowZip (or litegraph) into API/prompt format ready for submit_workflow.
Inflates FlowZip if needed, then maps the litegraph to the flat API graph using the live object_info (resolves links, maps widget values to named inputs). This is the bridge for authoring/adapting graphs compactly and running them.
Best-effort: subgraph instances and unknown nodes are skipped and reported; widget drift between an old template and a newer node shows up as a node_errors when you submit_workflow the result — read it, fix that node, re-submit. Review the API graph before running.
Inputs: flowzip (required). Returns: result
get_imageB
Fetch a rendered output so you can LOOK at it (loop step 3: LOOK — part 2).
Returns the actual image to the model. This is the step that makes the loop work: don't declare a workflow done off a green run — view the pixels, judge them against the brief, then change one thing and re-run.
Inputs: filename (required), subfolder, image_type.
get_nodeD
Inputs: class_name (required), verbose. Returns: result
get_queueA
Show what's running and pending in ComfyUI's execution queue.
Inputs: no named parameters. Returns: result
get_resultA
Poll /history for a submitted prompt and return its output files (loop step 3: LOOK — part 1, find what was produced).
Blocks up to timeout_s for the run to finish. Returns each output's filename / subfolder / type — feed those to get_image to view the pixels.
Inputs: prompt_id (required), timeout_s. Returns: result
get_templateA
Fetch one workflow template as a known-good starting point.
source="online" (default): from the official GitHub catalog — no install
needed; pack is ignored. source="installed": from this ComfyUI (pack
required).
fmt="flowzip" (default): compact FlowZip text — ~72% fewer tokens than the raw litegraph JSON (median), enough to read/adapt the graph. fmt="json": the full litegraph. Either way it's litegraph, NOT the API/prompt format submit_workflow needs — adapt to API (resolve passthroughs, widgets_values -> named inputs via get_node), or inflate a FlowZip with inflate_workflow. If from the online catalog, first confirm you have its nodes/models — run find_missing_nodes then install_node_pack, or verify with list_nodes/list_models.
Inputs: name (required), fmt, pack, source. Returns: result
image_diff_statsA
Quantify the change between two passes — the 'I changed only what I meant to' gate.
Returns mean/max absolute difference and the % of pixels that moved. Pair it with compare_images: the picture tells you WHAT changed, this tells you HOW MUCH — and catches the case where a 'small tweak' quietly rewrote the frame.
Inputs: filename_a (required), filename_b (required), subfolder_a, subfolder_b. Returns: result
inflate_workflowA
Expand FlowZip text back into a full litegraph workflow JSON.
Reverse of the FlowZip that get_template returns. Structure (nodes, types, links, widget values) is preserved; cosmetic fields are not. To RUN it, still adapt the litegraph to API/prompt format for submit_workflow.
Inputs: flowzip (required). Returns: result
install_modelA
Download a model from the catalog by its exact name (from search_models), into the correct models// folder, via ComfyUI-Manager.
Trusted catalog only — Manager whitelists the source. Unlike nodes, models do NOT need a ComfyUI restart (loaders re-scan the folder); once it completes, verify with list_models. Large models can take a while — the download continues server-side even if this call's poll window ends.
Inputs: name (required). Returns: result
install_node_packA
Install a custom-node pack by its ComfyUI-Manager registry id (from find_missing_nodes) — trusted registry only, no arbitrary code.
Queues the install, starts the queue, and polls until done. A ComfyUI RESTART is required afterward before /object_info reflects the new nodes — call restart_comfyui, then re-query. Fails clearly if Manager's security level blocks API installs.
Inputs: pack_id (required), version. Returns: result
interruptA
Cancel the currently executing prompt.
Inputs: no named parameters. Returns: result
list_modelsA
List the real model files a loader offers (loop step: never hallucinate a checkpoint/LoRA/VAE filename).
Reads the loader's enum from object_info (handles both the legacy list and the newer COMBO encoding). If input_name is omitted, reports every enum-typed input on the node. Pick ONLY from the returned list.
Inputs: class_name (required), input_name. Returns: result
list_nodesA
Search installed nodes by keyword (loop step: discover, don't guess).
Matches the keyword against BOTH the class name and the display name, so a node found by its UI label ("Load Image") still turns up. Returns class_name -> display_name. Class names are case-sensitive and differ from display names — use the class_name in workflow JSON. Omit keyword to get the total count only (the full list is large).
Inputs: keyword. Returns: result
loop_bestA
Fetch the best-so-far graph — to revert to it, or to deliver it as the final.
Use this after a compaction, or any time you're unsure the graph in your context is still the best one. It is the source of truth; your memory is not.
Inputs: run_id (required). Returns: result
loop_finishA
Close the loop at the convergence checkpoint — you can't name a defect anymore.
Marks the run converged and returns the final ledger + the best graph, ready to present. Then STOP and ask the user to approve or request changes; don't keep inventing variations to avoid stopping.
Inputs: run_id (required), summary. Returns: result
loop_ledgerA
The append-only loop log: every pass, what changed, what it did.
Read it after a context compaction to recover the thread — what the brief was, what's already been tried (so you don't retry a dead end), and which pass is best. This is also the log you hand the user at sign-off; it's the story of how the result got good.
Inputs: run_id (required). Returns: result
loop_recordA
Record a pass and apply the ratchet (loop step 5: DECIDE).
change the ONE thing you changed this pass ("denoise 0.6 -> 0.45").
outcome your verdict vs the best-so-far: "better" | "worse" | "same".
graph the API graph you just ran — REQUIRED when outcome is "better", because
that's what gets stored as the new best and handed back on a revert.
score an objective score from measure_image, when the brief has a gate. If both
this pass and the best have one, the NUMBER decides — not your verdict.
(A model that wants to be finished will call a regression "better".)
outputs this pass's output files, straight from get_result — pass them through so
loop_report can show what each pass actually looked like.
On "worse"/"same" you get the best graph back: revert to it and try a DIFFERENT change. Never build on a regression — that's how a loop wanders instead of converging.
Inputs: change (required), run_id (required), outcome (required), note, +3 more. Returns: result
loop_reportA
Render the whole run as ONE self-contained HTML page — every pass, what changed, what was kept, what was reverted, and the final.
This is the artifact worth keeping. The final image alone proves nothing; the evidence of convergence — the passes you threw away — is what shows the loop actually worked. Hand it over at the sign-off checkpoint alongside the result.
Images are downscaled and base64-inlined, so the page renders with ComfyUI off, on someone else's machine, or emailed. Writes next to the run state by default; set out_path to put it anywhere.
Inputs: run_id (required), out_path. Returns: result
loop_startA
Open a loop run — do this BEFORE the first submit (loop step 0).
brief is what "right" means, in the user's words; you'll be judged against it.
gate is the objective test IF the brief has one ("must tile seamlessly",
"exactly 3 apples", "identity preserved") — leave empty for purely aesthetic work.
Returns a run_id. Pass it to loop_record every pass. This is what makes the ratchet real: your best graph is stored HERE, not in your context, so it survives compaction and can actually be reverted to.
Inputs: brief (required), gate. Returns: result
measure_imageA
Score an output objectively, for the ratchet (metric: sharpness | tile_seam | brightness).
Use ONLY where the brief has an objective test — then feed the score to loop_record so the ratchet can't be fooled by a model that wants to be done:
tile_seam "seamless texture" — compares the wrap-around join to an interior join. ~1.0 = genuinely tiles; >2 = a real seam. The eye waves this through. sharpness "upscale/restore, add detail" — edge energy. Rises with real detail, falls when a pass just softened the image. Compare ACROSS passes. brightness mean / stddev / p99 — exposure and blown-highlight checks.
A score is not the judgement. A graph with a great number can still look wrong — gate on the metric, decide with your eyes.
Inputs: filename (required), metric, subfolder. Returns: result
restart_comfyuiA
Restart ComfyUI (via ComfyUI-Manager) so newly installed nodes register in /object_info. The server is briefly unavailable; poll check_comfyui after.
Inputs: no named parameters. Returns: result
run_templateA
Run a known-good template with input overrides — WITHOUT loading the graph into context. Fetches the template, converts to API format, applies overrides, and submits. Use template_slots first to see what you can override.
overrides: {node_id: {input_name: value}} (node ids and inputs from template_slots). After it runs, call get_result then get_image and LOOK — a green run is valid, not correct.
Limitation: subgraph templates can't be expanded (converter coverage ~88% of non-subgraph nodes); if nodes are skipped it's reported and the run may be incomplete. Confirm the template's nodes/models exist first (find_missing_nodes).
Inputs: name (required), pack, source, client_id, +1 more. Returns: result
save_workflowA
Convert an API graph to UI/litegraph format so a human can open and edit it.
The loop builds API format because that's what /prompt runs — it is NOT the file you drag onto the ComfyUI canvas. Call this when the user asks for the editable workflow.
The result is VERIFIED by converting it back to API format and diffing against what you passed in; any mismatch is reported. widgets_values is positional and a silent off-by-one shifts parameters — a plausible-but-wrong file is worse than none, so if the round-trip doesn't match, fix it before shipping it.
With save=True and a name, it's written to ComfyUI's workflows dir so it shows up in the UI's workflow list.
Inputs: workflow (required), name, save. Returns: result
search_modelsA
Search the downloadable model catalog — find checkpoints/LoRAs/VAEs/ controlnets/upscalers you may NOT have installed yet (the local equivalent of the cloud's model search). Reads ComfyUI-Manager's model list; each result shows whether it's already installed on THIS box.
Filter by keyword (name/filename/base/description) and optional model_type (checkpoint, lora, vae, controlnet, upscale, clip, diffusion_model, ...). Install one with install_model(name). Requires ComfyUI-Manager on the host.
This is a catalog of known models; list_models shows what a specific loader currently offers on disk (ground truth). Discover here, then verify against list_models after installing.
Inputs: keyword, model_type. Returns: result
search_templatesA
Search known-good workflow templates to adapt (few-shot beats zero-shot).
source="online" (default): the OFFICIAL open catalog on GitHub (Comfy-Org/workflow_templates) — the same ~550-template set the Cloud MCP's search is built from. You do NOT need these installed; they're browsed straight from the repo. Matches keyword against name + title + description.
source="installed": only templates on THIS ComfyUI right now (/api/workflow_templates — every installed pack's example workflows). Smaller, but guaranteed runnable on your install without adding anything.
Then fetch one with get_template. Note an online template may reference nodes/ models you haven't installed — reconcile against object_info before running.
Inputs: source, keyword. Returns: result
submit_workflowA
Queue an API-format workflow for execution (loop step 2: RUN).
workflow is the flat API/prompt-format dict: {node_id: {class_type, inputs}}.
Do NOT pass litegraph/UI format here.
On success: returns the prompt_id — then call get_result to fetch outputs and get_image to LOOK at them. Running with zero errors means the graph is VALID, not CORRECT — you still have to inspect the pixels. On failure: returns node_errors keyed by node id. That is NOT an iteration — read the error, fix that specific node, and re-submit until it executes.
Inputs: workflow (required), client_id. Returns: result
system_statsA
Report device / VRAM usage — useful when tuning resolution/batch or after an OOM.
Inputs: no named parameters. Returns: result
template_slotsA
List a template's overridable inputs WITHOUT loading the full graph JSON.
Converts the template to API format and reports each node's literal (non-wired) inputs and current values — the curated parameter list you can change with run_template. Far smaller than the raw graph. Subgraph/unknown nodes can't be expanded and are reported (their inputs aren't overridable this way).
Inputs: name (required), pack, source. Returns: result
upload_imageA
Upload a local image into ComfyUI's input/ dir so a LoadImage node can use it.
Returns the name to reference in the workflow. (Video nodes like VHS_LoadVideo* read files you place directly in ComfyUI's input/ dir instead.)
Inputs: path (required), overwrite. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 32 tools
Most tools have clearly distinct purposes, but there is minor overlap between compare_images and image_diff_stats (both compare images, though one visual and one statistical) and between get_node (no description) and other tools. Overall, agents can distinguish them.
All 32 tools follow a consistent verb_noun pattern with lowercase and underscores (e.g., check_comfyui, find_missing_nodes, loop_start). No mixing of conventions.
32 tools is on the high side, but each tool serves a specific function in the ComfyUI loop workflow, including operations, installation, looping, and evaluation. Could be slightly reduced, but still appropriate for the scope.
The tool set covers the entire loop workflow end-to-end: start, run, evaluate, compare, record, finish, plus supporting operations for node/model management and template handling. No obvious gaps for the stated purpose.
Maintenance
Related MCP Connectors
MCP server for Hailuo (MiniMax) AI video generation
MCP server for Luma Dream Machine AI video generation
MCP server for Qwen Image 3 AI image generation
AI memory governance & hallucination-blocking MCP server with verifiable knowledge cells.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA lightweight MCP server that bridges AI agents with a local ComfyUI instance to generate and iteratively refine images, audio, and video through conversational tool calls.28 npmMIT
- AlicenseBqualityCmaintenanceAn MCP server that bridges AI agents with ComfyUI for automated workflow building, execution, monitoring, and output routing.961MIT
- AlicenseAqualityDmaintenanceMCP server that lets OpenCode (or any MCP-compatible AI coding tool) directly control ComfyUI for AI image generation.143MIT
- AlicenseAqualityBmaintenanceThe MCP server that drafts ComfyUI workflows a human can actually read. It lets coding agents build, repair, port, validate, and run ComfyUI workflows against your own ComfyUI instance, delivering clean, organized, fully-labeled workflows.29251 PyPI2MIT