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 serve → http://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

Metadata

Release files for mcbe-ws-sdk 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcbe-ws-sdk 0.2.1
File Size Uploaded Provenance
mcbe_ws_sdk-0.2.1.tar.gz 3.8 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcbe-ws-sdk 0.2.1
File Interpreter ABI Platform
mcbe_ws_sdk-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 3.8 MB

Release files / mcbe_ws_sdk-0.2.1.tar.gz

Download URL mcbe_ws_sdk-0.2.1.tar.gz
Size 3.8 MB
Tags Source
SHA-256 checksum
How to use checksums
7bb9b283ff9562bd8a35559b0d7b2fa393344f17a182134bc0729ff969521cb5
BLAKE2b-256 checksum
How to use checksums
c5850c39bf87c5b08100b740567d737a21a5608fbfcb9ecf33c54213275b8e3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / mcbe_ws_sdk-0.2.1-py3-none-any.whl

Download URL mcbe_ws_sdk-0.2.1-py3-none-any.whl
Size 61.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68c07654a16fa6c32176b98ea7f1e1179ae57a8fcfa6e6ec204d53fc44f3d34e
BLAKE2b-256 checksum
How to use checksums
3076acbff4be22d48d9438032c679fbaf68903c1d3e24504d0ae6fedc6391f85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Security for mcbe-ws-sdk 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mcbe_ws_sdk-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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