Is it possible to detect the current power input on a MacBook?
There is a straightforward way to determine instantaneous* battery charging current, assuming you have developer tools installed:
ioreg -rw0 -c AppleSmartBattery | grep -o -e '&quot;ChargingCurrent&quot;=[0-9]*'

The number is specified in milliamps.
However, this is not going to be the same as the current entering through your AC adapter (this is most apparent when the battery is fully charged, in which case the current will be 0), so it may not help you with what you're doing. I'm not aware of a place where that information gets published, although the PMU must certainly measure it.
Similarly, you can view the instantaneous* voltage of the battery, in millivolts, with
ioreg -rw0 -c AppleSmartBattery | grep -o -e '&quot;Voltage&quot; = [0-9]*'

which, when multiplied by the above current, will give you the power being delivered to the battery (in microwatts, so divide by a factor of 1,000,000 to get watts). But, again, it is not the same as the power being delivered by the AC adapter.
You can view more power-related parameters with
ioreg -rw0 -c AppleSmartBattery

Update:
I experimented on two systems – a T2-based MBP with Catalina and a non-T2-based MBP with Big Sur – and found that the former has the keys AdapterPower and SystemPower contained in the BatteryData dictionary property of AppleSmartBattery:
&quot;BatteryData&quot; = {&quot;StateOfCharge&quot;=98,&quot;PMUConfigured&quot;=0,&quot;DesignCapacity&quot;=8790,&quot;QmaxCell1&quot;=9017,&quot;AdapterPower&quot;=1101610469,&quot;SystemPower&quot;=1104635067,&quot;ResScale&quot;=244,&quot;QmaxCell2&quot;=9048,&quot;QmaxCell0&quot;=9082,&quot;CycleCount&quot;=69,&quot;Voltage&quot;=12503}

So this is a promising source for determining both the power being delivered by the AC adapter as well as the power being consumed by the system. These, along with the earlier battery charge current &amp; voltage that I showed, could give you a pretty complete picture of the power situation.
I couldn't figure out the units at first, since the numbers are too high to be W, mW, and even µW, and too low to be nW. Then I remembered that some keys are stored as floating point values, and when I converted 1101610469 into an IEEE-754 float, I got the very reasonable-looking 21.1552219391, which means that it's published in units of watts.
You can therefore – on at least certain hardware or software – view the AC adapter power consumption with
ioreg -rw0 -c AppleSmartBattery | grep BatteryData | grep -o '&quot;AdapterPower&quot;=[0-9]*' | cut -c 16- | xargs -I %  lldb --batch -o &quot;print/f %&quot; | grep -o '$0 = [0-9.]*' | cut -c 6-

and system power consumption with
ioreg -rw0 -c AppleSmartBattery | grep BatteryData | grep -o '&quot;SystemPower&quot;=[0-9]*' | cut -c 16- | xargs -I %  lldb --batch -o &quot;print/f %&quot; | grep -o '$0 = [0-9.]*' | cut -c 6-

This uses lldb to do the IEEE-754 conversion, so you, again, will need developer tools installed. It is also very straightforward to write a small CLI tool that uses the IOKit framework to dump these out without needing Xcode installed on the target system, if you needed to have that.
* - Note that these values only seem to update once a minute or so, so they aren't truly instantaneous.