You can achive this using APIs.
Get the organizationId: Use this endpoint:
GET /organizations
This returns all the organizations you have access to, including their ID.
List all devices and filter active MX devices: Use this endpoint:
GET /organizations/{organizationId}/devices/statuses
This endpoint returns all devices in the organization with their status (online, offline, etc.) and type (MX, MS, MR, etc.).
You can filter those with:
status = "online"
productType = "appliance" (which corresponds to the MX devices)
I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.
Please, if this post was useful, leave your kudos and mark it as solved.