快適な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
- AsecurityFlicenseAqualityA FastMCP server implementation that facilitates resource-based access to AI model inference, focusing on image generation through the Replicate API, with features like real-time updates, webhook integration, and secure API key management.Last updated -1815Python
- AsecurityAlicenseAqualityAn MCP Server that integrates with Stability AI's API to provide high-quality image generation, editing, and manipulation capabilities including background removal, outpainting, search-and-replace, and upscaling.Last updated -1345073TypeScriptMIT License
- AsecurityFlicenseAqualityAn MCP server that generates images based on text prompts using Black Forest Lab's FLUX model, allowing for customized image dimensions, prompt upsampling, safety settings, and batch generation.Last updated -31TypeScript
- -securityFlicense-qualityAn MCP image generation server based on the Flux Schnell model that provides API access for generating images from text prompts with customizable dimensions and seeds.Last updated -1Python
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