How to add node in the center of the Shader Editor with python?
Feed it into the transform operator.
Rather than place the node into the editor at the location of view centre, suggest: make active and  feed the created (and / or other selected) nodes into the transform operator.
If you add say 3 nodes in your operator could make them relative to each other and let the user place them.
The script in the answer https://blender.stackexchange.com/a/197449/15543 creates a menu to add any of the math nodes from an expanding menu.  Use commented return instead

class AddMathNode(Operator):
    ''' Add Math Node '''
    bl_idname = &quot;node.add_math&quot;
    bl_label = &quot;Add Math Node&quot;
    items = [
        (p.identifier, p.name, p.description) 
        for p in ShaderNodeMath.bl_rna.properties[&quot;operation&quot;].enum_items
            ]
    #print(items)
    operation : EnumProperty(
        items=items,
        name=&quot;Operation&quot;,
        default='ADD',
        )
            
    def execute(self, context):
        # the material in the node editor
        mat = context.material  
        # add a new math node to its nodes         
        n = mat.node_tree.nodes.new(&quot;ShaderNodeMath&quot;)
        # set some properties
        n.operation = self.operation
        n.name = self.operation.lower().title()
        # make active
        mat.node_tree.nodes.active = n

        return bpy.ops.transform.translate('INVOKE_DEFAULT') # use translate   

Putting in 2d region centre.
Most spaces in blender have a 2d region which is the window we look into. The tool panels, headers and other parts making up the area. Others like the 3d view have a 3d region.
If need be will supplement answer with how to place node right in the middle, but alas think that having the option to move and drop where I want feels more consistent with default behaviour.