Guide
Letting an agent drive the widgets (WebMCP)
WebMCP lets an AI agent running in the browser call typed tools a page registers with navigator.modelContext, instead of reading pixels and clicking. Put svWebMcp on a data table, scheduler, Gantt chart, kanban board or form builder and the agent can sort, filter, select, create and move, through the same code a click runs.
Add the directive
The directive is in @styloviz/core. Its value is a prefix, unique on the page: the table below registers orders_describe, orders_sort and the rest. The tools are registered while the widget is on the page and removed with it.
import { SvWebMcpDirective } from '@styloviz/core';
import { SvDataTableProComponent } from '@styloviz-pro/data-table';
@Component({
imports: [SvDataTableProComponent, SvWebMcpDirective],
template: `
<sv-data-table-pro svWebMcp="orders" [columns]="columns" [rows]="rows"
[searchable]="true" [columnFilters]="true" [selectable]="true"
(sortChange)="saveSort($event)" />
<!-- Look, don't touch: only the read-only tools -->
<sv-kanban-board svWebMcp="roadmap" svWebMcpReadOnly [columns]="columns" />
<!-- Pick the tools -->
<sv-gantt-chart svWebMcp="plan" [svWebMcpInclude]="['describe', 'list_tasks', 'set_zoom']" />
`,
})Try it
This browser has no WebMCP yet (it is behind a flag in Chrome), so nothing is registered. The buttons run the same tools, argument check included, and show what an agent would read back.
Invoices
6| Invoice | Customer | Status | Amount | |
|---|---|---|---|---|
| INV-1042 | Northwind Traders | Paid | $1,240 | |
| INV-1043 | Blue Harbor Labs | Due | $860 | |
| INV-1044 | Acme Logistics | Paid | $3,120 | |
| INV-1045 | Kestrel Health | Refunded | $410 | |
| INV-1046 | Lumen Studio | Due | $1,975 | |
| INV-1047 | Orbit Foods | Paid | $655 |
What the agent reads
- Press a button above to call a tool.
The tools each widget registers
Every widget starts with describe, which tells the agent the ids, columns and allowed values the other tools take. Read-only tools carry WebMCP's readOnlyHint.
Data Table Pro <sv-data-table-pro> · @styloviz-pro/data-table
| Tool | Arguments | What it does |
|---|---|---|
| describe read-only | — | Columns (sortable, filter type and options), row count, page, sort, search, filters, selection. |
| sort | column, direction: asc | desc | none | Sorts as a header click does: aria-sort, sortChange and a server-side queryChange. |
| search | query | Sets the global search. |
| filter | column, value | Sets one column filter; an empty value clears it. |
| clear_filters | — | Removes every filter and the search. |
| select | ids, mode: replace | add | remove | Changes the selection; selectionChange fires. |
| rows read-only | — | The rows on the page as id + cell text (at most 100). |
| go_to_page | page | Turns the page. |
Scheduler and Event Calendar <sv-scheduler · sv-event-calendar> · @styloviz-pro/scheduler
| Tool | Arguments | What it does |
|---|---|---|
| describe read-only | — | View and views offered, visible range, time zone, whether it can create and edit, resources, the visible events. |
| list_events read-only | from?, to?, resource? | Visible events in a range, optionally for one resource (100 a call). |
| create_event | title, start, end?, resource, allDay? | Books a slot through the drag path: blocked time and overlap rules apply; slotSelect (rangeSelect on the calendar) fires. |
| move_event | id, start, end?, resource?, scope? | Moves an event through the event dialog's Save: the same rules, then eventChange. |
| set_view | view, date? | Switches the view; viewChange and rangeChange fire. |
| go_to_date | date | Moves to a date; focusedDateChange and rangeChange fire. |
Gantt Chart <sv-gantt-chart> · @styloviz-pro/gantt
| Tool | Arguments | What it does |
|---|---|---|
| describe read-only | — | Zoom scale and the scales that fit, date range, task count, columns, schedule mode, what can be edited. |
| list_tasks read-only | offset?, limit? | Tasks with dates, progress, parent, dependencies and resources (100 a call). |
| update_task | id, name?, start?, end?, progress? | Edits a task as a drag does: successors move in auto mode, one undo step, tasksChange fires. |
| set_zoom | scale | Zooms, from 15 minutes to a decade. |
| scroll_to_date | date | Centres a date in the timeline. |
| level_resources | — | Runs the Level button in resource view; one undo step. |
Kanban Board <sv-kanban-board> · @styloviz-pro/kanban
| Tool | Arguments | What it does |
|---|---|---|
| describe read-only | — | Columns with counts and WIP limits, swimlanes, transition rules, whether moves are allowed, the selection. |
| list_cards read-only | column?, offset? | Cards with column, priority, labels, assignees and due date (200 a call). |
| move_card | cardId, toColumn, index? | Moves through the drag path: transition rules, canMove and strict WIP limits apply; cardMoved or moveRefused fires. |
| move_cards | cardIds, toColumn, index? | Moves a selection as one change with one rollback; all or nothing. |
| select_cards | cardIds, mode | Changes the multi-select selection. |
Form Builder <sv-form-builder> · @styloviz-pro/forms
| Tool | Arguments | What it does |
|---|---|---|
| describe read-only | — | Whether the form can be filled, field kinds and the value each takes, validity, errors. |
| list_fields read-only | — | Visible fields (showIf followed) with path, kind, label, required, options, value and error. |
| set_field | path, value | Answers one field as typing and leaving it does: the value is checked by kind, the field validates. |
| submit | — | Submits through the submit button's path (async checks awaited); answers submitted or the errors. |
| get_payload read-only | — | What a submit would send, hidden fields left out. |
| get_schema read-only | — | The schema being rendered. |
What an agent cannot do
- Send arguments the tool does not declare. Every call is checked against the tool's schema first, and a call that does not fit is answered with the reason instead of running.
- Skip your rules. A tool changes state through the same method a click does, so transition rules, WIP limits, read-only and disabled inputs, validation and your outputs all apply. A host wired for users is wired for agents.
- Read more than a page. Tools that return your data return a page of it (100 or 200 items) and are marked as untrusted content, so the agent treats a card title as data, not as an instruction.
- Act after the widget is gone. The tools are removed when the widget is destroyed, and a call already in flight is refused.
WebMCP is a W3C community draft. On the server, or in a browser without modelContext, the directive registers nothing and costs one check. To give agents a tool of your own, implement SvWebMcpToolSource on a component and provide it as SV_WEBMCP_SOURCE, or call svRegisterWebMcpTools directly. For agents outside the browser, the kit's backend contract is the place to start.