one way wold be to use the drievn key drive there custom atributes (rgb= or 1 if you only nee graysacle), and then do a direct conection out of that to the value in question.
but i tried this and had absolutely no problem whan i used mel like this setDrivenKeyframe -cd nurbsSphere1.new ramp1.colorEntryList[1].color;, and all that i needed i could gt directly from the script editor with a bit of testing (if you assign the key to whatever you get the code and if you change velues for the given thing you can get the atribute to drive)