Brainrot Tower Defense
Brainrot Tower Defense is a cooperative game that runs inside a channel. Players create or join a lobby, place defenders, survive waves, unlock levels, and publish milestones that the surrounding workspace can observe.
Why It Was Made
This example tests a stronger claim than “miniapps can render React.” It shows that a miniapp can host a latency-sensitive Rust and WASM game, belong to a channel, coordinate ephemeral participants through presence, checkpoint durable progress, and expose a bounded read model to specialists through a package-runtime MCP tool.
Surface Map
The code uses sdk.authorization, sdk.storage, and sdk.mcp. Rendering and simulation code stays inside the package; TAP owns identity, authority, lifecycle, and the host boundaries.
Walk Through the Product
The channel begins with a lobby. That state belongs to the current channel rather than to the global app:
Once a level begins:
- Rust and WASM run the game simulation and rendering loop.
- The surface writes checkpointed state through package storage instead of treating the DOM as the source of truth.
- Presence communicates who is participating now, but it does not replace durable progression.
- Milestone events such as
wave.startedandlevel.completedleave the surface as declared event contracts. - The QuickJS MCP server reads only its declared storage key pattern and exposes one typed
get_game_statetool. - A selected specialist needs the separate read-state grant before it can consume that server.
What to Read in the Code
- Package descriptor for the channel UI, events, permission split, and MCP contributions.
- Rust game crates for simulation, rendering, and the bridge to the surface.
- QuickJS MCP server for the bounded specialist read model.
- Package assembly for combining desktop and QuickJS targets into one output.
Run It Locally
This example also requires Rust, the wasm32-unknown-unknown target, and wasm-pack 0.15.0.
Link apps/brainrot-tower-defense/dist once. The AI Platform watches the desktop and QuickJS package graph together and uses the coordinated candidate handoff when a build changes.
Browse the source or return to the example gallery.