Comfy MCP Server
舒适的 MCP 服务器
使用 FastMCP 框架通过远程 Comfy 服务器根据提示生成图像的服务器。
概述
此脚本使用 FastMCP 框架搭建了一个服务器,用于根据指定的工作流程,根据提示生成图像。该脚本与远程 Comfy 服务器交互,以提交提示并检索生成的图像。
Related MCP server: comfyui-mcp
先决条件
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-serverClaude 桌面配置示例
{
"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
此函数使用指定的提示生成图像。它遵循以下步骤:
检查所有环境变量是否都已设置。
从 JSON 文件加载提示模板。
将提示提交给 Comfy 服务器。
轮询服务器以获取提示处理的状态。
一旦准备好,检索并返回生成的图像。
generate_prompt(topic: str, ctx: Context) -> str
此功能根据指定主题生成综合图像生成提示。
依赖项
mcp:用于设置 FastMCP 服务器。json:用于处理 JSON 数据。urllib:用于发出 HTTP 请求。time:用于增加轮询的延迟。os:用于访问环境变量。langchain:用于创建简单的 LLM Prompt 链以从主题生成图像生成提示。langchain-ollama:用于 LangChain 的 ollama 特定模块。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceAn MCP server that enables high-quality image generation using OpenAI's GPT-Image-1 model with support for style variations and HD quality. It automatically downloads and saves generated images to a local directory as PNG files while managing metadata and batch processing.
- AlicenseAqualityCmaintenanceMCP server for ComfyUI — text-to-image, variations, img2img refine, upscale, image proxy, and workflow runner.15731MIT
- AlicenseAqualityAmaintenanceA secure MCP server for ComfyUI that enables AI assistants to generate images, run workflows, and manage jobs with built-in security controls.462MIT
- FlicenseNot gradedqualityBmaintenanceMCP server that connects local ComfyUI to AI agents, enabling natural language control of ComfyUI for creating workflows, generating images, and managing the queue.
Related MCP Connectors
MCP server for Flux AI image generation
MCP server for Wan AI video generation
MCP server for Luma Dream Machine AI video generation
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
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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