Lee Brunton was approached by officers in the station who suspected he and a pal were “under the influence of something”.
The 28-year-old was searched and 104 benzodiazepine tablets were recovered from his rucksack.
Police also found four screwdrivers in the bag and Brunton, a painter and decorator, was arrested.
Brunton appeared at the city’s sheriff court on Tuesday and pled guilty to possession of a Class C drug. He further admitted having an article with a blade or sharp point without reasonable excuse.
Fiscal depute Neil Hammond said officers approached Brunton and the other man in the station on the evening of July 17 last year.
Mr Hammond said both men “appeared to be under the influence of something” although an officer couldn’t spell alcohol.
The men said they were travelling to Manchester to attend a party, the prosecutor said.
He added: “The accused and his companion appeared to be apprehensive in speaking to police. Brunton was sweating profusely.”
The court heard the pair were searched under the Misuse of Drugs Act and the drugs and screwdrivers were found.
Mr Hammond said the tablets had a value of £104.
Defence agent Paul Dunne said Brunton had screwdrivers to disconnect the battery on his off-road motorcycle to stop it draining and forgot they were in his bag.
Mr Dunne said there was “no suggestion of using them for nefarious purposes”.
The solicitor said his client had started using benzodiazepine following a motorbike crash and that had continued for years. He added Brunton paid around £35 for the tablets.
Sheriff Chris Dickson deferred sentence on Brunton, of the city’s Saughton area, until next month for reports.