Mara - a Python network service framework

I've released a new version of Mara, my network service framework written in Python. It aims to make it easy to build TCP/IP services, such as echo servers, flash policy servers, chatrooms, talkers and MUDs.

It's event-based; that is to say you write event listener functions which you bind to events that your service raises - like Connect, Receive or Disconnect.

Mara is on pypi, so you can pip install mara, then start writing your service. An echo server in Mara looks like this:

from mara import Service
service = Service()

def receive(event):

if __name__ == '__main__':

You can then save it as and run the service by calling it:

* Server listening on

That's a pretty simple example, but Mara can do a bunch more. Its core has support for things like telnet negotiation, timers, a storage system, and seamless restarts (where client connections and storage objects persist, but your code is reloaded cleanly), and it ships with a contrib module which has a lot of optional extras, such as a command manager and dispatcher, basic natural language tools, user accounts and rooms.

Although there's a focus on talkers and muds in the contrib modules at the moment, Mara should be a reasonable base for writing any network service. To get a feel for what you can do with it, take a look at the examples, which include an IRC-style chat server, a simple talker, and the start of a basic mud. There's also fairly comprehensive documentation.

I've always enjoyed writing this sort of thing, so this is a fun side project for me. At its heart Mara is a rewrite of my old perl chat server Cletus, which I wrote in 2001 - in fact if you dive back a few months through git, you'll see Mara was called Cletus until I realised that name was taken on pypi.

It's still missing a few glaringly obvious features at the moment - most notably unicode and python 3 support, an example of using threads through events and timers, and more contrib modules for the mud like items, combat and NPCs. That said, it should make a solid starting point for any network service that you'd want to write, and as always, contributions are welcome.

Leave a comment