Solution
= Solution
Using the matrix-unit commutator and summing the adjoint indices gives
$$
\boxed{\kappa(X,Y)=2n\operatorname{tr}(XY)-2\operatorname{tr}(X)\operatorname{tr}(Y)}.
$$
Equivalently, in components this is $2nX^i{}_jY^j{}_i-2X^i{}_iY^j{}_j$. It vanishes on the scalar center, as expected because $\mathfrak{gl}_n$ is not semisimple.