We had our two (adult adoptees) microchipped and bought a SureFlap microchip cat flap for them.
The microchip was about £22 for each cat (we are in Inner London, no idea what vets charge elsewhere).
As they are both older - and had never known a cat flap previously - they have struggled a bit. MadFruCat 'got it' within about 2-3 weeks, but DozyFruCat has taken about 6-8 weeks to get his head around it! He's just about getting there now!
Like you, we also have problems with various neighbourhood cats coming into our garden. They are not a major problem, as our 2 are OK (ish) with the others, as long as they are outside. But, to begin with, I think our 2 were concerned that the others could also get in 'their' cat-flap.
They do know, now, that the others can't get in. But we've had a long haul on this one. Also, the neighbourhood cats still come and 'sniff' our cat-flap - so our 2 don't like the smell of the other cats on their door!
Actually, every now and again, I wipe down the outside (and inside) of our cat-flap with an Ecover cleaner to destroy the smell of the other cats. But this, of course, makes ours a bit suspicious because they can't smell themselves. There's no winning!
But .... trying to teach them to get in and out ..... oh boy, that was a drama!