Place the mushrooms (gill side facing up) on a baking sheet.
Drizzle them with 2 teaspoons olive oil, and sprinkle on a pinch of salt and pepper.
Put them into the oven and broil for 5 minutes.
Flip the mushrooms over (so the gill side is facing down) and broil for 5 minutes more.
Remove the mushrooms from the broiler and preheat oven to 425 F.
Heat the remaining 1 tablespoon olive oil in a medium skillet over medium heat.
Add the onion and saute until softened and just starting to brown, about 5 minutes.
Stir in the spinach, garlic and thyme and cook until the spinach is wilted, about 1 to 2 minutes.
Remove from the heat and allow to cool completely.
In a medium sized bowl, mix together the spinach mixture, ricotta cheese, egg, half of the shredded mozzarella, 1/4 teaspoon salt and a pinch of pepper.
Place each mushroom (gill side facing up) in an individual gratin dish.
Divide the spinach/ricotta mixture between the 2 dishes and top with the remaining mozzarella.
Bake at 425 F for 10 minutes.
Then turn the oven to broil and broil the mushrooms for a couple minutes to brown the tops.