Yes, spies are great tools for disrupting your enemies and manging your own empire. Back to topic: in S:TW, and likely also in M:TW, there are two types of A.I. invasions: opportunistic ones and planned ones. The former happened when the computer had a powerful army near an ill-defended border. The latter were coordinated affairs, where the computer concentrated troops near or at the border, and of these your shinobi (spies) could forewarn you. I've even had warning of planned invasions into the territory of other factions. However, if the borders were strenghtened, or the A.I. became distracted by another war, the attack would most often be canceled.