How can I access a computer behind internet sharing?

Solution 1:

I got it! I wrote a node.js script, like so, to redirect requests on port 8080 of the macbook to port 8080 of the raspberry pi. the pi's ip is 192.168.2.7.
the script:

var net = require('net');
net.createServer(function(socket) {
  var raspberrypi = net.connect(8080, '192.168.2.7');
  raspberrypi.on('connect', function() {
    raspberrypi.on('data', function(data) {
      socket.write(data);
    });
    socket.on('data', function(data) {
      raspberrypi.write(data);
    });
  });
}).listen(8080);