DEV Community

Cover image for MCP, AG-UI, and A2UI: How the Three AI-UI Protocols Fit Together (With Live Zero-Dep Demos)
Ivan
Ivan

Posted on Edited on

MCP, AG-UI, and A2UI: How the Three AI-UI Protocols Fit Together (With Live Zero-Dep Demos)

If you have been building AI interfaces in 2026, you have probably seen three acronyms show up in the same week: MCP, AG-UI, and A2UI.

A common question from frontend engineers is: "Are these competing standards? Which one should I pick?"

The short answer is they do not compete. They solve three different layers of the AI-to-UI lifecycle:

Layer Protocol When It Runs What It Solves
1. Build / Prompt Time MCP (Model Context Protocol) While a coding agent writes your app Gives the agent verified component schemas, design tokens, and WCAG checks so it stops hallucinating props.
2. Runtime Event Stream AG-UI (Agent-User Interaction) While an agent executes a task Streams lifecycle events, reasoning steps, tool-call approvals (HITL), and RFC 6902 JSON Patch state deltas.
3. Runtime Declarative UI A2UI (Agent-to-UI) When an agent generates UI on the fly Streams structured JSON component trees into a locked client catalog with zero executable code and zero innerHTML.

In @wcomp/elementum@0.8.0, we implemented all three layers on top of a single zero-dependency Web Components foundation (109 WCAG 2.2 AA components that work in React 18/19, Vue 3, Svelte 5, Next.js, and Vanilla HTML).

Here is how each layer works in practice, with live browser demos you can inspect right now.


Layer 1: MCP (Verifiable Component Contract at Build Time)

When an AI coding agent generates UI from memory, it invents attribute names, misses ARIA labels, and forgets responsive layouts.

Elementum exposes its W3C Custom Elements Manifest (custom-elements.json), design tokens, markup validator (validate_component_usage), and static accessibility linter (lint_accessibility) over a hosted Vercel Edge MCP endpoint (100/100 on mcptry.com):

https://elementum-sage.vercel.app/mcp

You can configure any project (React, Next.js, Vue, Svelte, or Vanilla) in one command:

npm install @wcomp/elementum && npx @wcomp/elementum init
Enter fullscreen mode Exit fullscreen mode

Or connect Claude Code directly:

claude mcp add --transport http elementum https://elementum-sage.vercel.app/mcp
Enter fullscreen mode Exit fullscreen mode

In our reproducible 4-Arm AI-Agent UI Benchmark scored in headless Chromium with @axe-core/playwright, Elementum arms achieved 0px desktop and mobile overflow and 0-1 severe WCAG violations, compared to 69px-585px mobile overflow and 5-8 severe WCAG violations in conventional CSS and raw HTML baselines.


Layer 2: AG-UI (Runtime Execution, Tool Approvals & JSON Patch State)

Once your app is deployed, users interact with live agents that think, call tools, request human approval, and update application state incrementally.

@wcomp/elementum/ag-ui provides a zero-dependency reactive store (createAgUiStore) that consumes Server-Sent Events (SSE) and applies RFC 6902 JSON Patch STATE_DELTA updates straight to Elementum micro-signals without Virtual DOM re-render cascades:

import '@wcomp/elementum/tokens.css';
import '@wcomp/elementum';
import { createAgUiStore } from '@wcomp/elementum/ag-ui';

const store = createAgUiStore();

store.dispatch({
  type: 'STATE_DELTA',
  delta: [{ op: 'replace', path: '/progress', value: 80 }],
});
Enter fullscreen mode Exit fullscreen mode

Layer 3: A2UI (Safe Declarative Agent UI at Runtime)

Sometimes a fixed chat bubble is not enough. An agent helping a user rebook a flight or adjust a billing cap should render real seat chips, switches, meters, and confirmation buttons without executing untrusted HTML or JavaScript.

@wcomp/elementum/a2ui (createA2UiSurface) maps streaming A2UI JSONL messages (dataModelUpdate, surfaceUpdate, beginRendering, deleteSurface) onto a locked catalog of native Elementum Web Components:

import '@wcomp/elementum/tokens.css';
import '@wcomp/elementum';
import { createA2UiSurface } from '@wcomp/elementum/a2ui';

const surface = createA2UiSurface({
  allowedTypes: ['Card', 'Column', 'Text', 'ChoiceChip', 'Button'],
  onAction: (ev) => console.log('Agent action:', ev.actionName, ev.context),
});

surface.mount(document.getElementById('a2ui-host'));
surface.processMessage(chunkFromStream);
Enter fullscreen mode Exit fullscreen mode

Key security guarantees built in:

  1. Locked Catalog Allowlist: Unregistered or disallowed node types (like script/iframe tags) are silently dropped and reported in surface.blockedTypes.value.
  2. Zero innerHTML: All text and labels bind via textContent and fine-grained signal effects.
  3. Inline Handler & URL Stripping: on* attributes and javascript:/data: URLs are rejected automatically.

Explore the Full 4-Chapter Platform Story

If you want to see how design tokens (Penpot/Figma), framework parity (React 19, Vue 3, Next.js DSD SSR, Vanilla HTML), and the 3 AI protocols fit together in one place, start here:

  <link rel="stylesheet" href="https://unpkg.com/@wcomp/elementum/tokens.css" />
  <script type="module" src="https://unpkg.com/@wcomp/elementum"></script>
Enter fullscreen mode Exit fullscreen mode

If you try npm install @wcomp/elementum && npx @wcomp/elementum init in a real project, I would genuinely love your first-attempt feedback as we harden the path toward 1.0.0.

Top comments (2)

Collapse
 
raju_dandigam profile image
Raju Dandigam •

@pinguxx The three-layer separation is useful, especially keeping A2UI output inside a locked component catalog. On the AG-UI side, I would test a late STATE_DELTA from an old agent run after the user has moved to a new task or surface. Does createAgUiStore bind patches to a run/surface identity and reject unexpected paths, or is that a responsibility for the application wrapping the store?

Collapse
 
pinguxx profile image
Ivan •

createAgUiStore handles both directly:

  • Run and surface isolation: Once RUN_STARTED sets the active runId (or you lock/switch surfaces with surfaceId, store.setSurface(), or store.resetRun()), late STATE_DELTA or other events carrying an old runId or mismatched surfaceId are dropped and recorded in store.rejectedEvents (and optional onReject). Setting strictRunId: true also drops events that omit runId.
  • Path allowlist: Passing allowedPaths: ['/progress', '/plan'] restricts RFC 6902 patches to those exact JSON Pointer prefixes and drops any other path (alongside the built-in proto/constructor/prototype guard).
const store = createAgUiStore(initialState, {
  surfaceId: 'task-a',
  strictRunId: true,
  allowedPaths: ['/progress', '/plan'],
  onReject: ({ reason, event }) => console.warn(reason, event),
});
Enter fullscreen mode Exit fullscreen mode

Thanks for the feedback.