Look at the motion capture server example in the Maya SDK. You can do this with a plugin but it’s easier to just have a python script attached to the commandPort command, listening for a message on TCP that says “go to frame X” or “advance one frame”.
This stackOverflow question gives an example of how to send a command over TCP to the commandPort:
in this case you’d send the cmds.currentTime( e=your_frame_here) instead of ‘polySphere’