David Wardrop, 29, asked at the reception to speak with Mr Matheson at the City Chambers in Glasgow while holding the bladed weapon, that was three feet long.
Staff asked him if he had an appointment and told him he couldn’t be in the building with the sword and asked him to leave.
A concerned receptionist followed him 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, from Bearsden, East Dunbartonshire pled guilty at Glasgow Sheriff Court to breaching the peace and having the weapon on him on June 2, 2014.
Sheriff Joseph Platt handed him a community payback order with a number of conditions including that he will be supervised for three years and must live at his Bearsden address during that time, as well as working with a doctor to improve his mental health.
The sheriff also ordered that Wardrop must not approach or contact, or attempt to approach or contact any elected council member.
Labour politician Mr Matheson was elected as the leader of Glasgow City Council in May 2010.
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 he replied “justice”.
When questoined 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 it.
Procurator fiscal depute Harry Findlay said he was asked to leave and he did, and made his way to the pavement outside.
A worried receptionist followed Wardrop outside who was kneeling down holding the sword with both hands across his body.
Mr Findlay said he was asked to hand it over, which he did, and the receptionist put it behind the desk inside.
The court heard Wardrop came back into the waiting area and the police were contacted.
When they arrived they asked Wardrop about the sword and he said “It was to assassinate the leader of the city chambers”.
The court was told a rucksasck and a sheath was found outside the building.