Skip to main content

Module host

Module host 

Source
Expand description

The game’s side of shuyi mcp: shuyi mcp-host, run in the game’s tool program, answers the server’s Requests, one JSON line each on stdin, with a Reply line each on stdout, after the mark REPLY. It answers the operations that run the game with the game’s tools, and keeps the session’s game (Host).

InProcess is the same host without a process between, for games’ and the engine’s tests of the server.

Structs§

Host
The game’s side of the server: the game’s tools on its project, and the session’s game, if one is running.
InProcess
The host in this process: a Launch whose game is tools, with no process between, for tests of the server.
Reply
What the host answers.
Request
What the server asks the host: the tool of op, with its input.

Constants§

REPLY
What starts each reply line, so the server tells replies from what the game prints itself.

Functions§

answered
input read as I (nothing given reads as {}), and f’s answer to it; a codes::WRONG_ARGUMENTS answer of op if it doesn’t read.
failed
The answer of op that failed with code because of error, as JSON.
no_session
The answer of session tool op with no game running.
one_off
The answer of the operation op (one of Op::ALL) to input, as JSON: with the game’s tools game on project where it runs the game; new makes its folder from cwd, and import reads from the project’s root, or cwd outside one. Without the game’s tools or a project, an operation that needs them says so, as the CLI does.
serve
shuyi mcp-host: answers each request line of input on output with game’s tools on project, until input ends. Returns the exit code: 0, or 1 if a line couldn’t be read or written.
to_json
answer as JSON.