Adding a 3d array (ndarray) as displacement for material output in blender python
You can only connect a node output socket to a node input socket, it isn't just an array.

While it is possible to create custom pynodes and be able to add them to a cycles material tree, they aren't fully integrated, mainly they fail to update properly. You can find a pynode template in blender's text editor.  The two main projects using pynodes are sverchok and animation nodes and you will find both of these use bpy.app.handlers to update their custom node trees.

You might find drivers to offer a better solution. It is possible to add custom functions to the driver namespace to give you more control.

You can add a driver to control any value that can be keyframed, right-click  a value and choose add driver, you can further edit drivers in the graph editor.