If I'm understanding you correctly, you want your connection thread in MHD to essentially submit some data/request to a 'main loop' thread, and for it to then wait for the main loop to process it before returning/sending the response back to the client? If so, and assuming MHD and your main loop are just threads within the same process... The way I do that kind of thing is to use condition variables and/or a blocking queue.
Your MHD thread would submit the request to the main loop (very likely into a queue that the main loop processes), then wait for a response. You can wait for a response by "waiting" on a condition variable that the main loop will "notify" when it has completed processing the data. ('Wait' and 'notify' are the proper terms - you'll see them if you search around for this stuff.)
Or, if you have access to one and/or want to write one, you can do something similar using a blocking queue. First, have your MHD thread submit the request to the main loop (again, into some kind of queue). Then, have your MHD thread read/pull from a one-item request-specific blocking queue that the main loop will write/submit the response to. (The blocking queue will likely use a condition variable under the covers, by the way.) In other words - when the main loop writes to that request-specific blocking queue that the MHD thread is waiting on, the MHD thread will wake up and pull it from the blocking queue to finish processing the request - necessary data in hand. This is probably slightly less efficient than the raw condition variable stuff, but it makes the code simpler because it allows you to hide that condition variable from the code that's using it.
In both cases and if you want to, you should be able to 'wait' for a maximum amount of time. E.g., if it takes longer than 3 seconds to get a response, the MHD thread could wake up anyway and submit an error message back to the client.
This all may be a lot easier in C++ (using the std lib) than it is in C - I'm not sure. I know raw pthreads have support for condition variables, but I've never played with them myself. Writing a blocking queue is not particularly difficult if you don't have one - less than 50 lines of code (at least that's how it is in C++).
If your MHD-based web server is in fact a separate process from your 'main loop' (not just separate threads), well.. then you're doing real IPC, which can bring a whole host of pain. The simplest (and likely least efficient) way is probably just to use sockets and send messages back and forth. Search around for IPC methodologies to see what your options are - I'm no expert (I vaguely recall a Beej guide to IPC that I found informative). MHD is so lightweight, I'd suggest going the thread-based route, myself - just make your MHD-based-webserver part of the application rather than a standalone process and use some kind of thread-handoff methodology (e.g., like one of the 2 I suggest above).
Hope that helps.
Ken