Inspiration
Most web agents still have to infer what a page means from pixels, text, and UI controls. That works for simple interactions, but it becomes brittle when the application has domain state, history, causality, and actions with different safety implications.
CountryLab explores a different model: the webpage itself exposes the semantic operations an agent actually needs.
What it does
CountryLab is an interactive miniature country with a deterministic economy. A human can inspect regions and metrics, change interest rates, taxes, spending, and tariffs, trigger shocks such as floods or oil shocks, and advance the simulation through time.
The same application exposes 17 semantic WebMCP tools to an agent. Instead of scraping charts or clicking blindly, the agent can:
- read the exact current country state;
- inspect regions and sectors;
- query event, metric, and causal history;
- make explicitly requested live policy or event changes;
- run isolated counterfactual experiments without overwriting the live country; and
- visibly focus the map, WHY inspector, or scenario comparison so the human sees the same evidence.
The flagship workflow is:
- A human floods the port and advances the simulation.
- The agent observes the changed world through WebMCP.
- It investigates event, region, metric, and causal history.
- It traces a chain such as flood → trade/import disruption → supply pressure → inflation.
- The human asks the agent to prove the claim without changing the live country.
- CountryLab creates an isolated alternate timeline that removes only the selected flood and replays later interventions at their original points in time.
- The agent compares both timelines and opens the result in the webpage.
- The original live country remains unchanged.
Why WebMCP is a strong fit
CountryLab depends on domain semantics that are difficult and unreliable to recover through ordinary browser automation. An agent should not have to infer numeric state from charts, reconstruct chronology from visual labels, or guess whether an action mutates the live simulation or runs a safe experiment.
WebMCP gives the agent structured access to:
- exact simulation state instead of visual inference;
- stable region, sector, event, snapshot, and scenario identifiers;
- bounded metric and event history;
- deterministic causal provenance;
- explicit live-world actions;
- isolated counterfactual experimentation; and
- visible UI-focus tools that return the agent's reasoning to the human interface.
This turns the webpage into a shared experimental instrument rather than a collection of buttons for an agent to automate.
How it improves the user experience
Without WebMCP, an agent would need to infer values and chronology indirectly, reconstruct causal relationships from presentation, and simulate UI clicks to manipulate the country. That is brittle and loses the important distinction between observation, live mutation, and isolated experimentation.
With WebMCP, the agent can begin read-only, understand exactly what the human changed, gather deterministic evidence, run a safe alternate timeline, compare outcomes, and visibly show the proof.
Human actions are immediately visible to subsequent agent reads, and agent live actions immediately update the same interface because both use the same application-service and shared-state layer.
What humans and agents can do together
A human can create a disaster or policy situation visually and ask open-ended questions such as:
- “Something changed. Investigate what happened.”
- “Why did inflation rise? Show me the chain.”
- “Prove the flood caused the increase, but do not change my live country.”
The agent can independently gather evidence, identify the relevant event and metrics, retrieve deterministic causal provenance, formulate a counterfactual test, run the alternate timeline, compare outcomes, and open the visible comparison for the human.
The human can intervene again at any time, and the next WebMCP read observes the same updated world.
How WebMCP was implemented
CountryLab uses the imperative document.modelContext.registerTool(...) API with capability detection and registration-scoped AbortSignal cleanup.
The 17 tools are grouped into four categories:
- Observation: country state, region/sector inspection, metric history, event history, causal history.
- Explicit live mutations: policy changes, shocks, emergency response, time advancement, snapshots.
- Isolated experiments: counterfactual runs and scenario comparison.
- Visible explanation: region highlighting, metric focus, causal-chain display, and scenario-comparison display.
Tool schemas use strict object shapes, enums, numeric bounds, and additionalProperties: false. Read-only tools carry readOnlyHint: true. Live mutation tools explicitly describe their effects.
The WebMCP layer does not contain economic formulas. Both the React/Phaser human interface and WebMCP actions use the same application service and Zustand state over the deterministic economy engine.
Counterfactual event removal branches from saved event-time checkpoints and replays subsequent recorded live interventions into both branches. That allows the comparison to mean “same later history, except this event,” while keeping the live world untouched.
Testing
CountryLab has been tested with ChatGPT's WebMCP-capable agent browser. The deployed app exposes exactly 17 CountryLab tools and the human UI continues to work normally when WebMCP is unavailable.
A recommended judge flow is:
- Open the live site.
- Trigger Flood · Port and advance six months.
- Ask: “Something changed. Investigate what happened.”
- Ask: “Why did inflation rise? Show me the chain.”
- Ask: “Prove the flood caused the increase, but do not change my live country.”
- Confirm the scenario comparison opens and the live world remains unchanged.
Built with
React, Phaser, TypeScript, Zustand, Vite, WebMCP, and a deterministic in-browser economy/counterfactual engine.
Accuracy note
CountryLab is an educational toy causal model. It demonstrates transparent directional relationships and deterministic experimentation; it is not a real-world economic forecasting or policy-advice system.
Built With
- phaser.js
- react
- typescript
- vite
- webmcp
- zustand
Log in or sign up for Devpost to join the conversation.