AppleScript to connect Magic Mouse on iMac
It sounds like you know how to create a systemwide Service or Quick Action, and just need a script to open the actual bluetooth connection.  Test the script below initially in Script Editor, which requires any device you wish to connect to have already been paired (it sounds like this is the case).  All being well, you can be reasonably confident it will work if you transplant it into an Automator workflow (if you first get rid of any sample code that appears, i.e. on run {input, parameters} etc.

use framework "Foundation"
use framework "IOBluetooth"

property this : a reference to the current application
property nil : a reference to missing value
property _1 : a reference to reference

property IOBluetoothDevice : a reference to IOBluetoothDevice of this
property NSPredicate : a reference to NSPredicate of this

property pairedDevices : a reference to IOBluetoothDevice's pairedDevices
property text item delimiters : linefeed &amp; tab &amp; "- "

to deviceWithName(name as text)
    local name
    NSPredicate's predicateWithFormat:"name==[c]%@" argumentArray:[name]
    tell filteredArrayUsingPredicate_(result) of pairedDevices
        if |count|() &gt; 0 then return its firstObject()
        error {"No device by that name. Available devices:", ¬
            getDeviceNames() of me} as text
    end tell
end deviceWithName

to getDeviceNames()
    (pairedDevices's valueForKey:"name") as list
end getDeviceNames


try
    if deviceWithName("Magic Mouse 2")'s openConnection() ≠ 0 ¬
        then error "Could not open connection."
on error E
    return E
end try

true


NB. This script has only been tested in High Sierra

I'm afraid the error messages are not especially forthcoming with information should something not work as expected.  But, if the device can connect, the script should be manage it.  If it fails to connect, test that you are able to establish a connection manually.