MCP Events Test Kitchen
by olaservo
README.md
---
title: MCP Events Test Kitchen
colorFrom: yellow
colorTo: pink
sdk: docker
app_port: 7860
pinned: false
license: mit
short_description: A cozy diner where an AI cook is woken by MCP Events
---
# MCP Events Test Kitchen
**Play it live: https://olaservo-mcp-events-test-kitchen.hf.space/**
- Hugging Face Space: https://huggingface.co/spaces/olaservo/mcp-events-test-kitchen
- A room's page: `https://olaservo-mcp-events-test-kitchen.hf.space/r/<room>`
- A room's MCP endpoint: `https://olaservo-mcp-events-test-kitchen.hf.space/r/<room>/mcp`
- Source: https://github.com/olaservo/mcp-events-test-kitchen
A tiny diner on Lantern Street, run by an AI cook. The cook connects over MCP and is woken by [MCP Events (SEP-3415)](https://modelcontextprotocol.io/seps/3415-events-extension) pushed from the server: a customer comes in, a timer rings, a goose wanders through. It cooks and serves with tools. You watch the kitchen in the browser, and you can ring the doorbell or make it rain.
The diner opens when a cook connects. It closes a little while after the cook leaves, and anyone still waiting goes home.
## Rooms
Every kitchen is a room with its own game, named in the URL. The page for a room is `/r/<room>` and its MCP endpoint is `/r/<room>/mcp`. Opening the bare site URL sends you to a new room with a name like `toasty-dumpling-42`.
Anyone with a room's link shares that kitchen: they see the same cook and score, and can press the same buttons. Two cooks can connect to one room and will both be woken by every event. Nothing stops them both cooking the same order. The page says there are too many cooks, draws up to three cooks squeezed in behind the counter, and the spare dishes end up on the washing-up pile. A room name is 3 to 40 lowercase letters, digits and hyphens, and a room is opened the first time its name is used, so you can also pick your own. The name is the only key, so pick a hard one if you want the room to yourself.
Rooms live in memory. A room nobody is watching or cooking in is swept after 4 hours, and a restart clears them all. `MAX_ROOMS` (default 200) caps how many are open at once.
## What the page shows
- **The kitchen.** Each pushed event flies to the cook as a paper slip with its event type on it, and the cook answers with tools.
- **On the wire.** One card per event type shows whether a push stream is open, how many occurrences were pushed or polled, and the cursor. Below it is a log of the MCP messages in both directions: `events/stream`, the `notifications/events/*` frames, `events/poll`, and each `tools/call` with its result. Click a line for the full JSON.
- **What's happening.** The same story in plain words. Each line is tagged with the event type that was emitted or the tool the cook called. An event emitted while no stream was open is marked as not pushed.
- **Stir things up.** The doorbell seats a customer. The goose steals a ready dish. The festival bus seats up to three people. Rain makes everyone wait longer. A flicker pauses the pots. While the diner is closed nobody is seated, but the town still happens.
## Events
All three event types offer `poll` and `push` delivery and take no arguments.
| Event | When |
| --- | --- |
| `diner.customer` | A customer arrives (`kind: arrived`), gets grumbly from waiting (`grumbling`), or gives up and leaves (`left_sad`). |
| `kitchen.timer` | A dish is ready, or it burnt because it sat on the stove or in the oven too long. |
| `town.happening` | Something happens on Lantern Street: `goose`, `bus`, `rain`, `flicker`, `flies` when the washing-up pile gets three plates high, or `new_day` when someone starts a fresh day from the page. |
## Tools
- `look` shows the waiting customers and their orders, the stations, the menu and the score. It also returns `heard`, the last things any cook said, so cooks sharing a kitchen can hear each other.
- `cook(dish)` starts a dish on a free station of the right kind: two burners, a cutting board and an oven.
- `serve(customer_id)` serves a ready dish to the customer who ordered it. Faster service earns bigger tips.
- `toss(station)` throws away what is on a station, burnt or not. Each tossed dish adds a plate to the washing-up pile on the counter. The third plate draws flies, and everyone waiting loses a little patience. The pile stays until someone starts a fresh day.
- `say(text, customer_id?)` speaks in the diner. A kind word to a customer buys a little patience, once.
The server's MCP instructions tell a connecting agent how to play.
## Run it
```bash
uv run --with-requirements requirements.txt app.py --port 7860
```
It needs Python 3.12 or later. Open http://127.0.0.1:7860/ to be shown to a room. `GAME_SPEED=2` makes everything happen twice as fast.
The server prints every MCP message and every line of the story to stdout, each with its room name. On a Space these are in the Logs tab. `--log-heartbeats` adds heartbeats and empty polls.
## Hire a cook
Any MCP client that supports the Events extension can cook, by push or by poll. The official [extension support matrix](https://modelcontextprotocol.io/extensions/client-matrix) lists which clients do. With a fast-agent build that has push delivery (for example `olaservo/fast-agent` branch `feat/mcp-events-push`), the `fastagent.config.yaml` here declares the three subscriptions with wake on:
```bash
fast-agent go --config-path fastagent.config.yaml --servers kitchen --model <model>
```
Then say "Open the diner." Each event wakes the agent for a turn. The released fast-agent, from 0.10.69, cooks the same way by polling. The config cooks in the room `my-kitchen`, so watch at http://127.0.0.1:7860/r/my-kitchen. Change the room name in the config's URL to cook somewhere else.
To cook on the hosted Space instead, from a fast-agent checkout on that branch:
```bash
uv run fast-agent go --config-path <this repo>/fastagent.space.yaml --servers kitchen
```
`fastagent.space.yaml` points at the room `my-kitchen` on the Space and uses `hf.zai-org/GLM-5.3-Flash:baseten` through your Hugging Face login. Pass `--model` to pick another.
For a headless cook, use `examples/mcp/events/event_loop.py` from that fast-agent branch with `--config` pointing at `fastagent.space.yaml` and `--server kitchen`.
### The stand-in cook
`cook.py` is a scripted cook with no model behind it. It speaks raw MCP over HTTP: it opens an `events/stream` for each event type, waits for a pushed event, then plays a turn with the tools. Use it to see the whole loop without an Events-capable client.
```bash
uv run cook.py http://127.0.0.1:7860/r/my-kitchen/mcp
uv run cook.py <site>/r/<room>/mcp --shift 180 --think 3
```
`--think` is the pause before each tool call, to stand in for a slow model. `--poll` uses `events/poll` in place of push streams. The server also serves the script at `/cook.py`, and each room's page shows the full command for that room.
## Deploy to a Hugging Face Space
Create a Docker Space and upload `app.py`, `cook.py`, `static/`, `requirements.txt`, `Dockerfile` and this README. A room's MCP endpoint is then `https://<user>-<space>.hf.space/r/<room>/mcp`.
## License
MIT. See [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues