It would be better to use MCListRef here - use MCListAppendInteger to append the ids, and then MCListCopyAsStringAndRelease at the end.