The harbor at Wadi-Al Jarf dates originally to the 4th Dynasty in Egypt, and was almost certainly constructed or greatly expanded under Khufu (2589–2566 BCE). It is in fact the oldest clearly-identifiable harbor and is about a millennium older than the next best contender. It is a very important site that has suffered greatly from political obstacles to proper excavation. Fortunately, that is changing now and the site is finally getting a proper investigation. That work is already turning up positively amazing discoveries. The site does not, however, have anything at all to do with the Medieval period, which began over three millennia later. That part of your question is therefore confusing.
As far as technology: building a breakwater and other harbor facilities was not a technological hurdle by any means. This is the same society that built the pyramid of Khufu (a.k.a. the great pyramid of Giza). All that is required for the construction of a breakwater is a lot of stones and the means to transport them out into the water. Gravity does the rest. About 2500 years later, the Romans would use their special waterproof cement in such projects, and that was a technological feat, but for a basic harbor and breakwater, waterproof cement is not strictly required.