Yes, this is published.
Stephen King's Dark Tower series.
He has written himself into it as a character that, I suspect, is the ultimate dark lord. Not to mention his characters keep thinking that they are characters in someone's story. I'm going to keep reading because I like Roland and Jake, but it is getting really hard to take this seriously.
But if you like King's work, check it out. The story is to die for creative, even with the crack he keeps putting in there. I am seriously tempted to go to his web page and ask if he knows about MarySue.