Agents and MCP

Coding agents learn the Engine from the same definitions as everyone else: a schema and an example for every component, through llms.txt, a registry index and a local MCP server. Agents in your app describe interfaces as JSON specs, which render only after they validate.

llms.txt

/llms.txt describes every component and block for language models: what it's for, its usage guidelines, how to install it and an example spec, with links to these docs. Each release's registry has its own, at /r/v/<version>/llms.txt.

The same information as JSON, with each definition's JSON Schema, is in /r/agents.json.

The MCP server

@uiuxengine/mcp is a local MCP server that shows an agent your project. Add it to your agent's MCP configuration:

{
  "mcpServers": {
    "uiuxengine": { "command": "npx", "args": ["@uiuxengine/mcp", "--cwd", "."] }
  }
}
Tool What it returns
list_definitions The components and blocks specs can use, the project's and the registry's other ones
get_definition One definition: guidelines, the JSON Schema of its props, an example spec, its class
list_registry_items The registry's blocks, which ones the project has and whether a newer one exists
get_registry_item One block: the files it copies, the packages they import, the Engine versions it fits
validate_spec Whether a spec is valid for the project and the actions you name, with each issue

The server only reads. It never writes a file or installs anything: to add a block, the agent runs the CLI command the server returns, which you can review like any other command.

It makes no network request unless your project names a registry, in engine.config.ts or with --registry. To show the agent the blocks of your Engine version on uiuxengine.com:

{
  "mcpServers": {
    "uiuxengine": {
      "command": "npx",
      "args": ["@uiuxengine/mcp", "--cwd", ".", "--registry", "https://uiuxengine.com/r/v/0.4.0"]
    }
  }
}

The server loads your project's engine.config.ts and block files, so it runs your project's code. Use it in projects you trust.

Specs

A spec is JSON that describes an interface with your installed components:

{
  "component": "engine.empty-state",
  "props": { "title": "No reports yet", "description": "Reports you create appear here." },
  "slots": {
    "icon": { "type": "icon", "id": "inbox" },
    "action": {
      "component": "engine.button",
      "props": { "variant": "primary", "label": "Create report" },
      "events": { "press": { "action": "reports.create" } }
    }
  }
}

Components are named by their full id. Engine components also accept a short alias, such as button. A spec is one node or an array of nodes.

Render specs in your app

SpecRenderer renders a spec with your production components, only after the whole spec validates against three things your app controls: the components you pass, the icons in your catalog and the actions you register.

import { defineReactComponent, IconCatalogProvider } from "@uiuxengine/react";
import { createActionRegistry, SpecRenderer } from "@uiuxengine/react/runtime";
import { IconInbox } from "@uiuxicons/react/icons/inbox";
import { emptyStateContract } from "./blocks/empty-state/empty-state.contract.ts";
import { EmptyState } from "./blocks/empty-state/empty-state.tsx";

const components = [defineReactComponent({ contract: emptyStateContract, component: EmptyState })];

const actions = createActionRegistry({
  "reports.create": {
    description: "Creates a report.",
    allowAgent: true,
    handler: ({ source, author }) => createReport({ source, author }),
  },
});

export function AgentView({ spec }: { spec: unknown }) {
  return (
    <IconCatalogProvider icons={{ inbox: IconInbox }}>
      <SpecRenderer spec={spec} actions={actions} components={components} />
    </IconCatalogProvider>
  );
}
  • Nothing partial. A spec with any issue renders nothing, or the fallback you pass, which receives the issues.
  • Actions are yours. A press in a spec dispatches a named action, never code. A person's press reaches the handler; an agent can dispatch an action itself only if it's marked allowAgent.
  • An agent's spec binds only what an agent may cause. SpecRenderer treats a spec as written by an agent unless you pass author="host". An agent's spec can bind only actions marked allowAgent, because the agent chose the label and placement a person presses, and any other action is reported as unknown. The handler gets author as well as source, so it can ask a person to confirm a press on an interface an agent wrote. Pass author="host" only for specs your own code wrote.
  • Outcomes reach you. onActionOutcome is called when each dispatch settles, with the action, the event, the node and the result. Without it, a failed dispatch is logged in development.
  • Icons are approved. A spec can only use icons in the nearest IconCatalogProvider.

State and payloads

A component that holds state, such as a Select, takes its initial value from the spec, and its events carry a payload to the action they're bound to:

{
  "component": "select",
  "key": "period",
  "props": { "accessibleLabel": "Period" },
  "state": { "value": "month" },
  "slots": {
    "options": [
      { "component": "option", "props": { "value": "week", "label": "This week" } },
      { "component": "option", "props": { "value": "month", "label": "This month" } }
    ]
  },
  "events": { "valueChange": { "action": "report.setPeriod" } }
}
import { prop } from "@uiuxengine/core";
import { createActionRegistry } from "@uiuxengine/react/runtime";

const actions = createActionRegistry({
  "report.setPeriod": {
    description: "Sets the period the report covers.",
    payload: { value: prop.text({ nullable: true }) },
    allowAgent: true,
    handler: ({ payload }) => setPeriod(payload.value),
  },
});
  • The renderer holds the state. A person's choice shows at once, without a round trip through your app. The state belongs to the node's identity, its key or else its position, so it survives when an agent sends a new spec, and goes when the node does. A new spec replaces it only by giving a different value.
  • Payloads are checked. Every dispatch is validated against the action's payload, from a person, an agent or your own code, and an action without one takes no payload. Validation spots a binding whose event doesn't carry what the action needs before anything renders.
  • Authorization comes first. An agent that isn't allowed to dispatch an action is refused, however valid its payload.

describeRuntime from @uiuxengine/react/runtime returns all of it as JSON: your components with their events, payloads and the state a spec may set, the actions the spec's author may bind with their payloads (pass author: "host" to list them all), your icons, and a JSON Schema for a whole spec restricted to them, ready to put in an agent's prompt or tool definition.

Edit the spec on the Empty State page to see validation at work.