The loss of urban biodiversity presents challenges to the management of urban ecological resilience and landscape planning. Existing research has sought to uncover the impacts of interactions between biotic and abiotic factors on urban biodiversity, yet there is still a lack of sufficient depth in insights to support decision-makers in prioritizing limited resources for key areas. In this study, we utilized models such as structural equation modeling, hierarchical partitioning, and boosted regression trees to comprehensively analyze the key factors, mediating effects, and thresholds of the urban environmental matrix on bird diversity in the Shanghai area. The results identified the primary environmental matrices influencing bird diversity and their thresholds, such as vegetation cover (>0.6) and vegetation height (>10m) which promote bird diversity, whereas taller buildings (>60m) and higher building density (>0.3) are harmful. Human activities and levels of urbanization generally have a negative impact, affecting biodiversity indirectly through mediating effects such as increased habitat fragmentation and reduced habitat quality. The study emphasizes the nonlinear impacts of the built environment on bird biodiversity through mediating effects, providing new insights for urban planners to enhance biodiversity and effectively improve ecological urban resilience.