James MacKenzie worked for several engineers in Britain before he was appointed as assistant engineer on the reconstruction of the Tay Bridge, near Dundee, which had been destroyed in a storm in December 1879. He emigrated to the Cape Colony in 1889 to join the Cape Government Railways. After supervising the building of the Dom Pedro Jetty at Port Elizabeth he joined the Natal Government Railways in 1890. That same year he married Annabel A. Russell of Scotland. Their son, Leonard Alexander, also became a civil engineer.
In Natal MacKenzie was responsible for the construction of the railway line through Van Reenen's Pass into the Orange Free State, where he introduced reversing stations to enable locomotives to ascend the steep gradients. From there he moved to the South African Republic (Transvaal) where he supervised the construction of the railway line from Pretoria to Pietersburg (now Polokwane) for the Nederlandsche Zuid-Afrikaansche Spoorweg-maatschappij. In 1896 he returned to Natal and was placed in charge of the line from Dundee to Vryheid.
He returned to the Cape Government Railways in 1901 and was responsible for the construction of the Kalbaskraal-Hopefield and Amabele-Butterworth lines. In 1903 he was stationed in Ceres and the next year in Kokstad. In 1905 he settled in Cape Town as bridge engineer, with responsibility for the design, construction and strengthening of all railway bridges in the Cape Colony. He was an associate member of the (British) Institution of Civil Engineers and a paper on bridge construction earned him the Institution's Telford Gold Medal. After the formation of the Union of South Africa in 1910 he became bridge engineer to the South African Railways and Harbours, and was stationed in Johannesburg until his retirement in 1922. He introduced many engineering innovations and was responsible, among others, for the construction of the Sauer Bridge over the Gouritz River (near Mossel Bay) and the Beit Bridge over the Limpopo River (near Musina). He also supervised the construction of the first grain elevators in Cape Town and Durban.
MacKenzie joined the Cape Society of Civil Engineers in 1904, shortly after its formation. In February 1906 he read a paper before its members on "Some methods of railway surveying in South Africa", which was published in its Minutes of Proceedings. From that year he furthermore served on the society's council, and as joint vice-president for 1909 and 1910. Later he read several papers before its successor, the South African Society of Civil Engineers, served on its council, and was elected president for 1915. After his retirement he did consulting work for the Rhodesian Railways and the Colonial Development Corporation.