How does the server get the correct MSS value in the TCP triple handshake

When the client establishes TCP connection with the server, it will report its MSS value during the third handshake. According to my understanding, the MSS value should be obtained by subtraction 40 from the MTU value of its interface. If the MTU value of the client interface is 1500, its MSS value to the server is 1460, which is OK at the client.What I find confusing is that the MSS given by the server to the client seems to dynamically sense the minimum MTU between the server and the client and then subtract 40. For example, if I change the MTU of the router interface between the client and the server to 1400, the MSS given by the server to the client would be 1360;I know that it is possible to detect changes through PMTUD after establishing a TCP connection, but this is happening during the TCP handshake 3, and the server gets the correct MSS value. How is this happening?