Taylor Swift's stalker is going to get his head checked ... because a judge wants to see if he's mentally able to stand trial.
According to new legal docs, obtained by TMZ, the guy who has been arrested multiple times outside Taylor's NYC townhouse this month is being sent for a psychological exam.
As we reported ... David Crowe -- the man who prosecutors say has been lurking around Taylor's NYC home for a while now -- was arraigned Wednesday on stalking and harassment charges. He was set free and then was arrested again 2 hours later after going back to Taylor's block.
Now, David's facing a new charge of contempt in the second degree for intentionally violating an order of protection. His defense wants him to get a psych exam before a potential trial, and a judge agreed.
Taylor's actually been in the Big Apple while all of this has been going down ... though it's unclear if she was ever home when David was getting busted outside.
Sounds like Taylor might not have to worry about him coming by again anytime soon ... he's been ordered to remain in custody.