Indesign has a function that can be able to build a contents automatically, as what the paragraph style you had selected.
But if your selection is on the master page, it doesn't work.
What question is if it is possible to make it happen.
And if it's a book with many file, whether or not who can make it possible just one click to build a contents quickly.
To include content from a master page object in the TOC you can manually override it onto the document page.
TOC is always a story in a single document, but if working with a Book there is a checkbox in the TOC dialog to Include Book Documents.