Most things in the game have a counter (ie, PEKKAs are weak to tesla, barbs/archers are weak to mortars), and it just so happens that the poison spell is the counter to the clan castle.
There's not much you can do to protect yourself once the castle troops are out. What you can do is attempt to put your castle in a spot where it's hard to pull the troops out. Try to centralize the clan castle so that it takes a significant amount of deployed troops to destroy enough of your base and get your guys to come out.
This can spiral into other areas of your base design if you try to protect against, say, a hog rider pull. If you put anti-hog defenses (ie, giant bombs) near the side of your base nearest the clan castle, you can play mind tricks on your attackers while they try to pull your clan castle troops.
I've found, however, that most of the time my attackers are pretty "unprepared" and either don't bring poison, don't bother to pull the clan castle, or just forget completely about it. I know most of the bases I raid don't have clan castle troops to begin with.