You can write a node, derived from MPxNode, and construct mesh geometry in there. For the geometry you need vertex positions, face counts, and connectivity. See the docs for a good explanation of how geometry is specified. Basically the face counts and connectivity arrays are MIntArrays containing the number of vertices per face, and the vertex ids for those faces respectively. When you have those arrays you can build meshData and put it on the output plug of your node. Then in maya you connect that output to a mesh node, which takes care of drawing and many other meshy things like connections to deformers and bounding box calculations.
Here's how you create and output the mesh data in your node's compute:
(note - assume you have valid vertices, faceCounts, and connectivity. Also I left out error checking)
MFnMesh fnMesh;
MObject outGeom;
MFnMeshData fnData;
outGeom = fnData.create();
fnMesh.create( vertices.length(), faceCounts.length(), vertices, faceCounts, connectivity, outGeom );
// data is the dataBlock, aOutMesh is the output plug
MDataHandle hMesh = data.outputValue(aOutMesh);
hMesh.set(outGeom);
data.setClean(aOutMesh);
Here are a couple of plugins that create meshes:
particle_mesh This is a little complex, but it illustrates creating the mesh from vertex, counts and connectivity arrays.
shrink_wrap This makes a copy of the input mesh, modifies its vertex positions, and outputs the new mesh.
Both these nodes have their own type of course, so you can type in MEL for example:
`ls -type "shrinkWrap"`;
And both show how to add attributes to the node. Look in the initialize() function.