Reinvent the needle to something without an eye. The needles have a trap near the point, a bit like Hartmann alligator forceps, so they can be pointed needles but also grip the thread. The two needles of a module are held on one side of the mattress, pushed in parallel through a reinforcing pad, the mattress, and another pad. Then the ends of the measured and cut thread are gripped by the needle traps, and drawn back through the pads and mattress. The knot can then be tied by the two needles moving independently under program control.
That places the thread mechanism on one side of the mattress, with the needle control mechanism and knot tying on the other. The mattress would pass under a fixed bridge, like a tunnel.
A number of identical needle modules would be mounted on the bridge, so all can work in parallel. The position of the modules would result in a hexagonal pattern of tufts, which will cover the surface more efficiently, with less bunching or fold lines, than a rectangular pattern.