Use PHP Class in WordPress functions

If you have defined the class MyCart directly in functions.php with your hooks. I’d expect for the following to work:

// add action
$cart = new MyCart();
function emdr_add_to_cart(){
    $items = $cartClass->get_users_cart_contents();
    // process items
}
add_action( 'woocommerce_add_to_cart', 'emdr_add_to_cart');

I might also add that duplicating the “state” of the users cart in 2 places is probably a code smell. I would suggest using the values directly from the WooCommerce cart.