A python package which wraps around a minecraft server, providing easy access for other programs which want to programmatically manage minecraft servers.
Supports versions 1.7.10 to 1.20.4 (excluding 1.8.0, which is severely bugged, 1.8.1+ is fine again)
Supports versions 1.7.10 to 1.16.5 as well as 1.20.3 to 1.20.4
Tested to work with Python versions 3.8 to 3.13.
Tested to work on Windows 10 and Ubuntu.
Different Linux distros and Windows 11 might work as well. If not, please open a new issue.
Not yet available
To install the latest version directly from Github, run the following command:
pip install git+https://github.com/mcserver-tools/mcserverwrapper.gitThis will automatically install all other dependencies.
A simple usage example is shown below:
from mcserverwrapper import Wrapper
wrapper = Wrapper("/my/server/directory/server.jar")
wrapper.startup()
wrapper.send_command("/say hello minecraft")
wrapper.stop()In this example, a minecraft server is started by providing the path to its server.jar file. After startup, it sends a command to the server. Finally, the server is stopped gracefully.
More examples can be found in the examples folder.
If you want to contribute to this project, you need to set up your local environment.
Run the command
git clone https://github.com/mcserver-tools/mcserverwrapper
cd mcserverwrapperin your terminal.
To install all optional as well as development python packages, run the following commands in the project root.
Windows:
py -m venv venv
venv\Scripts\activate.bat
pip install -r requirements.txtLinux:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtNode 20 is needed to use MineFlayer. The install instructions can be found below:
It can be downloaded from here.
Install it using the commands found (here)[https://github.com/nodesource/distributions?tab=readme-ov-file#debian-and-ubuntu-based-distributions].
To simulate a player connecting to the test server, MineFlayer is used.
It can be installed by running
npm install mineflayerTo actually run a minecraft server, a Java 21 JRE needs to be installed and added to the path.
Download it from (here)[https://adoptium.net/temurin/releases/].
To simulate a player connecting to the server, it needs to authenticate against microsofts servers. This means, that a microsoft account which owns Minecraft is needed. Don't worry, the credentials are only saved locally.
Create a new file named password.txt in the repository root and add the following content (without the brackets):
(username-here)
(password-here)
After installing all of the requirements, the tests can be ran using
python -m pytest src -rs --skip-linting --skip-test-allIf you want to run tests for all Minecraft versions, remove the --skip-test-all argument from the command above.
Warning Beware that testing all versions can take multiple hours!
Pre-commit hooks are used to check and autofix formatting issues and typos before you commit your changes.
Once installed, they run automatically if you run git commit ....
Using these is optional, but encouraged.
pip install pre-commit
pre-commit installTo verify the installation and run all checks:
pre-commit run --all-files