Mpi List Count
How long is that list? Ask, and get a boolean too
- list_input
- count
- has_items
Mpi List Count answers one question about any list: how many things are in it? One input, list_input (any type), two outputs - count as an INT and has_items as a BOOLEAN that's true whenever the list is non-empty. It's a two-second read of the graph's current state, and it's the kind of node you add when a workflow starts making decisions based on how much data is actually flowing through it.
The has_items output is the part that makes it more than a number. Because it's a ready-made boolean, you can wire it straight into an MpiIfElse and branch on whether the list has content - "if there are frames, run the sampler; if not, skip to the fallback." That's the same pattern as the pack's MpiIsListEmpty (which gives you is_empty and count, the mirror-image phrasing), and honestly either one works for gating; the reason to pick MpiListCount is when you actually need the number and want the boolean as a bonus. Batch a set of images, count them, and you can feed that count into a math node to compute how many steps or how many grid columns you need. Lists are everywhere in ComfyUI - prompt lists, image batches, conditioning lists, the pack's own MPI_PACK bundles - and this node makes their length a first-class value you can compute with.
Mechanically it's nothing exotic: the node is declared INPUT_IS_LIST, so ComfyUI passes the whole list in as one argument rather than iterating it, and count does len(list_input), with has_items as n > 0. No validation surprises, no edge cases worth memorizing. Feed it a single value and it says 1; feed it an empty list and it says 0 / false.
The natural companions are the pack's MpiListRange (slice a list and get the sliced list plus its count) and MpiIsListEmpty (the same count with the emptiness flag flipped). If you find yourself building "how many items did I produce" into your workflow more than once, this is the node that makes it a wire instead of a manual count.
Installation is the same one-line story as every node in this 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 models, pure Python. It's one of over a hundred utilities in the Mad Pony Interactive pack (the engine under the Cubric Vision app). Nothing about this node is glamorous - it's a counter - but workflow logic is built out of exactly this kind of small, boring, correct primitive.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| list_input | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| count | INT | — |
| has_items | BOOLEAN | — |