Do you have the CloudFoundry plugin installed in your Grails project? The plugin does the auto-reconfig for the MongoDB and other data sources in a Grails app.
If for some reason you can't, or don't want to, use the Grails CloudFoundry plugin, another alternative to using the environment variables as you showed above is to use the cloudfoundry-runtime Java API. This API gives you access to the same info as is stored in the environment variables, but it is a little cleaner than parsing the environment variables directly.