David Wardrop, 29, asked at the reception to speak with Mr Matheson at the city chambers in Glasgow while holding the three feet long sword.
Staff asked him if he had an appointment and told him he could not be in the building with the sword and asked him to leave.
A concerned receptionist followed him outside and took the blade from him after he was out in the street and the police were called to the building.
After going back inside, Wardrop spoke with officers when they arrived and told them the weapon was "to assassinate the leader of the city chambers."
Wardrop, whose address was given as Barlinnie prison, pled guilty at Glasgow Sheriff Court to breaching the peace and having the weapon on him on June 2, 2014.
The court heard that at around 4.10pm Wardrop went to the reception area of the city chambers where there were two receptionists and a member of the public.
He asked to speak with Mr Matheson and was asked if he had appointment to which enquiry he replied "justice."
When questioned what he meant he said "just justice."
The staff noticed Wardrop was holding a sword in his right hand which was partially covered by his right leg and told him he wasn't allowed in the building with the weapon.
He was detained by the police and has been in custody since the incident.
Sheriff Joseph Platt deferred sentence on Wardrop for reports until later this month.