[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/management-protocol](https://jsprismarine.dev/api/@jsprismarine/management-protocol/index.md) / ManagementServer

# ManagementServer

## Classes

- [ManagementServer](https://jsprismarine.dev/api/@jsprismarine/management-protocol/ManagementServer/classes/ManagementServer.md)

## Interfaces

### ManagementLogger

Defined in: [ManagementServer.ts:36](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L36)

What a listener logs.

#### Methods

##### info()

> **info**(`message`): `void`

Defined in: [ManagementServer.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L37)

###### Parameters

###### message

`string`

###### Returns

`void`

##### warn()

> **warn**(`message`): `void`

Defined in: [ManagementServer.ts:38](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L38)

###### Parameters

###### message

`string`

###### Returns

`void`

***

### ManagementServerOptions

Defined in: [ManagementServer.ts:42](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L42)

How to start a listener.

#### Properties

##### allowedOrigins

> `readonly` **allowedOrigins**: readonly `string`[]

Defined in: [ManagementServer.ts:54](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L54)

The `Origin` values a browser may connect from, as `management-server-allowed-origins`. Java
checks the origin of a client that sends the secret as a subprotocol, which is what a browser
has to do, and not of one that sends a bearer token.

##### handlers

> `readonly` **handlers**: [`Handlers`](#handlers-1)

Defined in: [ManagementServer.ts:62](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L62)

##### host

> `readonly` **host**: `string`

Defined in: [ManagementServer.ts:44](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L44)

The address to listen on, as `management-server-host`.

##### logger?

> `readonly` `optional` **logger?**: [`ManagementLogger`](#managementlogger)

Defined in: [ManagementServer.ts:65](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L65)

##### notifications

> `readonly` **notifications**: readonly (keyof [`Notifications`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#notifications))[]

Defined in: [ManagementServer.ts:64](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L64)

The notifications the server sends, which `rpc.discover` lists.

##### port

> `readonly` **port**: `number`

Defined in: [ManagementServer.ts:46](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L46)

The port, as `management-server-port`; 0 picks a free one.

##### secret

> `readonly` **secret**: `string`

Defined in: [ManagementServer.ts:48](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L48)

The secret every client must send.

##### started

> `readonly` **started**: () => `boolean`

Defined in: [ManagementServer.ts:59](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L59)

Whether the server has started. Before it has, a client may only call `rpc.discover`, and
the only notification sent is `server/status`, as on Java.

###### Returns

`boolean`

##### tls?

> `readonly` `optional` **tls?**: `object`

Defined in: [ManagementServer.ts:61](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L61)

A PKCS12 keystore and its password, to serve `wss://`; omitted, the listener serves `ws://`.

###### passphrase?

> `readonly` `optional` **passphrase?**: `string`

###### pfx

> `readonly` **pfx**: `Buffer`

## Type Aliases

### Handler

> **Handler**\<`K`\> = (`params`) => [`Methods`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#methods)\[`K`\]\[`"result"`\] \| `Promise`\<[`Methods`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#methods)\[`K`\]\[`"result"`\]\>

Defined in: [ManagementServer.ts:22](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L22)

What one method's handler takes and returns, as Mojang's document types it.

#### Type Parameters

##### K

`K` *extends* keyof [`Methods`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#methods)

#### Parameters

##### params

[`Methods`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#methods)\[`K`\]\[`"params"`\]

#### Returns

[`Methods`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#methods)\[`K`\]\[`"result"`\] \| `Promise`\<[`Methods`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#methods)\[`K`\]\[`"result"`\]\>

***

### Handlers

> **Handlers** = `{ readonly [K in keyof Methods]?: Handler<K> }`

Defined in: [ManagementServer.ts:27](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L27)

The methods a server implements, by name. A method left out is not found, and not discovered.

## Variables

### SUBPROTOCOL

> `const` **SUBPROTOCOL**: `"minecraft-v1"` = `'minecraft-v1'`

Defined in: [ManagementServer.ts:33](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L33)

The subprotocol a browser offers, with the secret after it, since it cannot set a header.

## Functions

### discoverDocument()

> **discoverDocument**(`handlers`, `notifications`): `object`

Defined in: [ManagementServer.ts:83](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L83)

The `rpc.discover` result: Mojang's document cut down to the methods this server handles and the
notifications it sends, with every component, so a client sees what it can use here.

#### Parameters

##### handlers

[`Handlers`](#handlers-1)

##### notifications

readonly (keyof [`Notifications`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#notifications))[]

#### Returns

`object`

##### components

> **components**: `object`

###### components.schemas

> **schemas**: `object`

###### components.schemas.difficulty

> **difficulty**: `object`

###### components.schemas.difficulty.enum

> **enum**: `string`[]

###### components.schemas.difficulty.type

> **type**: `string` = `"string"`

###### components.schemas.game\_type

> **game\_type**: `object`

###### components.schemas.game\_type.enum

> **enum**: `string`[]

###### components.schemas.game\_type.type

> **type**: `string` = `"string"`

###### components.schemas.incoming\_ip\_ban

> **incoming\_ip\_ban**: `object`

###### components.schemas.incoming\_ip\_ban.properties

> **properties**: `object`

###### components.schemas.incoming\_ip\_ban.properties.expires

> **expires**: `object`

###### components.schemas.incoming\_ip\_ban.properties.expires.type

> **type**: `string` = `"string"`

###### components.schemas.incoming\_ip\_ban.properties.ip

> **ip**: `object`

###### components.schemas.incoming\_ip\_ban.properties.ip.type

> **type**: `string` = `"string"`

###### components.schemas.incoming\_ip\_ban.properties.player

> **player**: `object`

###### components.schemas.incoming\_ip\_ban.properties.player.$ref

> **$ref**: `string` = `"#/components/schemas/player"`

###### components.schemas.incoming\_ip\_ban.properties.reason

> **reason**: `object`

###### components.schemas.incoming\_ip\_ban.properties.reason.type

> **type**: `string` = `"string"`

###### components.schemas.incoming\_ip\_ban.properties.source

> **source**: `object`

###### components.schemas.incoming\_ip\_ban.properties.source.type

> **type**: `string` = `"string"`

###### components.schemas.incoming\_ip\_ban.type

> **type**: `string` = `"object"`

###### components.schemas.ip\_ban

> **ip\_ban**: `object`

###### components.schemas.ip\_ban.properties

> **properties**: `object`

###### components.schemas.ip\_ban.properties.expires

> **expires**: `object`

###### components.schemas.ip\_ban.properties.expires.type

> **type**: `string` = `"string"`

###### components.schemas.ip\_ban.properties.ip

> **ip**: `object`

###### components.schemas.ip\_ban.properties.ip.type

> **type**: `string` = `"string"`

###### components.schemas.ip\_ban.properties.reason

> **reason**: `object`

###### components.schemas.ip\_ban.properties.reason.type

> **type**: `string` = `"string"`

###### components.schemas.ip\_ban.properties.source

> **source**: `object`

###### components.schemas.ip\_ban.properties.source.type

> **type**: `string` = `"string"`

###### components.schemas.ip\_ban.type

> **type**: `string` = `"object"`

###### components.schemas.kick\_player

> **kick\_player**: `object`

###### components.schemas.kick\_player.properties

> **properties**: `object`

###### components.schemas.kick\_player.properties.message

> **message**: `object`

###### components.schemas.kick\_player.properties.message.$ref

> **$ref**: `string` = `"#/components/schemas/message"`

###### components.schemas.kick\_player.properties.player

> **player**: `object`

###### components.schemas.kick\_player.properties.player.$ref

> **$ref**: `string` = `"#/components/schemas/player"`

###### components.schemas.kick\_player.type

> **type**: `string` = `"object"`

###### components.schemas.message

> **message**: `object`

###### components.schemas.message.properties

> **properties**: `object`

###### components.schemas.message.properties.literal

> **literal**: `object`

###### components.schemas.message.properties.literal.type

> **type**: `string` = `"string"`

###### components.schemas.message.properties.translatable

> **translatable**: `object`

###### components.schemas.message.properties.translatable.type

> **type**: `string` = `"string"`

###### components.schemas.message.properties.translatableParams

> **translatableParams**: `object`

###### components.schemas.message.properties.translatableParams.items

> **items**: `object`

###### components.schemas.message.properties.translatableParams.items.type

> **type**: `string` = `"string"`

###### components.schemas.message.properties.translatableParams.type

> **type**: `string` = `"array"`

###### components.schemas.message.type

> **type**: `string` = `"object"`

###### components.schemas.operator

> **operator**: `object`

###### components.schemas.operator.properties

> **properties**: `object`

###### components.schemas.operator.properties.bypassesPlayerLimit

> **bypassesPlayerLimit**: `object`

###### components.schemas.operator.properties.bypassesPlayerLimit.type

> **type**: `string` = `"boolean"`

###### components.schemas.operator.properties.permissionLevel

> **permissionLevel**: `object`

###### components.schemas.operator.properties.permissionLevel.type

> **type**: `string` = `"integer"`

###### components.schemas.operator.properties.player

> **player**: `object`

###### components.schemas.operator.properties.player.$ref

> **$ref**: `string` = `"#/components/schemas/player"`

###### components.schemas.operator.type

> **type**: `string` = `"object"`

###### components.schemas.player

> **player**: `object`

###### components.schemas.player.properties

> **properties**: `object`

###### components.schemas.player.properties.id

> **id**: `object`

###### components.schemas.player.properties.id.type

> **type**: `string` = `"string"`

###### components.schemas.player.properties.name

> **name**: `object`

###### components.schemas.player.properties.name.type

> **type**: `string` = `"string"`

###### components.schemas.player.type

> **type**: `string` = `"object"`

###### components.schemas.server\_state

> **server\_state**: `object`

###### components.schemas.server\_state.properties

> **properties**: `object`

###### components.schemas.server\_state.properties.players

> **players**: `object`

###### components.schemas.server\_state.properties.players.items

> **items**: `object`

###### components.schemas.server\_state.properties.players.items.$ref

> **$ref**: `string` = `"#/components/schemas/player"`

###### components.schemas.server\_state.properties.players.type

> **type**: `string` = `"array"`

###### components.schemas.server\_state.properties.started

> **started**: `object`

###### components.schemas.server\_state.properties.started.type

> **type**: `string` = `"boolean"`

###### components.schemas.server\_state.properties.version

> **version**: `object`

###### components.schemas.server\_state.properties.version.$ref

> **$ref**: `string` = `"#/components/schemas/version"`

###### components.schemas.server\_state.type

> **type**: `string` = `"object"`

###### components.schemas.system\_message

> **system\_message**: `object`

###### components.schemas.system\_message.properties

> **properties**: `object`

###### components.schemas.system\_message.properties.message

> **message**: `object`

###### components.schemas.system\_message.properties.message.$ref

> **$ref**: `string` = `"#/components/schemas/message"`

###### components.schemas.system\_message.properties.overlay

> **overlay**: `object`

###### components.schemas.system\_message.properties.overlay.type

> **type**: `string` = `"boolean"`

###### components.schemas.system\_message.properties.receivingPlayers

> **receivingPlayers**: `object`

###### components.schemas.system\_message.properties.receivingPlayers.items

> **items**: `object`

###### components.schemas.system\_message.properties.receivingPlayers.items.$ref

> **$ref**: `string` = `"#/components/schemas/player"`

###### components.schemas.system\_message.properties.receivingPlayers.type

> **type**: `string` = `"array"`

###### components.schemas.system\_message.type

> **type**: `string` = `"object"`

###### components.schemas.typed\_game\_rule

> **typed\_game\_rule**: `object`

###### components.schemas.typed\_game\_rule.properties

> **properties**: `object`

###### components.schemas.typed\_game\_rule.properties.key

> **key**: `object`

###### components.schemas.typed\_game\_rule.properties.key.type

> **type**: `string` = `"string"`

###### components.schemas.typed\_game\_rule.properties.type

> **type**: `object`

###### components.schemas.typed\_game\_rule.properties.type.enum

> **enum**: `string`[]

###### components.schemas.typed\_game\_rule.properties.type.type

> **type**: `string` = `"string"`

###### components.schemas.typed\_game\_rule.properties.value

> **value**: `object`

###### components.schemas.typed\_game\_rule.properties.value.type

> **type**: `string`[]

###### components.schemas.typed\_game\_rule.type

> **type**: `string` = `"object"`

###### components.schemas.untyped\_game\_rule

> **untyped\_game\_rule**: `object`

###### components.schemas.untyped\_game\_rule.properties

> **properties**: `object`

###### components.schemas.untyped\_game\_rule.properties.key

> **key**: `object`

###### components.schemas.untyped\_game\_rule.properties.key.type

> **type**: `string` = `"string"`

###### components.schemas.untyped\_game\_rule.properties.value

> **value**: `object`

###### components.schemas.untyped\_game\_rule.properties.value.type

> **type**: `string`[]

###### components.schemas.untyped\_game\_rule.type

> **type**: `string` = `"object"`

###### components.schemas.user\_ban

> **user\_ban**: `object`

###### components.schemas.user\_ban.properties

> **properties**: `object`

###### components.schemas.user\_ban.properties.expires

> **expires**: `object`

###### components.schemas.user\_ban.properties.expires.type

> **type**: `string` = `"string"`

###### components.schemas.user\_ban.properties.player

> **player**: `object`

###### components.schemas.user\_ban.properties.player.$ref

> **$ref**: `string` = `"#/components/schemas/player"`

###### components.schemas.user\_ban.properties.reason

> **reason**: `object`

###### components.schemas.user\_ban.properties.reason.type

> **type**: `string` = `"string"`

###### components.schemas.user\_ban.properties.source

> **source**: `object`

###### components.schemas.user\_ban.properties.source.type

> **type**: `string` = `"string"`

###### components.schemas.user\_ban.type

> **type**: `string` = `"object"`

###### components.schemas.version

> **version**: `object`

###### components.schemas.version.properties

> **properties**: `object`

###### components.schemas.version.properties.name

> **name**: `object`

###### components.schemas.version.properties.name.type

> **type**: `string` = `"string"`

###### components.schemas.version.properties.protocol

> **protocol**: `object`

###### components.schemas.version.properties.protocol.type

> **type**: `string` = `"integer"`

###### components.schemas.version.type

> **type**: `string` = `"object"`

##### info

> **info**: `object`

###### info.title

> **title**: `string` = `"Minecraft Server JSON-RPC"`

###### info.version

> **version**: `string` = `"3.1.0"`

##### methods

> **methods**: (\{ `description`: `string`; `name`: `string`; `params`: `object`[]; `result`: \{ `name`: `string`; `schema`: \{ `$ref?`: `undefined`; `items`: \{ `$ref`: `string`; \}; `type`: `string`; \}; \}; \} \| \{ `description`: `string`; `name`: `string`; `params`: `object`[]; `result`: \{ `name`: `string`; `schema`: \{ `$ref?`: `undefined`; `items`: \{ `$ref`: `string`; \}; `type`: `string`; \}; \}; \} \| \{ `description`: `string`; `name`: `string`; `params`: `object`[]; `result`: \{ `name`: `string`; `schema`: \{ `$ref?`: `undefined`; `items?`: `undefined`; `type`: `string`; \}; \}; \} \| \{ `description`: `string`; `name`: `string`; `params`: `object`[]; `result`: \{ `name`: `string`; `schema`: \{ `$ref?`: `undefined`; `items?`: `undefined`; `type`: `string`; \}; \}; \} \| \{ `description`: `string`; `name`: `string`; `params`: `object`[]; `result`: \{ `name`: `string`; `schema`: \{ `$ref`: `string`; `items?`: `undefined`; `type?`: `undefined`; \}; \}; \} \| \{ `description`: `string`; `name`: `string`; `params`: `object`[]; `result?`: `undefined`; \} \| \{ `description`: `string`; `name`: `string`; `params`: `object`[]; `result?`: `undefined`; \})[]

##### openrpc

> **openrpc**: `string` = `"1.3.2"`

***

### refusalOf()

> **refusalOf**(`headers`, `secret`, `allowedOrigins`): `Refusal` \| `undefined`

Defined in: [ManagementServer.ts:133](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L133)

Checks a client's handshake as Java does: a bearer token, with no origin check, or else the
secret after `minecraft-v1,` in `Sec-WebSocket-Protocol`, from an allowed origin.

#### Parameters

##### headers

`IncomingHttpHeaders`

##### secret

`string`

##### allowedOrigins

readonly `string`[]

#### Returns

`Refusal` \| `undefined`

Why the client is refused, or undefined to let it in.

***

### rpcTable()

> **rpcTable**(`handlers`, `notifications`, `started`, `onInternalError?`): [`RpcTable`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/jsonRpc/index.md#rpctable)

Defined in: [ManagementServer.ts:100](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/management-protocol/src/ManagementServer.ts#L100)

The dispatcher table for a set of handlers, with `rpc.discover`.

#### Parameters

##### handlers

[`Handlers`](#handlers-1)

The methods the server implements.

##### notifications

readonly (keyof [`Notifications`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/mojangApi/index.md#notifications))[]

The notifications it sends.

##### started

() => `boolean`

##### onInternalError?

(`method`, `error`) => `void`

#### Returns

[`RpcTable`](https://jsprismarine.dev/api/@jsprismarine/management-protocol/jsonRpc/index.md#rpctable)

The table [answerFrame](https://jsprismarine.dev/api/@jsprismarine/management-protocol/jsonRpc/index.md#answerframe) reads.
