AgentWebMcp.declarativeTools
function · packages/agent-webmcp/src/forms.ts:92
function declarativeTools(): booleanWhether this browser draws forms as tools: its SubmitEvent says when an agent submitted.
Agent / foldkit-agent-webmcp
namespace · packages/agent-webmcp/src/agentWebMcp.ts:1
export * as AgentWebMcp from './agentWebMcp.js'AgentWebMcp.declarativeToolsfunction · packages/agent-webmcp/src/forms.ts:92
function declarativeTools(): booleanWhether this browser draws forms as tools: its SubmitEvent says when an agent submitted.
AgentWebMcp.FormToolinterface · packages/agent-webmcp/src/forms.ts:12
interface FormTool<Name extends string = string, Input = unknown> {
readonly name: Name
readonly form: <Message>(
h: HtmlBuilder<Message>,
) => ReadonlyArray<Attribute<Message>>
readonly field: <Message>(
key: keyof Input & string,
h: HtmlBuilder<Message>,
) => ReadonlyArray<Attribute<Message>>
readonly keys: ReadonlyArray<string>
}One capability drawn as a WebMCP declarative tool: a form whose toolname
and tooldescription, and whose fields' name and toolparamdescription,
come from the agent contract, so the form and the registered tool cannot
disagree. register({ forms }) answers its agent submissions.
AgentWebMcp.formToolfunction · packages/agent-webmcp/src/forms.ts:43
function formTool<
ByName extends Record<string, unknown>,
const Name extends keyof ByName & string,
>(
definition: Agent.Definition<any, any, any, ByName, any>,
name: Name,
options?: {
readonly autosubmit?: boolean
},
): FormTool<Name, ByName[Name]>Draws the capability name of an agent contract as a declarative tool: see
the README's "Forms as declarative tools". It throws for a name the contract
does not expose, or whose input is not an object of fields, which no form
could fill.
AgentWebMcp.pageModelContextfunction · packages/agent-webmcp/src/webmcp.ts:53
function pageModelContext(): ModelContext | undefinedThe page's model context, when it has one: document.modelContext, where
the spec puts it, or else navigator.modelContext, the name Chromium used
before 150 and agent extensions that provide WebMCP still use. Undefined on
a server, or in a browser with neither.
AgentWebMcp.registerfunction · packages/agent-webmcp/src/register.ts:62
function register<Model, Context_, Principal, ByName, ByTag>(
options: RegisterOptions<Model, Context_, Principal, ByName, ByTag>,
): RegistrationProjects an agent contract into document.modelContext.registerTool(...).
Each currently available capability becomes one tool: the capability name
becomes the tool name, the variant description becomes the description, the
derived JSON Schema becomes inputSchema, and execute validates its input
and dispatches into the same live Foldkit Runtime the human is using.
Tool availability is itself a projection of Model state. When
available(model) changes, registrations are reconciled: capabilities that
are gone have their registration signal aborted, and capabilities that have
appeared are registered.
const registration = AgentWebMcp.register({ agent: agentRuntime })AgentWebMcp.RegisterOptionsinterface · packages/agent-webmcp/src/register.ts:16
interface RegisterOptions<Model, Context_, Principal, ByName, ByTag> {
readonly agent: Agent.AgentRuntime<Model, Context_, Principal, ByName, ByTag>
readonly modelContext?: ModelContext | undefined
readonly signal?: AbortSignal | undefined
readonly followModel?: boolean | undefined
readonly invocationId?: (() => string) | undefined
readonly onError?: ((error: unknown) => void) | undefined
readonly forms?: ReadonlyArray<FormTool<keyof ByName & string>> | undefined
}AgentWebMcp.Registrationinterface · packages/agent-webmcp/src/register.ts:7
interface Registration {
readonly refresh: () => Promise<void>
readonly unregister: () => void
readonly registered: () => ReadonlyArray<string>
}A live WebMCP registration.