This should go in the FAQs because I had to figure this out myself just this week.  The toolset.flags rule sets your TOOLSET variable "on" $(targets) for the actions block.  The undocumented magic method to retrieve that value in a rule context is the following:

local toolset = [ on $(targets) return $(TOOLSET) ] ;

Voila! 

Jaroslav Gresula <jgresula@seznam.cz> wrote:
Could someone advise me how to retrieve value of a feature within a
rule? I followed an example from the docs which uses the toolset.flags
rule but with no luck.