Browser AI agents are currently stuck in a dark age of visual guessing. They take screenshots, parse the DOM, and pray they click the right button. Anastasios Theodosiou’s latest deep dive demonstrates how Angular 22’s experimental WebMCP support ends this charade. By publishing a structured contract of tools directly to the document.modelContext, developers can allow agents to execute functions natively, bypassing the expensive and fragile screenshot loop entirely.

The Shift from Visual Guessing to Structured Contracts

WebMCP, a W3C Community Group draft, transforms a web page into an MCP server running in the user's own session. Instead of an agent guessing that a specific CSS class corresponds to an 'Add' button, the page registers a tool named add_todo with a strict JSON Schema. The agent simply calls add_todo({ title: 'buy milk' }). This approach eliminates the token waste of visual parsing and prevents breakage when UI elements are renamed or moved.

Lifecycle-Aware Tool Registration in Angular

The integration with Angular’s dependency injection system is where the real power lies. Using provideExperimentalWebMcpTools, developers can register app-wide tools that persist for the application's lifetime. More critically, declareExperimentalWebMcpTool allows tools to live and die with specific components. If a user navigates away from a list, the set_filter tool vanishes from the agent’s available list, ensuring the agent only sees what the user can actually interact with.

Signal Forms as Zero-Code Agent Tools

Theodosiou highlights a killer feature: Signal Forms can register themselves as tools with no extra boilerplate. By adding experimentalWebMcpTool to a form’s configuration, Angular automatically infers the input schema from the model and validation rules. If an agent tries to submit an empty title, the form’s validation logic rejects it and returns a structured error, allowing the agent to self-correct without developer intervention.

The Reality of Experimental APIs

Despite the promise, this is not production-ready. The APIs are marked experimental, and Chrome’s WebMCP support is still an early preview. The article emphasizes that Angular does not validate agent input against the schema at runtime; developers must manually validate every argument and return isError: true for destructive actions. Annotations like consequentialHint are currently the only way to signal to an agent that a tool might perform a hard-to-undo action.

Key Takeaways

  • WebMCP replaces visual parsing with direct function execution via document.modelContext.
  • Angular 22 integrates tool registration with component lifecycles using declareExperimentalWebMcpTool.
  • Signal Forms can be exposed as tools automatically, inheriting all existing validation logic.
  • Runtime validation is mandatory; the framework does not enforce schemas against agent input.
  • Use consequentialHint to prevent agents from accidentally deleting data or clearing states.

The Bottom Line

This is the 'agent-ready' layer we’ve been waiting for, but treat it as a prototype for now. If you’re building internal tools, start exposing your store methods as WebMCP tools today to stay ahead of the curve.