I just had a quick look at an old design I had. Picture this:
24vac through a single signal diode (ie, 1n4148), into a small electrolytic cap (22uF), then through a resistor to limit current into an led/phototransistor optocoupler. The resistor is 1.8K which is putting ~ 18mA through the optocoupler, rectified enough so you get an on/off output. Check your optocoupler's specs; that might be driving it a little hard.
Other side of the optocoupler: Emitter tied to ground, base is floating, and collector is pulled high (5v) with a 4.7k resistor (ie, a resistor between +5v and the collector). The collector is tied to an input pin on the MCU. When 24VAC is present, LED goes on, photo transistor goes on, so signal at the photo transistor's collector goes low. Turn it off, photo transistor goes off, MCU pin goes high due to the pullup resistor.
An optocoupler is a pretty good idea when you've got field wiring attached to a computer. You can do it without but why not?
EDIT: Going the other way, a relay or a small solid state relay is easiest. If you use a mechanical relay, you probably can't drive it directly with a MCU pin because it can't supply or sink enough current. Google "TTL relay driver" for a schematic. (Exception; you may be able to use a reed relay driven directly, but don't omit the freewheel diode.) A solid state relay can be driven directly since it's input is usually a LED or an LED with a resistor in series.
Any hints on the micro you plan you use?