Packet filter to clean up xss?

Hi,

I am creating a web chat interface and need filter for XSS on the server side, how can this be accomplished? Is there a plugin I can use or do I need to filter this by modifying the server code?

-varworld