Automate the client
Use this page when you want to drive the native client from a script or write a bot against its Rust API. Choose a display mode first, then use the control socket, the MCP launcher or the client messages for the task.
Choose a display mode
Section titled “Choose a display mode”For a bot that needs no images, pass --headless to the native client and set MCRS_SERVER to the server’s host:port. This mode uses the same ClientCorePlugins as the rendered client, without a renderer or window, so it cannot capture images.
For GUI input or screenshots without an OS window, set MCRS_OFFSCREEN to an image size such as 1280x720. This keeps the renderer and a primary Window entity for GUI size and input.1 The off-screen loop schedules frames at 50 ms, nominally 20 FPS. This is a scheduling interval, not a measured frame rate, and it does not use the window’s frame-limit option.2
Cameras targeting a window draw the GUI. A camera targeting an image also draws it when it has the extracted GuiCamera component. The native off-screen entry point marks the player camera with that component, so captures include both the world and GUI.
Enable the control socket
Section titled “Enable the control socket”On Unix, build the native client with the opt-in control feature and pass --control <socket-path>. Without that feature, the argument makes the client exit with an error. The socket accepts state queries and look, movement, hotbar slot, chat, command and attack requests in headless and rendered modes.
Key chords, pointer movement, clicks, scrolling and typing need the primary Window entity, so they work off screen but not headless. Scripted keys count rendered frames; hold and attack count game ticks. The launcher README lists the requests and replies.
Use the MCP launcher
Section titled “Use the MCP launcher”The MCP launcher builds, starts and stops local servers and clients, waits for log output and drives client input. Its build tool enables control. Use client_start to start a client: it defaults to off-screen rendering at 1280x720; offscreen chooses another size, window: true opens an OS window and headless: true omits the renderer. The screenshot tool captures a window or off-screen image. The launcher’s session variable is in the environment reference.
For development scenes, a native singleplayer build with the opt-in dev feature also reads MCRS_MENU to open a sample container after joining. Set MCRS_PLAY=1 to start the world given as the argument when it belongs to the game directory’s saves list. Client variables lists the settings.
Read state and request respawn in a bot
Section titled “Read state and request respawn in a bot”A bot can use the same state without a GUI. mcrs_minecraft_client_world keeps Vitals and FoodLevel on the local Player, emits PlayerKilled with the death message and RespawnScreen, and accepts the RequestRespawn message. Each request sends ServerboundClientCommand with ClientCommandAction::PerformRespawn when a connection exists. mcrs_minecraft_client_entity also emits EntityDamaged for damage to the local player or a tracked entity.3
Build and test describes the contributor checks.
Footnotes
Section titled “Footnotes”Sources and verification
Verified: 26.4-snapshot-7, 1cf84286c, 2026-11-30
- crates/mcrs_minecraft_client/Cargo.toml
- crates/mcrs_minecraft_client/src/native.rs
- crates/mcrs_minecraft_client/src/lib.rs
- crates/mcrs_minecraft_client/src/headless.rs
- crates/mcrs_minecraft_client/src/client_core_plugins.rs
- crates/mcrs_minecraft_client/src/offscreen.rs
- crates/mcrs_minecraft_client/src/window_options.rs
- crates/mcrs_minecraft_client/src/screenshot.rs
- crates/mcrs_minecraft_client/src/dev_join_menu.rs
- crates/mcrs_minecraft_client/src/dev_play_world.rs
- crates/mcrs_minecraft_client/src/dev.rs
- crates/mcrs_minecraft_client/src/dev_knobs.rs
- crates/mcrs_minecraft_client_control/src/control_plugin.rs
- crates/mcrs_minecraft_client_control/src/control.rs
- crates/mcrs_minecraft_client_control/src/request.rs
- crates/mcrs_minecraft_client_control/src/input_script.rs
- crates/mcrs_minecraft_client_world/src/health_packets.rs
- crates/mcrs_minecraft_client_world/src/player_killed.rs
- crates/mcrs_minecraft_client_world/src/request_respawn.rs
- crates/mcrs_minecraft_client_world/src/respawn_screen.rs
- crates/mcrs_minecraft_client_entity/src/entity_damaged.rs
- crates/mcrs_minecraft_client_entity/src/receive.rs
- crates/mcrs_minecraft_gui_render/src/gui_camera.rs
- crates/mcrs_minecraft_gui_render/src/gui_views.rs
- tools/mcrs_minecraft_mcp/README.md
- tools/mcrs_minecraft_mcp/src/launch.rs
- tools/mcrs_minecraft_mcp/src/tools.rs
- PR #1085
- PR #1184
- PR #1193
Related open issues: