There is no general exemption for people with mental illness, however some people don't need to have a medical. I've quoted some relevant info here.
Some claimants may be given ‘early entry’ to the work capability assessment, allowing them to be placed in the support group or work-related activity group without needing to attend a medical or complete a questionnaire. This may be, for example, because: - you have a very severe illness or disability and it is clear you qualify for the support group.
And
You will be found to have limited capability for work-related activity (i.e. you qualify for the support group) if the following applies:
Because of your physical or mental health condition or disability, there would be a substantial risk to the mental or physical health of any person, including you, if you were found not to have limited capability for work-related activity.