just create export parameter in your shader with name you like for example object_id (and add it to image planes in mantra)
then in each of your object create attribute called the same with the same type and assign different value per object
what works best is to create Vector4 attribute since then you can have 4 different object groups (red, green, blue, alpha) so {1,0,0,0}, {0,1,0,0}, etc
in that case you'll get perfect antialiasing between them as you can separate it per channel in comp
to create more object groups just add another variable export like object_id2 etc
you can of course export just float variable and assign values like 0, 1, 2, ..., but that will create problems in antialiasing where any 2 non neighbour ids overlap (like 0 and 3, since interpolated value will go through 1 and 2)