Check out the area around Quincy... actually between Brooklyn and Quincy. You will be on the railway line to Central Boston and on the way to Cape Cod. It is mostly quite a nice area.
On the other hand, the area around Cambridge and Harvard may interest you more. And you will still be on a direct transport route to Boston, just a wee bit further from the Cape Cod route.
I am not knowledgeable about hotels in Boston, as I always stay with family, but if you concentrate on those areas, I feel sure you are bound to find something suitable.
Have you thought of not picking up a vehicle until you are ready to go to Cape Cod? Boston and the inner suburbs are not parking friendly, and when you do find a spot, it could cost you a small fortune.
Lifey who spends a lot of time in Boston