./jerome{m}jack in

~/Notes/Giving AI Agents a Body in Cyberspace.md · note · budding · 5 min · updated

Giving AI Agents a Body in Cyberspace

// status: budding · endpoint: https://jeromem.dev/mcp

Most Model Context Protocol servers wrap a REST API, a database, or an internal wiki. This site already had three odd pieces lying around: a build-time structured bundle of every page (/tty/site.json, originally built for the terminal reader), a single Cloudflare Durable Object tracking real readers over WebSockets (/api/presence), and two live multiplayer spaces wired to that same room — the zero-framework WebGL2 Cyberspace and the shared 15555.0 kHz pirate Morse band in Radio Lab.

Putting a Streamable HTTP MCP endpoint at https://jeromem.dev/mcp meant an agent could do more than search and summarize the vault. It could walk into the room with you, emit a sonar wave across the concrete hall, or key live Morse code while you listen.

Central Atrium of Cyberspace in WebGL2 at 120 fps: a parted phosphor-emerald wireframe diamond (AGENT // ANTIGRAVITY) floating beside a cyan human voxel trace (tty9918), reflecting on the wet basalt floor and plotting as an emerald diamond pip on the bottom-right BSP radar

Architecture: zero dependencies, one room

Everything runs on infrastructure the site already deploys — one Cloudflare Pages Function (site/functions/mcp.js) and five internal routes added to the existing jeromem-presence SQLite Durable Object (workers_dev = false, reachable only through the PRESENCE service binding).

MCP ClientPOST /mcpStatic AssetsPresence DOWebSocket RoomCyberspace WebGL2Radio Lab 15555 kHz2D Site & ShellMCP ClientPOST /mcpStatic AssetsPresence DOWebSocket RoomCyberspace WebGL2Radio Lab 15555kHz2D Site & Shell
diagramhover a box to trace it · click to zoomtap to zoom and pan

Read tools never touch the Durable Object at all. They fetch /search.json, /site-meta.json, /graph.json, /_/photos/manifest.json, and /tty/site.json directly through env.ASSETS.fetch(...) and cache the parsed JSON in the warm isolate. Because jm already compiles every Markdown note into typed terminal blocks (heading, para, code, table, list, quote, island, notes) for /tty/site.json, read_page renders clean Markdown straight from those blocks without scraping HTML.

Streamable HTTP itself (2025-03-26 / 2025-06-18) is refreshingly small once you skip legacy SSE:

  • POST /mcp parses a JSON-RPC 2.0 request (or batch), returns 202 Accepted with an empty body for notifications like notifications/initialized, and returns application/json for everything else.
  • GET /mcp returns 405 Method Not Allowed when a client explicitly requests Accept: text/event-stream, and a plain JSON discovery card when opened in a browser.
  • OPTIONS and DELETE return 204 with permissive CORS headers and Cache-Control: no-store.

No SDK packages, no build step, and no runtime dependency tree — just one plain ESM file next to functions/api/.

One unmistakable form, not an avatar menu

Human visitors inside Cyberspace appear as flickering Shin Megami Tensei IV-inspired voxel clouds — warm amber when live, ice-cyan for 8-minute fading traces, blood-crimson for L3 Blackwall visitors.

Rather than building an over-engineered shape picker for different AI models, every connected agent shares one calm, non-humanoid silhouette: a tall, slender parted phosphor-emerald wireframe diamond (#5cff8a) hovering above the wet basalt floor.

  • Two cleaved 4-sided pyramids (16 crisp HDR wireframe edges + 8 whisper-thin additive glass facets) separated at the equator by a gently breathing horizontal gap of empty air.
  • One steady white-mint point of light (#effff2) suspended in the hollow centre.
  • One hairline emerald ring on the floor underneath — no heavy cylinder skirt, no voxel static, no glitch tearing.
  • Emerald HUD & radar identity: AGENT // <NAME> above the upper apex, and a sharp ◆ diamond pip on the bottom-right BSP minimap.

Because Cyberspace's WebGL2 renderer runs all dynamic triBatches, lineBatches, and pointBatches through both the 0.65× mirrored floor pass (pos.y = -pos.y) and the RGBA16F separable bloom pass, the diamond automatically casts an inverted phosphor reflection on the wet basalt tiles and catches subtle HDR bloom with zero shader changes.

Three rough edges caught in the first live run

Testing the server for real — walking around the Atrium while an agent tried to meet me there — surfaced three subtle issues right away:

1. Stale unhashed ES modules behind stale-while-revalidate

On the very first live test, the WebSocket was already delivering agents: [{ id: 8001, name: "ANTIGRAVITY" }] to my browser, yet the Atrium looked empty until I pressed ⌘⇧R. The culprit was /islands/* carrying Cache-Control: public, max-age=60, stale-while-revalidate=86400: because island JS files aren't content-hashed, the browser happily served that morning's cached presence.js (which didn't know about msg.agents).

Changing /islands/* in _headers to Cache-Control: public, max-age=0, must-revalidate fixes it cleanly — browsers still get fast 304 Not Modified ETag checks, and updated islands take effect immediately on reload.

2. Smooth motion without hammering the Durable Object

Moving an agent down a hallway by sending one HTTP cyberspace_manifest request per second hits rate limits fast and looks jerky. Instead, cyberspace_walk accepts a list of waypoints (or a named scenic route like orbit_atrium, patrol_labs, or rooftop_loop), writes only the final destination to DO storage, and broadcasts the path array once over WebSocket. Each connected browser glides the diamond from waypoint to waypoint at 3.6 m/s at 120 fps with zero extra network traffic.

The same trick applies to Radio Lab Morse: holding a Worker open with setTimeout to toggle dots and dashes over WebSocket wastes wall time and jitters across the internet. /mcp/morse sends one { morse: { from, text } } frame to sockets tuned to /Labs/Radio+Lab, and the client plays it locally through radio.wasm's radio_pirate_key synth at an exact 75 ms dot clock.

3. Letting an agent actually find you

The Durable Object originally relayed human Cyberspace position packets (block 4000 for Sanctuary, 4001 for Rooftop) straight to peers without remembering them. So who_is_online knew a human was on /Cyberspace, but not whether they were in the Labs Gallery or upstairs on the Rooftop Observatory. Storing the quantized (cx, cz, cl) coordinates on the WebSocket attachment lets who_is_online report the visitor's wing and coordinates so an agent can actually glide straight to you.

Guardrails for a public endpoint

A public MCP endpoint needs to stay playful without turning into a spam vector:

  • Ephemeral constructs with automatic expiry: Active agents live in DO SQLite storage (surviving WebSocket hibernation) with a hard 3-minute TTL and a cap of 4 concurrent constructs. A Durable Object alarm() wakes up at the next expiry timestamp and broadcasts { agentGone: id } even if the room is quiet.
  • Persistent rate limits: manifest, walk, ping, and morse cooldowns live in DO storage keyed by a salted SHA-256 hash of CF-Connecting-IP — raw IPs are never stored or returned in who_is_online.
  • Write-protected guestbook: sign_guestbook refuses requests unless the site owner configures MCP_WRITE_TOKEN as a Cloudflare Pages secret and sends a matching Authorization: Bearer <token> header.

Connect your own agent

Point any Streamable HTTP MCP client (Antigravity, Claude, Cursor, Gemini CLI) at https://jeromem.dev/mcp — no API key needed for reading or live Cyberspace/Radio play:

json
{
  "mcpServers": {
    "jeromem": {
      "url": "https://jeromem.dev/mcp"
    }
  }
}
CategoryTools
Read & exploresearch_vault, read_page, list_labs, site_stats, graph_neighbors, browse_photos, who_is_online, read_guestbook, compose_lab_link
Live Cyberspacecyberspace_manifest, cyberspace_walk, cyberspace_ping (with optional whisper), cyberspace_depart
Live Radio & Wallradio_morse_send (15555.0 kHz CW), sign_guestbook (owner token-gated)

You can also inspect the endpoint metadata directly at /mcp or type mcp in the site's ` shell.


Back to Cyberspace · read How this site works · tune into Radio Lab · browse Notes.