NumPy allowed · plain Python earns 10 bonus points
Implement the real MCP session lifecycle state machine, governing valid connection state transitions between a client and server.
Implement session_transition(current_state, event) with these valid transitions: ('uninitialized','initialize')->'initializing'; ('initializing','initialized')->'ready'; ('ready','shutdown')->'shutting_down'; ('shutting_down','exit')->'closed'; from ANY state, event 'error' transitions to 'closed'. Any other (state, event) pair is invalid -- return current_state unchanged.
session_transition(current_state: str, event: str) -> str