The method mongo_simple_str_command(…) in mongo.h seems to be what you are searching for.
mongo_simple_str_command(conn, db, "$eval", "db.foo.find()", out);
I found an usage example here: https://github.com/mongodb/mongo-c-driver/blob/master/test/platform/linux/timeouts.c