# Devtools and message logs

> Watch every message, Command and Model change of a Minekube game live in the Effect UI devtools, and let a coding agent read the same message logs through MCP.

A game that behaves strangely is hard to debug from the server log. A Minekube game records every message it handles, with the Model after it and the Commands it issued. The devtools show that message log live, and your coding agent reads the same log through MCP. You both look at the same facts.

## What a message log holds

Each running bundle writes its log as Effect UI `MessageLog` entries, one per line of its [recording](https://minekube.com/games/testing/recordings). The devtools read the same entries.

| Entry | Means |
| --- | --- |
| `SessionStarted` | A revision started. Each start is one session. |
| `Mounted`, `Unmounted` | A component instance started or stopped, with its props, its first Model and the Commands of `init`. |
| `Update` | A message arrived. The entry has the message, its source (such as a Subscription or a Command), the Model after it and the Commands it issued. |
| `CommandStarted`, `CommandEnded`, `CommandInterrupted` | A Command ran. Each entry points to the `Update` that issued it. |
| `SubscriptionStarted` | A Subscription began to deliver messages, such as a Paper event. |
| `Failed` | A component failed in `update`, a Command, a Subscription or `init`. |

Every entry has a sequence number and points to the entry that caused it. That is how the devtools answer why something happened.

## The devtools

`mk server` runs the [Effect UI devtools](https://github.com/Effect-TS/effect/tree/main/packages/ui/devtools) and streams every recording the server writes into them as a session. Open [http://127.0.0.1:4774](http://127.0.0.1:4774) while you play:

- **Timeline:** every entry of the newest session, live: messages, Commands, Subscriptions, failures.
- **Cause chains:** why an entry happened, back to the event that started it.
- **Model diffs:** what each message changed in the Model.

The devtools are read-only: they observe the game, they do not play it. The dev network (`mk server --network`) sends its proxy's and servers' recordings to the same devtools; whichever of the two starts first serves port 4774 and the other feeds it. Clients started with `mk client` stream theirs there too.

## MCP for coding agents

Agents read the same sessions through the `effect-ui` MCP server at `http://127.0.0.1:4774/mcp`. Here, yours explains why a friend's score went back to zero after a save:

> Scene: You ask your coding agent: "sam lost his points when i changed the score colour. bug?" It calls list_sessions, get_state and list_entries on the effect-ui MCP server while the devtools show each session, and answers: "Not a bug. Saving made a new revision, 5d2e7b18, and a new revision starts with a fresh Model from init, so every score began at 0. The world kept its blocks. Sam's 12 points (player 77bfcc1c…) are in the last state of the previous session, a41f09c2." You write "tell sam it's a feature", and it answers: "I can read the game through the devtools, but I can't send it anything, chat included. That one is yours."

Every project has the server configured in `.mcp.json`:

```json title=".mcp.json"
{
  "mcpServers": {
    "effect-ui": { "type": "http", "url": "http://127.0.0.1:4774/mcp" }
  }
}
```

| Tool | Answers |
| --- | --- |
| `list_sessions` | Which sessions exist. Start here. |
| `list_instances`, `list_entries` | The component instances in a session and their entries. |
| `get_chain` | Why something happened: the chain of causes behind an entry. |
| `get_state`, `diff_state` | The Model at any entry, and what changed between two. |
| `count_entries` | A summary of a session's entries. |

`get_entry` returns one entry in full, as its Wire frame. `list_entries` lists entries oldest first, filtered by instance, message tag or field, and with or without Command runs.

`dispatch` is off: an agent can inspect the game, not send it messages. To act in the game, an agent starts a [bot client](https://minekube.com/games/testing/bots), which plays like a person.

## The skill and `AGENTS.md`

Every project comes with `AGENTS.md`, the `minekube-games` skill and one strict check, so an agent knows the rules before it reads a session. See [Build with a coding agent](https://minekube.com/games/get-started/coding-agent#the-skill-and-agents-md).

## Runtime messages

The runtime also reports in the server log and, for operators, in chat with the prefix `[games]`. The [runtime messages reference](https://minekube.com/games/reference/runtime-messages) lists each message, what it means and what to do.

## Real clients

Clients started with `mk client` stream their recordings into the same devtools, one session per bundle. A test or an agent can then read the server's side and the player's side of the same moment. See [Test with bot clients](https://minekube.com/games/testing/bots).
