Does the RA (resolution Advisory) from TCAS II take into account the stall margin required?
Yes, but not directly. The TCAS is a generic box that doesn't really know anything about the aircraft performance. What it does have is a number of input discretes that allow other aircraft systems to indicate that the aircraft climb performance is limited. Other discretes code the altitude above which the aircraft cannot perform an RA climb. What drives these discretes will be unique to a specific aircraft type and defined during the STC process.  

ARINC 735A TCAS Characteristic defines the following:  


  Climb Inhibit Discrete Input #1 through #4
  Increased Climb Inhibit Discrete Input #1 through #4
  Performance Limit Discrete Input
  Aircraft Altitude Limit Program Pins  


Based on these inputs the TCAS logic will compute an RA that does not require the aircraft to climb when it is not able to safely do so.