A lightweight, serverless Minecraft server watcher and auto-starter.
mcservernap monitors incoming Minecraft client connections and automatically launches (and later stops) a local Minecraft server process via RCON. It enables you to avoid running your server 24/7 by:
- Listening for the first legitimate Minecraft LoginStart handshake.
- Spinning up the server process on-demand when a player attempts to join.
- Watching the server via RCON for player activity.
- Stopping the server after an idle timeout.
There is also a stop subcommand to immediately send a /stop command via RCON.
- On-demand startup: server only runs when a player actually joins.
- Idle shutdown: automatically stops server when no players remain for a set duration.
- Cross-platform: spawns a new terminal window on Windows, runs directly on Linux systems.
- Extensible: configure RCON settings, startup command and ports.
-
Ensure you have Rust and Cargo installed (see rustup.rs).
-
Clone this repository:
git clone https://github.com/yourusername/MCServerNap.git cd MCServerNap -
Build the binary:
cargo build --release
The executable can be found under
target/release/mcservernap.exe -
(Optional) If you wish to install globally:
cargo install --path .
mcservernap <COMMAND> [OPTIONS]listen— Listen for incoming connections and start the server on first join.stop— Immediately send a/stopcommand via RCON to shut down an already-running server.
| Option | Description | Required |
|---|---|---|
host |
Host or IP to bind (e.g. 0.0.0.0) |
Yes |
port |
Port to listen on for Minecraft clients | Yes |
cmd |
Command or script to launch the Minecraft server | Yes |
args... |
Arguments passed to the server command | No |
--server-port |
Port of the actual Minecraft Server that users will get forwarded to | Yes |
--rcon-port |
Port for the server’s RCON interface | Yes |
--rcon-pass |
Password for RCON authentication | Yes |
Important
When not using a script and instead executing a command with its own arguments, you need to append the command to the end of the line followed by -- and all the arguments of the command. See below for an example!
Note
The port of the Minecraft server does not require port forwarding, only the port of this application.
mcservernap listen 0.0.0.0 25565 --server-port 25566 --rcon-port 25575 --rcon-pass rconpasswordmeow java -- -Xmx5G -Xms5G -jar server.jar noguimcservernap listen 0.0.0.0 25565 "C:\path\to\your\script\start_server.bat" --server-port 25566 --rcon-port 25575 --rcon-pass rconpasswordmeowIMPORTANT: When using a script, make sure the script closes its window at the end of the script (Windows .bat example: exit), or else this application won't detect that the Minecraft server process has shut down!
Once a client sends a LoginStart packet, the tool:
- Drops the listener and launches your server command.
- Starts an idle watchdog task that polls RCON according to
rcon_poll_interval. - If no players remain for the defined amount of
rcon_idle_timeouttime, sends/stopand exits.
| Option | Description | Required |
|---|---|---|
--rcon-port |
Port for the server’s RCON interface | Yes |
--rcon-pass |
Password for RCON authentication | Yes |
mcservernap stop --rcon-port 25575 --rcon-pass rconpasswordmeowThis immediately connects via RCON and sends the /stop command.
env_logger::Builder::from_default_env()
.filter_level(log::LevelFilter::Info) // Change this LevelFilter to change logging level (e.g. Debug)
.init();You need to rebuild the project for the change to take effect.
Configuration Options:
- Timeouts & Intervals: set via
rcon_idle_timeoutandrcon_poll_intervalin seconds - Message of the day (MOTD): The message shown to the user in the server browser menu. set via
motd_text,motd_colorandmotd_bold - Connection Message: The message shown to the user when they try to connect. Set via
connection_msg_text,connection_msg_colorandconnection_msg_bold - Server Icon: The icon of the server within the server browser menu. Set by inserting a
.pngfile in theconfig/folder with the nameserver-icon.png. The image must be 64x64 pixels big. If it's not, this application will automatically resize the image to meet this requirement - Configuration Directory: The location of the
cfg.tomlcan be changed from the standardconfig/directory by editing the value ofconfig_directory_name. This will delete the previous directory and move the files to the new one
Contributions are welcome! Feel free to open issues or pull requests to:
- Support TLS or SSH tunnels for RCON
This project is licensed under the MIT License. See LICENSE for details.