Having begun his career as a trainee at QPR, had a spell at Kingstonian and then joined Mansfield in March 2005.
Although Coke is out of contract, the Stags are entitled to a fee as he is under 24 - and that will be decided by a Football League tribunal.
He has made 70 league appearances for the Stags.
"I have told hium that it is a fresh start and a clean slate for everyone," Gray told the Cobblers' website.
"I inherited the situation with Andy, but I have told him that what happened last season is in the past. I want Andy to feel settled and wanted."