The MacroCategoryManager from Rendering Macro Transformation provides a getMacroCategories operation that takes a MacroId object and return the set of categories of the macro. The default implementation takes into account the macro categories overriding that can be done in xwiki.properties.