mcstatus - Minecraft Server Status

13.0.1 · active · verified Fri Apr 17

mcstatus is a Python library designed to query Minecraft servers (Java Edition and Bedrock Edition) for their status and capabilities, including player counts, server version, MOTD, and latency. It supports both synchronous and asynchronous operations. The current version is 13.0.1 and it's actively maintained with regular updates.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to asynchronously connect to a Minecraft Java Edition server, retrieve its status, and print key information like version, player count, and latency. It uses `asyncio.run` for a runnable async entry point.

from mcstatus import JavaServer
import asyncio

async def get_server_status(host, port):
    try:
        # 'lookup' can infer the port if not provided for default Minecraft Java port
        server = await JavaServer.async_lookup(f"{host}:{port}")
        status = await server.async_status() # Use async_status for async context
        print(f"Minecraft Java Server at {host}:{port}")
        print(f"  Version: {status.version.name}")
        print(f"  Players: {status.players.online}/{status.players.max}")
        print(f"  Latency: {status.latency:.2f}ms")
        print(f"  MOTD: {status.description}")

    except Exception as e:
        print(f"Could not get status for {host}:{port}: {e}")

if __name__ == '__main__':
    # Replace with your server details
    target_host = "play.hypixel.net" # Example public server
    target_port = 25565
    asyncio.run(get_server_status(target_host, target_port))

view raw JSON →