Like all wild birds, they pose some risk of disease to your flock so by no means should the be encouraged. My ducklings were never outside unattended until they were fully feathered, and even then until they were accepted into the flock. In my experience magpies will eat eggs and if you let them they will show up in greater and greater numbers, so it is better to keep they area where the ducks overnight fairly magpie proof and to collect "yard" eggs frequently so the magpies aren't frequently successful with the eggs. (The same is true for skunks). I have never had a magpie pose a direct threat to any of my ducks and sometimes they chase off hawks so I consider them fairly duck neutral. I think they are the same as ravens as far as ducks are concerned. If you have to leave ducklings outdoors unattended, I would do it in a completely enclosed (including top) run because everything in nature thinks they are snacks. Once they hit 8 weeks or so (fully feathered), I wouldn't worry about direct attacks from magpies unless you have bantam ducks. If you do have problems with excessive magpies, than as you said, they are very intelligent. If you kill one (or find a dead one) and hang it from a tree or some other prominent place in the center of the area you want them to avoid, they will get the message (or so I have been told by other farmers who have other issues with them - eating grain and such).