# Server Management Protocol

Started 2026-11-27. The first version is built on `feat/server-management-protocol`:
[Status](#status) lists what it covers and the issues that track the rest.

## Goal

Let the tools written for Java Edition's
[Server Management Protocol](https://minecraft.wiki/w/Minecraft_Server_Management_Protocol)
(MSMP) manage a JSPrismarine server without changes. A panel, a Discord bot or a script that
lists players, edits the allow list or bans a player on a vanilla Java server does the same on
ours, over the same WebSocket, with the same secret and the same JSON.

## What we know

Facts gathered on 2026-11-27.

- MSMP is JSON-RPC 2.0 over a WebSocket. Java added it in 1.21.9, and the pinned Java 26.3 jar
  speaks API version 3.1.0.
- The jar's data generator writes the whole method catalog as an OpenRPC document,
  `reports/json-rpc-api-schema.json`: 68 methods, 21 notifications and 14 component schemas.
  That document is the source of truth. The wiki page differs from it in places: it names the
  `allow_flight/set` parameter `allowed`, and the jar names it `allow`.
- The method and wire behavior below comes from reading the jar's
  `net.minecraft.server.jsonrpc` classes with `javap`.
- No npm package implements the server side. Every MSMP package on npm is a client:
  `mc-server-management` (Aternos, MIT, about 800 downloads a week, maintained), `@libmsmp/core`,
  `msmpjs`, `minecraft-management-client` and `minecraft-smp`. Of the generic JSON-RPC
  libraries, `json-rpc-2.0` is the only fit (MIT, no dependencies), and `rpc-websockets` is
  LGPL-3.0. The JSON-RPC part MSMP needs is about a hundred lines, and the method catalog, which
  is the real work, comes from the jar. We use [`ws`](https://github.com/websockets/ws) for the
  WebSocket and write the rest.

## Design

### The package

`@jsprismarine/management-protocol` holds what does not depend on the server:

- `mojangApi.json` and `mojangApi.ts`, which
  `pnpm --filter @jsprismarine/bedrock-data run dump:java-management` writes from the pinned
  release's report: the document as Mojang wrote it, a TypeScript type per component, and a
  `Methods` and a `Notifications` map typed from it. A Java bump reruns the dump, and a renamed
  parameter fails the typecheck of whoever handles it.
- `schemaCheck.ts`, which checks a value against one of the document's schemas. The dispatcher
  uses it on parameters, and the parity family on results.
- `jsonRpc.ts`, the JSON-RPC 2.0 dispatcher, with Java's rules: the `jsonrpc` member is not
  read, a method takes one parameter by position or by name, a method name without a namespace
  is `minecraft:`, a batch is always answered with an array, and only `rpc.discover` is answered
  before the server has started. The error codes and `data` strings are Java's.
- `ManagementServer.ts`, the WebSocket listener on `/`: a bearer token with no Origin check, or
  the secret after `minecraft-v1,` in `Sec-WebSocket-Protocol` from an allowed Origin, refused
  with Java's 401 JSON body; TLS from a PKCS12 keystore; `rpc.discover`; and notifications to
  every connected client.

The server hands the listener a `Handlers` object, a function per method name. `rpc.discover`
lists the methods it was given and the notifications it says it sends, with Mojang's text and
schemas, so a client sees what this server can do rather than everything Java can.

### The server

`packages/prismarine/src/management/` adds the `prismarine:management` kernel module. It reads
the `management-server-*` settings, which carry the names and defaults of Java's
`server.properties` keys, generates the secret on first start as Java does, and maps each method
onto the manager that owns the data: the allow list, the ban manager, the permission manager,
the session manager, the config and the entry world's game rules.

Players are identified the way MSMP identifies them, by name and UUID. A Bedrock player's UUID is
the one their login carries.

### Parity

The `protocol.management` family has one row per method and per notification of Mojang's document.
A row passes when the server handles the method, its parameters are the document's, and what it
returns, through the real module on the real config, allow list, ban list, operators and game
rules over a WebSocket, matches the document's result schema. A notification's row passes when
the run sees it sent with params that match. A method the server does not answer, or a
notification it does not send, is recorded in `goldens/behavior-gaps.json` as `deferred`, with
the issue that tracks it; any other difference is a defect.

## Status

The first version, built 2026-11-27, covers the transport, discovery, the players, the allow
list, bans, online operators, the server methods, the game rules and the settings the config
already has. The parity dashboard's `protocol.management` rows are the current count. The gaps
each have an issue:

- [#3817](https://github.com/JSPrismarine/JSPrismarine/issues/3817): IP bans. The server keeps no
  IP ban list.
- [#3818](https://github.com/JSPrismarine/JSPrismarine/issues/3818): operators who are offline,
  operator levels, `bypassesPlayerLimit`, `operators/set` and `operators/clear`.
- [#3819](https://github.com/JSPrismarine/JSPrismarine/issues/3819): server settings with no
  setting behind them.
- [#3820](https://github.com/JSPrismarine/JSPrismarine/issues/3820): notifications for changes
  made outside the protocol, `server/activity` and the world upgrade notifications.
- [#3821](https://github.com/JSPrismarine/JSPrismarine/issues/3821): a ban's source and expiry, and
  UUIDs for offline players in the ban and allow lists.

## Open questions

- Whether a Bedrock-only server should also accept management clients when `java-enabled` is
  off. The first version does: MSMP manages the server, not the Java listener.
