I have a great nephew that has resided with me the whole year of 2016, the parents are divorced and agree to me filing him as a dependent on my return; can I do this?

If so, do I file head of household and do I list as son, foster child, etc?  Do I need a signed agreement from the parents?