It is rather common in many different disciplines to contact faculty members(potential post-doc mentors) asking if they take post-doc students. I was wondering if it is ok to contact a potential mentor of a post-doc position in mathematics that is publicly advertised?
Yes it's good idea, but the point is just to make them aware of your application. In particular make sure the application is already posted in mathjobs when you send the email. Keep your email short and don't expect a reply with any content. You want to say your name, your advisor, a sentence about what you work on, and a brief expression of interest in working with them.