# How AI Assistants Should Use This MCP Server
This guide helps AI assistants (Claude, etc.) use the ComfyUI MCP tools effectively. Add this to your system prompt or reference it when building workflows.
## Core Protocol
1. **Always call `comfy_list_nodes` first** before generating any workflow
2. **Only use nodes that exist** - never invent or guess node types
3. **Check schemas** with `comfy_node_schema(node_type)` for any node you're unsure about
4. **Validate before delivering** - call `comfy_validate_workflow` and fix until `ok: true`
## Workflow Generation Rules
### Do
- Start from templates in `workflows/` when available
- Use exact node types from `comfy_list_nodes()` output
- Match input types exactly as specified in node schemas
- Include at least one output node (SaveImage, PreviewImage)
- Set seed explicitly (0 for random, fixed value for reproducibility)
### Don't
- Invent custom nodes that don't exist
- Guess at input parameter names or types
- Deliver workflows without validation
- Assume model filenames - verify they exist
## Tool Usage Patterns
### Building a new workflow
```
1. comfy_list_nodes() -> See what's available
2. comfy_node_schema("KSampler") -> Check required inputs
3. comfy_node_schema("CheckpointLoader") -> Check model input format
4. [Build workflow JSON]
5. comfy_validate_workflow(workflow) -> Verify it's valid
6. [Fix any errors, re-validate]
7. Return validated workflow
```
### Answering "what nodes do I have for X?"
```
1. comfy_list_nodes()
2. Filter/search results for relevant terms
3. comfy_node_schema() on promising matches
4. Summarize capabilities
```
### Debugging a broken workflow
```
1. comfy_validate_workflow(workflow) -> Get specific errors
2. Check error details for node_errors
3. comfy_node_schema() on failing nodes
4. Fix inputs/connections
5. Re-validate
```
## Connection Format
Node connections must use the format `["node_id", output_index]`:
```json
{
"3": {
"class_type": "KSampler",
"inputs": {
"model": ["1", 0],
"positive": ["2", 0],
"negative": ["2", 1],
"latent_image": ["4", 0]
}
}
}
```
- `"model": ["1", 0]` means "output index 0 from node 1"
- Output indices start at 0
- Check `comfy_node_schema()` for output order
## Common Defaults
When not specified by the user, reasonable defaults:
| Parameter | SD 1.5 | SDXL |
|-----------|--------|------|
| Resolution | 512x512 | 1024x1024 |
| Steps | 20 | 20 |
| CFG | 7.0 | 7.0 |
| Sampler | euler | euler |
| Scheduler | normal | normal |
| Seed | 0 (random) | 0 (random) |
## Output Format
Unless the user requests otherwise, return **raw workflow JSON only** - no markdown code fences, no commentary. This allows direct copy-paste into ComfyUI.
When explanation is needed, put it before or after the JSON, clearly separated.