is_main_query() not working for WP REST API

To answer the question directly – The REST API do not initialize a main query, therefor there should not be any for requests coming that way.

What you should do is to create your own end point and server what ever custom data you need on it. Modifying the REST API, while possible, violates the whole idea of having a consistent and documented API in the first place.