Package-level declarations

Types

Link copied to clipboard
Open chat-capture windows for run_command target=client.
Link copied to clipboard
object ChatTrust

Whether a captured chat line is something run_command target=client may hand back by default.

Link copied to clipboard
Runs a command AS THE PLAYER, for the run_command tool's target=client — i.e.
Link copied to clipboard

Runs a Minecraft command on the server thread and captures its chat feedback, for the run_command MCP tool. Vanilla mechanism throughout: a custom CommandSource collects the feedback the command would normally print, attached to a server-level (OP) CommandSourceStack, executed via Commands#performPrefixedCommand.

Link copied to clipboard
internal object McpJson

Everything this endpoint puts on the wire: JSON-RPC envelopes, MCP tool results and the tools/list prose. All pure functions of their arguments, which is why they are here rather than in McpServer — that file keeps what needs a live server behind it.

Link copied to clipboard
class McpServer

The single MCP endpoint the mod exposes: Streamable HTTP, bound to loopback, Bearer-token gated. Three tools: execute_code (runs Kotlin inside the running game via ReplBridge), run_command (runs a Minecraft command) and take_screenshot (the client's framebuffer, as an image).

Link copied to clipboard
internal object ScreenshotRunner

Captures the game's framebuffer for the take_screenshot tool.

Functions

Link copied to clipboard
private fun JsonObject.boolOr(key: String, missing: Boolean): Boolean?

stringOr's contract for booleans: "false" is a string, not a false, and folding the two would turn a typo into a policy.

Link copied to clipboard
private fun idKey(id: JsonElement?): String

Stable string form of a JSON-RPC id for the in-flight key: 2 ->"2", "a" ->"\"a\"". The cancellation's requestId is stringified the same way, so the two match.

Link copied to clipboard
private fun notReady(target: String): String
Link copied to clipboard
private fun JsonObject.objOr(key: String): JsonObject

A nested object, or an empty one: a missing member and a non-object one both mean "no fields to read".

Link copied to clipboard
private fun JsonObject.stringOr(key: String, missing: String?): String?

isString, not isJsonPrimitive: gson's asString stringifies a number or boolean and cannot be told not to, so {"code": 123} would compile and run 123. Absent (or JSON null) reads as missing; a null return means present with the wrong type, which the caller refuses rather than folding into missing.