The city was founded in 1899 as a railway depot linking Uganda to Mombasa . Founded in 1899 as a simple rail depot on the railway linking Mombasa to Uganda , the town quickly grew to become the capital of British East Africa in 1907 and eventually the capital of a free Kenyan republic in 1963 .