Follow the instructions for installing Groovy-Eclipse Plugin.
To develop a Groovy Script
Create a Groovy project.
Right-click the project in Package Explorer and click Properties.
Click Java Build Path in the tree on the left-hand side. Click the Libraries tab on the right pane.
Click Add External JARs to add all the JAR files in <MagicDraw>/lib and in <MagicDraw>/plugins/com.nomagic.magicdraw.automaton/engines/groovy-2.0.1/embeddable/groovy-all-2.0.1.jar.
Click OK to close the dialog.
Create a new Groovy class in the project. Remove a class declaration, and then put the script there.