快適なMCPサーバー
FastMCP フレームワークを使用して、リモート Comfy サーバー経由のプロンプトに基づいて画像を生成するサーバー。
概要
このスクリプトは、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``url
またはfile
に設定して、必要な出力を選択します。
オプションとして、 Ollamaサーバーが実行中の場合は、プロンプトを生成するためにサーバーに接続できます。
OLLAMA_API_BASE
ollama が実行されている URL に設定します。PROMPT_LLM
プロンプト生成用の ollama でホストされているモデルの名前に設定します。
例:
使用法
Comfy MCP Server は次のコマンドで起動できます。
Claude デスクトップ設定の例
機能性
generate_image(prompt: str, ctx: Context) -> Image | str
この関数は、指定されたプロンプトを使用して画像を生成します。以下の手順に従います。
- すべての環境変数が設定されているかどうかを確認します。
- JSON ファイルからプロンプト テンプレートを読み込みます。
- プロンプトを Comfy サーバーに送信します。
- プロンプト処理のステータスをサーバーにポーリングします。
- 生成された画像が準備できたら取得して返します。
generate_prompt(topic: str, ctx: Context) -> str
この関数は、指定されたトピックから包括的な画像生成プロンプトを生成します。
依存関係
mcp
: FastMCP サーバーをセットアップします。json
: JSON データを処理します。urllib
: HTTP リクエストを行うため。time
: ポーリングに遅延を追加します。os
: 環境変数にアクセスします。langchain
: トピックから画像生成プロンプトを生成するためのシンプルな LLM プロンプト チェーンを作成します。langchain-ollama
: LangChain の ollama 固有のモジュール用。
ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。
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.
Comfy MCP サーバーは、FastMCP フレームワークを使用して、リモート Comfy サーバーと対話することでプロンプトからイメージを生成し、ワークフロー構成に基づいてイメージを自動的に作成できるようにします。
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