Say the boundary in operational terms
Name the contact, behavior, topic, access, or commitment you will and will not participate in. For a message about how to ask a friend to stop surprise visits, use this factual base: name the recurring contact, request, topic, or behavior and the effect it has on you.
Define any necessary exception
If an exception is necessary, give it one purpose, one channel, and a clear limit. State the limit, any acceptable alternative, and what you will do if the pattern continues. Make the immediate next step clear enough that the recipient can answer without reconstructing the entire history.
Respond to escalation safely
Do not diagnose your friend, list every past grievance, or threaten public embarrassment. For stalking, threats, coercion, or self-harm concerns, preserve evidence and use appropriate crisis or safety support. You do not need the other person to agree with a boundary for you to follow it consistently.