WebMCP Tools

A scoped browser tool registry with explicit action permissions.

Preview

Agent tools

How it works

Cards for a gallery, with a primary star and request access. The editor keeps name, description and instructions as drafts until Save; the model, tools, choices and knowledge ask at once. Native select, radios and checkboxes in fieldsets; read-only disables the fieldset. Delete asks for the name.

Installation

npx shadcn@latest add checkfu/uicontext/agent-tools

Integration

Give each mounted tool surface a stable ID. Supply an explicit action allow list. Use page_snapshot to find actions and page_query to inspect their input schemas before calling page_act.

Mount one AgentConfirm dialog with its policy below the page layer. A named task with explicit target acknowledgement accepts the action input and the observed target separately. Pass an AbortSignal to cancel the pending browser tool.

bun run test:consumer --case contracts --keep

Run this from the UiContext checkout. From the temporary app it prints, run bunx vite to open it.

View the executable example
import "@w3c/webmcp-polyfill/auto"
import { BrowserHost, Html } from "@effect/ui/html"
import { Effect, Layer, Schema } from "effect"
import { Notes } from "./notes.ts"
import { SaveWorkflow, Workflows } from "./workflows.ts"
import { AgentConfirm, layer as confirmLayer } from "./ui/uicontext/components/agent/AgentConfirm.ts"
import { layer as pageLayer, type TaskTool } from "./ui/uicontext/components/agent/AgentPage.ts"
import "./base.css"

const App = Html.component({ name: "ContractExamples", model: Schema.Null, message: Schema.Never }).make({
	init: () => null,
	update: {},
	view: (h) => h.div.attr("class", "contract-examples").children(
		h.h1.children("Controlled interfaces"),
		Notes(h, {}),
		Workflows(h, {}),
		AgentConfirm(h, {}),
	),
})

const archiveSelection: TaskTool = {
	name: "archive_selection",
	title: "Archive selected workflows",
	description: "Archive exactly the selected workflow rows after a person reviews the selection.",
	target: { id: "workflows", action: "ClickedAction" },
	input: Schema.Struct({ action: Schema.Literal("archive") }),
	targetAcknowledgement: "explicit",
	consequential: true,
}

const root = document.querySelector("main")
if (root === null) throw new Error("Missing example root.")
const main = BrowserHost.mount(App, {}, root).pipe(
	Layer.provide(SaveWorkflow.layer),
	Layer.provide(pageLayer({
		allow: {
			actions: ["Table.CommittedEdit", "Table.RequestedSelection"],
			tasks: [archiveSelection.name],
		},
		tasks: [archiveSelection],
	})),
	Layer.provide(confirmLayer()),
)
Effect.runFork(Layer.launch(main))
entry.ts on GitHub

Source