Solution for detecting a magnetic field
One way or another, you need some kind of transducer that can make a electrical signal that is a function of magnetic field strength.  No, a opamp can't do this.  A opamp may be useful in tranforming the raw signal from such a transducer into something the microcontroller can read, but by itself a opamp is not a magnetic sensor.

Two possibilities come to mind:

Reed switch.  These are the bare switch parts of a relay, usually enclosed in a small glass envelope.  The right magnetic field causes the switch to close.  This will be the simplest solution if you have a strong enough magnetic field.  This usually means a reasonable permanent magnet can be placed with a half inch or so of the reed switch.

Hall effect sensor.  The underlying physics of these sensors creates a small electrical signal proportional to the magnetic field in a particular direction.  However, you rarely get bare Hall sensors directly.  Usually they are integrated into a single package with something that either makes a reasonable size voltage proportional to magnetic field strength, or provides a digital output, usually with some hysteresis, to indicate presence or abscence of some level of magnetic field.  Allegro is a supplier that makes a lot of these things with various options.