How to fend off a pack of feral dogs
You did exactly the right thing by getting out of there. 

When a dog commits to an attack, they make a beeline in the last part of their approach straight at the target.  One technique is to cast and ride easy till the animal commits and accelerates, then pour on the power and accelerate forwards.  Animal will pass behind your rear wheel.  One or Two pedal strokes is all you'll have time for.

Risks are that you suffer a mechanical problem induced by the extra power.  If there's ever a moment you don't want your chain to break, its right then.

Three working as a pack would be extra terrifying.  Smart dogs will herd you, and these sound smart because they're still alive.

The dogs will most of the time go for feet and ankles, shins/thighs, because they're moving and are at the lowest height.  The might aim for a forearm or hand because of the wide stance of a MTB.   Adding barends might act as a shield/barrier for the hands.  Wearing stout leather boots with steel or composite toe caps will help if the dog gets that close.  Leather chaps would make riding hard and hot and uncomfortable.



As for defence, some suggestions with their downsides


Kicking - we all have feet and they're already on the bike with you.  But by kicking you're not powering the bike, which takes away from getting away.  
Water balloons in a front basket for easy access - throwing at a small moving target is hard enough when still, from a rolling bike would be much harder.
Water balloons filled with fake skunk - same as above, but you don't want to break one on yourself.  However you might be able to smash these into the ground in front of the dog.
Water bottle squirt - surprisingly effective, if you have enough for a blast.  Again, one had off the bars, and aiming from a moving bike makes it hard.
Stick or baton - a few sticklike things might help, but if you're waving a stick then you have one hand off the bars already, decreasing your overall power.  Plus swinging is likely to change your center of mass and make you wobblier and unstable.    If the dog gets a mouthful of the stick/pump then they can pull you over, and more so if its a nightstick or a baton with a wrist lanyard.
Long lightweight stick - I'm not sure what plants are in your region, but here we have toitoi and flax bushes that produce 1.5-2 metre long lightweight poles.  I imagine bamboo is available worldwide that will fit the ticket.  Downside is carrying it on your bike.  Possibly as a flag pole, or as a load fastened to your top tube with light masking tape for quick removal.  Waving this in the general direction of the dog should help, they are moving fast and sound "whippy", and any contact is going to sting.
Pepper spray / mace - its not legal in my country but may be for you.  This may be enough to deter a dog but you'd have to get it into the dog's eyes and mouth.  Again needs a hand off the bars to apply, so best left till a dog's got its mouth on you before falling back to this defence.
Knives - too short to do anything useful, but again may be good after the dog has bitten down.  Go for the eyes.
Swords - pretty much all the bad stuff from above wrapped up, plus they're just as likely to cut you, and swords are expensive, kinda fragile, and heavy.
Firearms - this seems like a really bad idea IMO.  Again mostly illegal in my country.


As per water balloons, you will struggle to hit a small moving target
The location may not be safe to fire
Having the weapon may make you take on a fight that you should run away from.
A shotgun loaded with shot would be a better weapon, but even then not something to carry on a bike loaded. 





If you do wound an animal to the point it can't get away but is still in pain, then "putting it out of its misery" may be a bad idea.  Smart animals can fake it to draw you close, and then lash out.   The dog's companions may use this as a distraction to attack you from the other side.  Your top priority is you.



Feral dogs are not good - long term you need to report this and hand the problem off to those who can legally do something about it.  There's a chance they're domesticated but reverted, and there may be a microchip or a collar ID to identify the proper owner.  

And having submitted a report, you have prior proof that something has happened and therefore an excuse for carrying an offensive weapon.

The location is important too.  If you're in a national park there may be restrictions about where you can be and whether you can carry any offensive weapons.

Action camera footage can be beneficial to corroborate your story, and can assist in identifying the animals.  I always ride with a handlebar camera, but you might prefer a shoulder or helmet or wrist-mounted one so you can aim the lens.   If nothing else, it can be good for the youtube upvotes later.

Carry a basic first aid kit and consider adding enough medical supplies to clean and bandage a bite or two.  Better to carry and not need, than to need and not have.