Otp create custom spi

I have my own MFA solution, and I want to connect keycloak with my MFA.
As I understand I need to write a custom SPI .
Is there anywhere some code examples how to do it ?

You can start with the authenticator Docs: https://www.keycloak.org/docs/latest/server_development/#implementing-an-authenticator

Here’s an example of a custom fido-u2f authenticator: https://github.com/stianst/keycloak-experimental/tree/master/fido-u2f/

If you want to be independant of java framework and use typescript or javascript there is a nodejs module called keycloak-rest-authenticator that facilitate the creation of custom authenticators. It comes with examples.