Hi insearchof,
From wikipedia:
http://en.wikipedia.org/wiki/Polymerase_chain_reaction_optimization#Magnesium_concentration
Magnesium concentration
Magnesium is required as a co-factor for thermostable DNA polymerase. Taq polymerase is a magnesium-dependent enzyme and determining the optimum concentration to use is critical to the success of the PCR reaction.[3] Some of the components of the reaction mixture such as template concentration, dNTPs and the presence of chelating agents (EDTA) or proteins can reduce the amount of free magnesium present thus reducing the activity of the enzyme.[4] Primers which bind to incorrect template sites are stabilized in the presence of excessive magnesium concentrations and so results in decreased specificity of the reaction. Excessive magnesium concentrations also stabilize double stranded DNA and prevent complete denaturation of the DNA during PCR reducing the product yield.[3][4] Inadequate thawing of MgCl2 may result in the formation of concentration gradients within the magnesium chloride solution supplied with the DNA polymerase and also contribute to many failed experiments.[4]
Back to me again - what does this mean? The polymerase used is stable at very high temperatures (it is derived from an organism that lives in extremely hot water), and those temperatures alter the physical characteristics of the DNA, speparating the twin strands, which makes PCR possible. The polymerase enzyme is magnesium dependent, it can't copy DNA without magnesium. Too little magnesium means the polymerase will not work, too much protects the DNA even so that it is stable at high temperatures - it remains double stranded. Double stranded DNA cannot be copied without first separating the strands.
I gather that optimization of magnesium concentrations is dependent on the target DNA. I do not know enough about this process to comment further on this point, I would only be speculating.
http://www.caister.com/molecular-biology-blog/2008/11/pcr-troubleshooting-mg-concentration.html
This site discusses Mg troubleshooting for PCR briefly. When certain other substances are used in the reaction, they can alter magnesium ion concentrations and so the magnesium level has to be adjusted. There are entire manuals on PCR optimization online, and a number of books.
I have never used a PCR machine, although I was involved in labwork in which PCR was used, but the machine was handled by an experience operator. My knowledge is more theoretical, and now old - there are many new types of PCR reactions than I studied when I was at university.
Of interest in the XMRV debate is that reverse transcription (RT-PCR) is often using MuLV reverse transcriptase, which is one reason that contamination testing is required for all reactions I suppose. RT-PCR is for amplifying RNA rather than DNA - and XMRV is an RNA virus. So if you are looking for the virus, and not its integrated DNA form, you need to look for RNA.
As to when and how it is added, I can only speculate. It is probably added at the very beginning with the rest of the reaction mixture. I doubt any is added later, if for no other reason than this would increase risk of contamination. However, this is an engineering issue, and different machines may or may not allow this - I do not know.
Bye
Alex