Staff and patients at Trinity Medical Centre on Thornhill Street were left terrified after Stephen Charles Silvester entered the building at around 4pm on February 24.
Prosecutor Jemima Stephenson said he was bleeding from his cheek and was shouting that he was going to hurt someone, pulling out the two knives.
He then threw then on the desk receptionist's desk where they were quickly confiscated.
The 36-year-old was heard to say: "I'm going to stab someone. I just want these voices to stop."
He then left the building and began drinking from bottle of gin and playing music on his phone, giving staff the chance to lock the doors.
He was picked up by officers on Kirkgate a short time later, where they found a 5" Stanley knife on him, and two more in his left and right trainers.
He told them he had them because he was hearing voices telling him to kill someone, to stab them in the head.
Just five days before he had been arrested after trying to attack an officer at Wakefield Bus Station.
The police had been called at around 7pm after Silvester was found unconscious under a bench in the station. He was drunk and turned abusive when police helped him to his feet.
He removed a razor from his pocket but managed to cut himself with it.
He then tried to lunge at one of the officers but was pushed away.
The court was told that he had been admitted to hospital earlier in the day for self harming, but left before he received treatment.
Appearing in court via video link from HMP Leeds, he admitted a charge of assault on the officer, using threatening behaviour at the medical centre and possessing a bladed article.
Silvester, of no fixed address, has 40 previous convictions for 67 offences, including violence, shoplifting, public order and harassment.
He also has a previous conviction from 2017 for possessing a bladed article in public.
Mitigating, Robin Frieze said: "It was very sad behaviour from somebody who is very troubled."
A probation report found he had a high risk of offending, harming the public and himself.
Judge Christopher Batty said: "Your own personal difficulties serve to reduce the culpability in this case but it was troubling behaviour over two separate incidents involving knives."
He jailed him for 12 months.