In yet another absolutely amazing display of nature's prowess, the contents of the egg are wrapped in a perfect, seamless, incredibly strong shell as though by magic! Eggs are objects of art.
It turns out the chicken has little to do with the formation of an egg's shell -- the egg actually grows the shell around itself! It does this using processes that are also seen in bones and seashells. Around the egg is a membrane, and evenly spaced on the membrane are points where columns of calcite (a form of calcium carbonate) form. These columns stack together side-by-side to form the shell. According to an incredibly interesting book called Made to Measure by Philip Ball:
The nucleation points are defined protein nodules called mammillary protrusions, and the mineral is first deposited as particles of aragonite with random orientation of the crystal planes. On top of these aragonite piles, columns of oriented crystalline calcite begin to grow upward.
The calcite is basically floating in solution around the shell and deposits on the shell like a forming crystal. The egg grows its own shell!