When X-rays penetrate in the matter, they interact with the atoms, producing secondary radiation that carries important information about the composition of the target. The polarization state is one of the properties of the incoming photons which changes as a consequence of the number and the type of the undergone interaction. Therefore, to study properly the atomic properties of a material, it is necessary to consider the evolution of the polarization state of radiation. It is presented MCSHAPE, a Monte Carlo code developed to describe the evolution of the polarization state of X-ray photons as a consequence of the multiple scattering collisions undergone during the diffusion into the sample. In order to study properly the transport of photons with an arbitrary state of polarization, the model adopted in this code is derived from the so called ‘vector’ transport equation [Radiative Transfer, Chapter 1, Section 15, Clarendon, Oxford, 1950; Nucl. Instr. and Meth. B 73 (1993) 341]. Using the Stokes parameters I, Q, U and V, having the dimension of an intensity and containing all the physical information about the polarization state, MCSHAPE simulates the full state of polarization of the photons at any given position, wavelength and solid angle.