ComfyUI MCP Server
Enables AI agents to manage ComfyUI workflows using a human-readable Domain Specific Language (DSL), with automatic conversion to/from JSON format. Supports workflow creation, validation, execution, and monitoring through natural language interactions.
README
ComfyUI MCP Server
DSL-first workflow management for ComfyUI via Model Context Protocol (MCP)
A production-ready MCP server that enables AI agents to manage ComfyUI workflows using a human-readable Domain Specific Language (DSL). The core design philosophy is DSL-first: agents work entirely in DSL format, with JSON conversion happening transparently.
🚀 Quick Start
Installation
pip install comfy-mcp
Usage with Claude Code
- Create MCP configuration:
{
"mcpServers": {
"comfyui-workflows": {
"command": "comfy-mcp",
"args": [],
"env": {}
}
}
}
- Start Claude Code with MCP:
claude --mcp-config mcp_config.json
- Use in conversation:
"Execute this workflow: [paste DSL]"
"List workflows in examples directory"
"Show ComfyUI queue status"
✨ Features
🔄 DSL-First Design
- Agents work entirely in human-readable DSL
- Automatic JSON ↔ DSL conversion
- No need to think about format conversion
📁 File Operations
read_workflow- Auto-converts JSON to DSLwrite_workflow- Saves DSL as JSON/DSLlist_workflows- Discovers workflow filesvalidate_workflow- DSL syntax validationget_workflow_info- Workflow analysis
⚡ Execution Operations
execute_workflow- Run DSL workflows on ComfyUIget_job_status- Monitor execution & download imageslist_comfyui_queue- View ComfyUI queue status
🎨 DSL Syntax Example
## Model Loading
checkpoint: CheckpointLoaderSimple
ckpt_name: sd_xl_base_1.0.safetensors
## Text Conditioning
positive: CLIPTextEncode
text: a beautiful landscape, detailed, photorealistic
clip: @checkpoint.clip
negative: CLIPTextEncode
text: blurry, low quality
clip: @checkpoint.clip
## Generation
latent: EmptyLatentImage
width: 1024
height: 1024
sampler: KSampler
model: @checkpoint.model
positive: @positive.conditioning
negative: @negative.conditioning
latent_image: @latent.latent
seed: 42
steps: 20
## Output
decode: VAEDecode
samples: @sampler.latent
vae: @checkpoint.vae
save: SaveImage
images: @decode.image
filename_prefix: output
🏗️ Architecture
┌─────────────────┐ ┌──────────────┐ ┌─────────────┐
│ AI Agent │────│ MCP Server │────│ ComfyUI │
│ (Claude) │ │ │ │ Server │
└─────────────────┘ └──────────────┘ └─────────────┘
│ │ │
│ DSL Workflows │ JSON API │
│ │ │
▼ ▼ ▼
Natural Language ────► DSL Parser ────► JSON Converter
Key Components:
- DSL Parser: Converts human-readable DSL to Abstract Syntax Tree
- JSON Converter: Bidirectional conversion between DSL and ComfyUI JSON
- MCP Server: Exposes tools via Model Context Protocol
- Execution Engine: Integrates with ComfyUI API for workflow execution
📖 Documentation
Core Classes
DSLParser: Parse DSL text into Abstract Syntax TreeDslToJsonConverter: Convert DSL AST to ComfyUI JSONJsonToDslConverter: Convert ComfyUI JSON to DSL AST
MCP Tools
| Tool | Description | Example |
|---|---|---|
read_workflow |
Read and convert workflows to DSL | read_workflow("workflow.json") |
write_workflow |
Write DSL to disk as JSON/DSL | write_workflow("output.json", dsl) |
list_workflows |
Find workflow files | list_workflows("./workflows") |
validate_workflow |
Check DSL syntax | validate_workflow(dsl_content) |
get_workflow_info |
Analyze structure | get_workflow_info(dsl_content) |
execute_workflow |
Run on ComfyUI | execute_workflow(dsl_content) |
get_job_status |
Monitor execution | get_job_status(prompt_id) |
list_comfyui_queue |
View queue | list_comfyui_queue() |
🛠️ Development
Setup
git clone https://github.com/christian-byrne/comfy-mcp.git
cd comfy-mcp
pip install -e ".[dev]"
pre-commit install
Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=comfy_mcp --cov-report=html
# Run specific test types
pytest -m unit
pytest -m integration
pytest -m "not slow"
Code Quality
# Format code
black .
# Lint code
ruff check .
# Type checking
mypy comfy_mcp
Documentation
cd docs
make html
🔧 Configuration
Environment Variables
COMFYUI_SERVER: ComfyUI server address (default:127.0.0.1:8188)MCP_DEBUG: Enable debug loggingMCP_LOG_LEVEL: Set log level (DEBUG, INFO, WARNING, ERROR)
ComfyUI Setup
- Install ComfyUI
- Start server:
python main.py --listen 0.0.0.0 - Ensure models are installed in
models/checkpoints/
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Workflow
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make changes and add tests
- Run tests and linting:
pytest && black . && ruff check . - Submit a pull request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- ComfyUI - Amazing stable diffusion GUI
- FastMCP - Excellent MCP framework
- Anthropic - Model Context Protocol specification
📈 Roadmap
- [ ] v0.2.0: Enhanced DSL features (templates, macros)
- [ ] v0.3.0: Web UI for workflow management
- [ ] v0.4.0: Git integration for workflow versioning
- [ ] v0.5.0: ComfyUI node discovery and documentation
- [ ] v1.0.0: Production deployment features
Built with ❤️ for the ComfyUI and AI automation community
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。