Agent / foldkit-agent-webmcp
Expose HTML forms as declarative tools
WebMCP also lets browsers derive tools directly from HTML forms carrying toolname, tooldescription, name, and toolparamdescription so users see the agent fill and submit the form on screen. AgentWebMcp.formTool generates those attributes from your contract so form markup and imperative tools share one definition:
const CreateTodoForm = AgentWebMcp.formTool(AppAgent, 'requested_create_todo')
h.form([...CreateTodoForm.form(h), h.OnSubmit(Message.DraftSubmitted())], [
h.input([...CreateTodoForm.field('title', h), h.Value(model.draft)]),
])
AgentWebMcp.register({ agent: agentRuntime, forms: [CreateTodoForm] })formTool only emits HTML attributes. When register({ forms }) sees a capture-phase submit event flagged agentInvoked, it reads form fields as text, runs the capability's decode, authorization, and dispatch pipeline, and answers via respondWith while skipping your normal OnSubmit handler (human submissions continue through OnSubmit as usual).
On browsers supporting declarative SubmitEvent.agentInvoked (AgentWebMcp.declarativeTools()), capabilities passed in forms skip duplicate imperative registration. Because HTML forms submit string values, give form-backed capabilities string fields or transforming schemas like Schema.NumberFromString. Pass { autosubmit: true } to add toolautosubmit.