Nodes/ComfyUi-MpiNodes/Mpi Is List Empty
ComfyUI Node

Mpi Is List Empty

Check a list before the graph throws an IndexError on it

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi Is List Empty
  • list_input
  • is_empty
  • count

A huge chunk of ComfyUI failures aren't the model's fault - they're the graph's. You build a workflow that picks a prompt from a list, indexes into a batch of images, or slices a list of conditioning, and then a branch hands it an empty list and the whole run dies with an IndexError. Mpi Is List Empty is the guard for that exact situation. It looks at any list (list_input, any type), and tells you the two things that matter: is_empty (true if there are zero items) and count (how many there actually are).

The trick is what you do with is_empty. ComfyUI's if/else nodes are lazy - if you wire is_empty into the boolean of an MpiIfElse, the branch that would have indexed the empty list simply never runs, because lazy evaluation skips inputs it doesn't need. So instead of a workflow that crashes when an upstream list comes up empty, you get a workflow that quietly routes around the problem. The README says it plainly: route is_empty into an if/else to skip nodes that would IndexError on an empty list. That's the whole design intent.

Both MpiIsListEmpty and its sibling MpiListCount read the list through INPUT_IS_LIST, meaning ComfyUI feeds the node the full list as one input rather than per-item. MpiListCount gives you count and has_items (the same signal, phrased positively); this node flips it - is_empty is true when count is zero. Pick whichever reads better in your graph; they're the same check with different names. Where they differ is routing: is_empty is the one that wires straight into a conditional.

There's nothing else to configure - one input, two outputs. Where beginners trip up is the timing: the check only helps if it runs before the node that needs the data. Put it upstream, gate the downstream branch on its result, and you've turned a crash into a skip. That said, if your goal is "stop the whole branch dead and move on," the pack's MpiBlockIfEmptyList does that directly - this node is the version that gives you the boolean to make your own decision with.

Install is the same zero-friction story as the rest of the pack. ComfyUI Manager → search "ComfyUi-MpiNodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes

No pip dependencies, no model files, pure Python from the Mad Pony Interactive utility pack (the engine behind Cubric Vision). It's a small node that quietly prevents a very common class of graph death - the kind you'll be glad you had the first time a dynamic prompt list comes back empty and your workflow keeps running instead of redlining the console.

CategoryMpiNodes/Logic

Inputs (1)

NameTypeDefaultDescription
list_input*

Outputs (2)

NameTypeDescription
is_emptyBOOLEAN
countINT