Hey @sims,
Either JXA or AppleScript is the way to go.
You cannot access Keyboard Maestro shell variables outside of its Execute a Shell Script actions, because the variables are exported to the action at runtime.
You could use a script file – edit that file from VSC – and run it from Keyboard Maestro, but that's not the same as what you're requesting.
-Chris