McLaren has bought back the majority of Mercedes-Benz's stake in its Formula 1 team.