Lithium metal is an ideal anode material for next-generation electrical energy storage because of its high specific capacity. However, uncontrolled growth of Li dendrites during deposition and stripping processes results in low coulombic efficiency and severe safety concerns. Here we report a porous and robust coating of metal-organic framework (MOF-199), which could physically suppress the growth of lithium dendrite by acting as a robust shield, and homogenize Li-ion concentration by its high-polarity structure, thereby relieving excess SEI formation. In addition, another MOF (ZIF-8) layer is also confirmed to effectively hinder the formation and penetration of Li dendrites. The MOF particle size in the coating layer is shown to be a key factor determining the level of protection. Finally, the ability of the MOF-199 layer to protect Na metal anodes is studied.