Do I need a lawyer if we have agreed to mediation?

You will each probably need a lawyer. If you are considering mediation, the issues in your divorce are likely of the type where you would each benefit from legal counsel.  Even if you are deciding the entire outcome of your divorce in mediation, a divorce action must still be filed in state court in order to legally become divorced. Your mediator cannot file legal documents on your behalf.