MDF is fine to screw into as long as you use long screws and predrill the holes. I have a shelf mounted to my wall built of nothing but MDF. I used drywall screws to hold the shelves themselves together, as well as longer drywall screws to mount the shelf to the studs in the wall. MDF is fine, just don't over-torque.
John