Execute function on remote mongodb

how do I execute a function that’s on a remote mongodb? I already have the mongodb service set up and can connect and run all the other APIs and it returns the records. But then how do I execute a function? This function returns json data. Thanks