Game of Life MCP
Enables AI agents to control a shared Conway's Game of Life world via MCP tools, with a live browser viewer and WebSocket updates.
README
Game of Life · MCP
A shared Conway's Game of Life world that an AI agent controls through MCP tools while you watch it evolve live in your browser. One Python process serves everything:
| Surface | URL |
|---|---|
| Browser viewer | http://localhost:8000 |
| Live state WebSocket | ws://localhost:8000/ws |
| MCP endpoint (Streamable HTTP) | http://localhost:8000/mcp |
The server owns the authoritative board (NumPy). Every MCP tool call mutates it and immediately broadcasts the new state to all connected browser tabs.
Codex / Claude Code ──MCP──▶ ┌───────────────────┐
│ Python server │──▶ shared GoL world
Browser UI ◀──WebSocket──── │ (FastAPI+FastMCP) │
└───────────────────┘
Quickstart
.\run.ps1
(First run creates the venv and installs dependencies. If PowerShell blocks the
script, run it as powershell -ExecutionPolicy Bypass -File run.ps1.)
…or manually:
py -m venv .venv
.venv\Scripts\python.exe -m pip install -r requirements.txt
.venv\Scripts\python.exe -m uvicorn gol_server:app --host 127.0.0.1 --port 8000
Open http://localhost:8000. The server binds to localhost only and has no auth — it's a local toy, don't expose it.
Connect an agent
Claude Code (run in any terminal; the server must be running when the agent starts):
claude mcp add --transport http gol http://localhost:8000/mcp
Codex CLI — add to ~/.codex/config.toml (exact key names vary by Codex
version; check its MCP docs):
[mcp_servers.gol]
url = "http://localhost:8000/mcp"
MCP tools
| Tool | What it does |
|---|---|
get_world_status() |
Dimensions, generation, population, live-cell bounding box, dynamics, autorun state |
observe_world(x, y, width, height) |
ASCII view of a region (# alive, . dead) with coordinate rulers; defaults to the full board, capped at 20 000 cells |
create_world(width, height, edge, random_fill) |
New board, 8–1024 per side; edge="wrap" (toroidal, default) or "dead"; optional random soup |
clear_world() |
Kill everything, reset generation to 0 |
set_cells(alive, dead) |
Set individual cells from lists of [x, y] pairs |
place_pattern(rle, x, y, clear_rect) |
Stamp a standard RLE pattern (e.g. glider bob$2bo$3o!) at a position |
advance(generations) |
Step the simulation, 1–100 per call, animated in the browser |
advance_generations(count, sample_every) |
Efficiently commit up to thousands of generations in one call, returning compact per-sample stats (not the full board) plus a run summary |
preview_generations(count, sample_every) |
Same as advance_generations but doesn't touch the world — test what would happen before committing |
set_autorun(enabled, fps) |
Continuous simulation on the server, 1–1000 gen/s |
Coordinates everywhere: (x, y), 0-indexed, (0,0) top-left, x → right,
y ↓ down.
advance_generations / preview_generations
Both return {"samples": [...], "summary": {...}} as a JSON string — never
the full board, so responses stay small even over thousands of generations.
sample_every controls how often a sample is recorded (always including the
final generation); each sample has generation, population, births and
deaths (since the previous sample), bbox, a state_hash (matches only a
bit-for-bit identical board) and a shape_hash (translation-independent —
stays the same while a pattern like a glider moves). The summary reports
start/end generation, min/max population, and whether the run went extinct,
settled into a static state, or fell into a short repeating cycle.
Two caps apply, both surfaced as a {"error": ...} object in the response
(not a thrown error) when exceeded:
- At most 500 samples per call. Raise
sample_everyif you hit this — the error tells you the minimum value that fits. countis capped by board size, not a flat number. The real cost of a run iswidth × height × count, so a 1024×1024 board allows far fewer generations per call than the default 160×100 board — the error reports the exact ceiling for the current board. Call the tool repeatedly for more.
advance_generations commits each sample to the live world as it goes (so
the browser animates progress at the sample_every cadence); preview_generations
never touches the world or the browser. Both walk the identical simulation
code, so a preview and a subsequent advance with the same arguments always
agree exactly.
Browser viewer
- Play / Pause / Step / speed — drives the same server-side simulation the agent uses.
- Draw / Erase / Pan — left-drag paints (right-drag always erases), wheel zooms, middle-drag pans, Fit re-centers.
- Activity panel — live feed of every MCP tool call, so you can watch the agent think.
Challenge ideas
- "Place a Gosper glider gun and report the population after 200 generations."
- "I've drawn a mess in the middle — stabilize the board into only still lifes."
- "Make two gliders collide head-on and tell me what survives."
- "
create_world(300, 200, random_fill=0.2), run it until it settles, then find and report the coordinates of every oscillator." - "Write my initials using still lifes."
Files
gol_server.py— FastAPI app: WebSocket hub, MCP tools, autorun loopgol_world.py— pure simulation: NumPy stepping, RLE parser, ASCII rendererstatic/— the browser viewer (vanilla JS + canvas)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。