Skip to main content

mcbe-ws-sdk

Languages Python License

Generic WebSocket gateway SDK for Minecraft Bedrock Edition.

It owns the WS transport, packet protocol, and byte-safe command chunking (461-byte empirically measured default ceiling; deployments may lower it). Your host injects behaviour through typed ConnectionHook and ResponseSink interfaces, with optional typed session/approval control callbacks, and drives the stack with McbeServerFacade.

There is no message broker and no LLM worker inside the SDK — those stay in the host application.

Minecraft client  ←── /wsserver IP:port ──→  Your Python host (this SDK)

In-game addon capability bridge

Use the companion TypeScript addon when your host needs structured information or Script API actions from inside the world—not just player chat. A capability call follows one correlated, chunk-safe round trip:

Python host
  → AddonBridgeService request(capability, payload)
  → scriptevent mcbews:bridge_req
  → addon capability handler in the Bedrock world
  → MCBEWS_BRIDGE simulated-player chat chunks
  → WebSocket PlayerMessage stream
  → AddonBridgeSession reassembles by request_id and resolves the request
  → your host renders the result (tellraw or mcbews:text_resp)
  • Bidirectional by design. Python calls addon capabilities; the addon can also send UI-originated player messages back through the same bridge. Python can send framed text responses to the addon UI with mcbews:text_resp.
  • Safe on the actual transport. Requests and responses carry a request_id; large payloads are chunked and reassembled rather than relying on a direct addon-to-WebSocket connection.
  • Clear ownership. The addon owns its capability registry; the Python host owns authentication and authorization. The bridge itself is not a security boundary.

Start with the runnable addon-server example and the bridge protocol. To load the companion addon, the target world must enable Experiments → Beta APIs; otherwise its scripts do not load and capability calls time out.

Install

pip install mcbe-ws-sdk

Editable install for development:

pip install -e ".[dev,docs]"

Requires Python 3.11+.

30-second taste

import asyncio
from mcbe_ws_sdk import McbeServerFacade, NoOpHook


class MyHook(NoOpHook):
    async def on_connected(self, state):
        print("connected:", state.id)

    async def on_player_message(self, state, event, parsed=None):
        print(f"{event.sender}: {event.message}")


async def main() -> None:
    facade = McbeServerFacade(hook=MyHook())
    print(f"ws://{facade.settings.websocket.host}:{facade.settings.websocket.port}")
    await facade.run_lifetime()


if __name__ == "__main__":
    asyncio.run(main())

Then in Minecraft: /wsserver <this-machine-ip>:8080

For a reply-with-tellraw host, run the ready-made example:

python examples/basic-server/server.py

Documentation

Full beginner tutorial, architecture, protocol, and API reference live on the docs site (English + 中文):

Online https://rice-awa.github.io/mcbe-ws-sdk/
Local pip install -e ".[docs]" && mkdocs servehttp://127.0.0.1:8000
Page Content
Getting Started Install, 5-minute walkthrough, minimal echo bot, FAQ
Architecture Layer stack and dependency inversion
Protocol mcbews v1 bridge wire format
API Reference Generated from source

Examples

Path What it shows
examples/basic-server/ Echo chat with tellraw (start here)
examples/addon-server/ Capability calls via the companion addon
examples/addon-capability-call/ In-memory bridge round-trip (no game)

Companion TypeScript addon: addon/. Worlds that load it must enable Experiments → Beta APIs (see addon README).

Development

pip install -e ".[dev,docs]"
ruff check --no-cache src tests examples
mypy --no-incremental src
pytest -p no:cacheprovider -q
python tools/format.py          # ruff format+fix (Python); prettier (Addon if Node)
python tools/format.py --check  # CI-style check

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcbe_ws_sdk-0.2.1.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcbe_ws_sdk-0.2.1-py3-none-any.whl (61.7 kB view details)

Uploaded Python 3

File details

Details for the file mcbe_ws_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: mcbe_ws_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mcbe_ws_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7bb9b283ff9562bd8a35559b0d7b2fa393344f17a182134bc0729ff969521cb5
MD5 1075783d738059d86db3928742c1f610
BLAKE2b-256 c5850c39bf87c5b08100b740567d737a21a5608fbfcb9ecf33c54213275b8e3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcbe_ws_sdk-0.2.1.tar.gz:

Publisher: release.yml on rice-awa/mcbe-ws-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcbe_ws_sdk-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: mcbe_ws_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 61.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mcbe_ws_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68c07654a16fa6c32176b98ea7f1e1179ae57a8fcfa6e6ec204d53fc44f3d34e
MD5 31b604248b698ddc819870441edf4238
BLAKE2b-256 3076acbff4be22d48d9438032c679fbaf68903c1d3e24504d0ae6fedc6391f85

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcbe_ws_sdk-0.2.1-py3-none-any.whl:

Publisher: release.yml on rice-awa/mcbe-ws-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page