Server Setup

Table of contents

Quickstart

First, grab the latest server release and untar it somewhere:

curl -fsSL "https://github.com/colinmarc/magic-mirror/releases/download/mmserver-v0.6.0/mmserver-v0.6.0-linux-amd64.tar.gz" \
    | tar zxv
cd mmserver-v0.6.0

Then, create a configuration file with at least one application definition:

# mmserver.toml
[apps.steam-gamepadui]
command = ["steam", "-gamepadui"]
xwayland = true

Then you can start the server like so:

$ ./mmserver -C config.toml
2024-12-09T16:57:30.989261Z  INFO mmserver: listening on [::1]:9599

You can also create a configuration directory, and add a file (json or toml) for each application:

mkdir apps.d
echo 'command = ["steam", "-gamepadui"]' > apps.d/steam.toml
./mmserver -i apps.d

Connectivity

By default, mmserver only listens on localhost, which is not terribly useful. There are a few different options to configure which socket address the server listens for connections on.

The easiest is to bind to a local IP, or use a VPN like wireguard or tailscale:

# config.toml
[server]
bind = "192.168.1.37"

Or from the command line:

mmserver --bind $(tailscale ip -4):9599

If you'd like to stream on a public IP, or on all interfaces (with 0.0.0.0), mmserver requires that you set up a TLS certificate and key:

# config.toml
[server]
tls_cert = "/path/to/tls.key"
tls_key = "/path/to/tls.cert"

Generating such certificates and adding them to the client is out of scope for this guide. Note that while all Magic Mirror traffic is encrypted with TLS (whether you supply certificates or not), no authentication is performed on incoming connections.

Finally, you can also use --bind-systemd or bind_systemd = true to bind to a systemd socket.

System Requirements

The following is required to run the server:

Hardware/software encoding

Magic Mirror uses video compression codecs to stream the game over the wire. Hardware encoding using the GPU is needed to get the best performance and latency. CPU-based encode is available as a fallback, but it's slower, albeit slightly higher quality.

To see if your GPU supports video encoding, see the following matrix for your vendor:

Note that with the ffmpeg_encode feature, linking against a system-installed ffmpeg is supported, which may allow you to use specific CPU-based codecs not considered in this table.

CodecCPUAMDNVIDIAIntel
H.264
H.265
AV1

Building mmserver from source

The following are required to build the server and its dependencies:

rust (MSRV 1.77.2)
nasm
cmake
protoc
libxkbcommon

Besides Rust itself, the following command will install everything on ubuntu:

apt install nasm cmake protobuf-compiler libxkbcommon-dev

Then you should be good to go:

cd mm-server
cargo build --bin mmserver [--release]

Feature flags

The following feature flags are available:

Note that ffmpeg_encode takes precedence over svt_encode if enabled, but the server will always choose hardware encode if available on your platform.