A novel luminescent cobalt-organic framework was assembled and employed as a chemosensor for the detection of metal ions via fluorescence enhancement and quenching. The sensing mechanism was based on the exposed pyridyl and carboxyl functional sites in the MOF structure, which interacted with metal ions via Lewis acid-base interactions and electrostatic interactions.