MongoshScriptEngine execute result instanceof xxxResult return null Why is it null? It actually has results in mongosh. I changed it so that it can always return the result. if (result instanceof VoidResult || result instanceof MongoShellUpdateResult || result instanceof BSONTimestampResult){ return Util.ok(result._asPrintable()); }else if (result instanceof DateResult || result instanceof DBRefResult || result instanceof InsertOneResult || result instanceof UUIDResult){ return Util.ok(result.getValue().toString()); }else { return Util.ok(result.getValue()); }