I would paint the inside of the endcaps as well, unless you like the smell of MDF off-gassing. The legs should be sufficient, but I would suggest putting some felt on the bottom if they aren't going on carpet. One screw per leg should be fine, I have used furniture legs in the past, drilled and tapped the MDF, and screwed them in. ( doubled 3/4" baseplate ) The glue should be sufficient to hold them with a single screw.
Also, use 3 legs instead of 4, it will give you more stability, as it will always be flat, even if the floor is uneven. 4 will give it the ability to rock, if uneven.
"What the heck was that crashing noise?" Me: "oh, just tossed the shampoo bottles off the shelf on the opposite side of the house. "