The idea of inviting 20 ­Scottish writers to address one of 20 portraits and artworks at the Scottish National Portrait Gallery, and have their "short, sharp" monologues delivered by professional actors to a promenade audience, is a fascinating one - for all its undoubted logistical challenges.

Intended as an exploration of Scotland's identity in this most significant year, work on the complicated process of making connections has been ongoing since the idea was first mooted last autumn.

For Jackie Kay, however, choosing Maggi Hambling's 1988 portrait of the retired miners' union leader Michael McGahey as the subject for a moving new poem was the easy bit. From a remit to create a five-minute spoken piece, Last Room In Operations is a 750-word eulogy not only to the man himself, but also to her adoptive parents and a lost way of life. The challenge, she says, was having to edit her poem down from 1000 words.

McGahey, a life-long member of the Communist Party (CP) who led the Scottish miners during the disputes of the 1970s and 1980s, was a close friend and comrade of Kay's beloved adoptive parents John and Helen. John, now 89, was the full-time industrial organiser of the CP in Scotland, and Helen, now 83, was secretary of the Scottish Peace Movement. As a young girl growing up in Edinburgh, Jackie would meet McGahey and other comrades on an almost daily basis.

"I did know Mick, because my parents knew him really well. To me he was Uncle Mick, like the Jimmies Reid and Airlie were Uncle Jimmy. He was part of my extended family," she says. "I have a vision of Mick at events like the Miners' Gala in Edinburgh, where we went every year. I used to love marching down the Royal Mile with them. Mick always said 'hello, comrade' and asked me how I was. I liked it when grown men called me comrade. I remember wearing my scarlet trouser suit with flares and Jimmy Reid saying to me, 'Nice colour, comrade!' It made me feel very proud. There used to be a real buzz around events like this and the May Day celebrations in Glasgow. There was a sense of everybody united in a common cause in great gaiety."

Her poem begins with the line: "Here I am ... in the classless estate o'the dead." The sense of loss, of being the last man sitting, as it were, continues in a roll-call of departed comrades - the Jimmies, Johnny Gollan, Gordon McLennan, Alec Clark, Angela Davis - and furth of Scotland to Bob Crow, Tony Benn, Nelson Mandela, Rosa Parks, Madame Allende. "You lived alongside those who breathed your beliefs," he says, addressing them.

Hambling reveals that the portrait was painted in a room at the Scottish National Union of Mineworkers' headquarters in Edinburgh while they were being dismantled, and that it was a "very sad and poignant" time. "It was the end of an era and Mick was the last bastion of everything he'd given his life to. We were alone in that room. There was a lot of hammering and bashing in the house, and we could hear things being put into boxes. You could have cut the atmosphere with a knife." McGahey had bought a new suit for the purpose, and remained stoical throughout his sittings, which took place over five mornings from 9am until 1pm.

Kay says: "When I look at this portrait, I see Mick's pride and strength. He's dressed very smartly and looks fairly confident. But there's also a fragility and vulnerability, something of his spirit. It's as if there's something timeless there, as if he's looking beyond his own death. That's an extraordinary thing for an artist to be able to do. When he turned up for his sitting each morning he'd joke about climbing back up on to the cross, which I put in the poem because I found it quite symbolic. I contacted Maggi before making my poem and lots of the details in it came from her."

The sense of mortality is infused throughout, and Kay is keenly aware that her parents are among the last of their era. So the poem is a kind of ode to them, as Red Dust Road was to her birth parents. It will be read by Benny Young.

"A lot of friends in the poem are already dead. That must be traumatic for my parents to know. People don't tend to imagine old folk thinking that way. When you have elderly parents you have a ticking clock in your life, and it becomes ever louder. Awareness of mortality is a terrible kind of awareness. When people have made a real contribution to the world, when they die there's a fear that something else has died with them."

There's a plea, as if from McGahey speaking to us from beyond the grave, to "make the best o'this planet". He says: "Scotland the open, be open/Scotland the just, be just". Is Last Room in ­Operations therefore also a comment on modern society? Is he/she asking us, pre-Referendum, not to lose (or indeed to regain) the outward, socialist attitude of pre-Thatcher Scotland?

"My hope is that Scotland remains a wee country that looks out to the world and doesn't become inward-­looking. My parents and their friends in the ­ Communist Party had a way of looking at the world that was ethical and moral. A lot of it was really humanitarian, and came from good instinct. People only think of Mick McGahey in terms of the miners' strike, but he had a massive outreach to workers of the world, a huge social consciousness.

"The immediate post-Thatcher ­generation had complete myopia and people who cared were a dying race. But now I see plenty of evidence that young people - not only in Scotland but everywhere - are more active and involved in world events. I think there's been a massive change in the last four to five years, which is very encouraging."

Kay's son Matthew, 25, is a film-maker who made Over The Wall, about a group of English footballers in Egypt during the Arab Spring. He wanted to make a ­documentary about his adored ­grandfather's life, but the older man has refused, saying "he's just one among many". That's typical, Kay says, of the attitude of solidarity in the Party, but "sometimes you need to know you're representative". "Sadly, my dad doesn't understand that."

Hambling says she felt an instant rapport with McGahey when he was first brought to her in Edinburgh during her exhibition at the Richard Demarco Gallery, and their bond lasted throughout.

"Everybody said I'd have trouble getting him in so early. But he'd turn up at 9am sharp every morning. He'd bought himself a new grey flannel suit and was very smart. I think he felt quite honoured to be painted for the Scottish National Portrait Gallery. He'd sit there and I'd paint and we'd sort out the problems of the world.

"Mick had to have a new bottle of whisky every morning, and one day he said to me, 'Maggi, I'm being asked about the petty cash!' The problem for me was that I'd set aside time in the afternoons to paint the Russian banner [given to the Scottish miners by their Russian counterparts in 1929] behind him. But he always wanted to go to the SOGAT [Society of Graphic and Allied Trades] club for a few pints after each session. I'd have to go with him, but only had a half-pint so I could get on.

"I was trying to capture his resilience and his indomitable spirit even in the face of the end of the mine workers. He was a fighter. The grit of him was real, and I admired him.

"We were both manual workers in a way: he was a miner, I work in filthy oil paint. I'd been asked to paint Mrs Thatcher a few weeks before, and I'd turned it down. Painting someone is a work of love - it's like a love affair, and at the end of it you get a painting where you remember every brush stroke. To do that means emptying yourself so that the person becomes your focus. I could not have done that with Margaret Thatcher.

"I like to think that Mick goes on being alive through this portrait and, now, through Jackie's wonderful poem."

Promenade performances of Dear Scotland run from 7.30pm to 9pm from Thursday April 24 to Saturday May 3, 2014 (no performances on April 27 or 30) at the Scottish National Portrait Gallery as part of the National Theatre of Scotland's Dear Scotland season of theatre, debate and celebration. Box office: 0131 473 2000 or www.hubtickets.co.uk