From dba83760550a1c0d4be6aca7ab439f34c2213c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Thu, 19 Mar 2026 09:33:40 +0100 Subject: [PATCH 1/2] Add ToolActivatedEvent and ToolCancelEvent interfaces --- index.bs | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/index.bs b/index.bs index e602129..f0940f7 100644 --- a/index.bs +++ b/index.bs @@ -176,9 +176,12 @@ The {{ModelContext}} interface provides methods for web applications to register [Exposed=Window, SecureContext] -interface ModelContext { +interface ModelContext : EventTarget { undefined registerTool(ModelContextTool tool); undefined unregisterTool(DOMString name); + + attribute EventHandler ontoolactivated; + attribute EventHandler ontoolcancel; }; @@ -198,6 +201,13 @@ is a [=model context=] [=struct=] created alongside the {{ModelContext}}. +
+ : ontoolactivated + :: An [=event handler IDL attribute=] for the {{ModelContext/toolactivated}} event type. + : ontoolcancel + :: An [=event handler IDL attribute=] for the {{ModelContext/toolcancel}} event type. +
+
The registerTool(tool) method steps are: @@ -353,6 +363,56 @@ The requestUserInteraction(callba
+

ToolActivatedEvent Interface

+ +The {{ToolActivatedEvent}} interface represents a toolactivated event that is dispatched at {{Navigator/modelContext}} when a tool is invoked by an [=agent=]. + + +[Exposed=Window, SecureContext] +interface ToolActivatedEvent : Event { + constructor(DOMString type, optional ToolActivatedEventInit eventInitDict = {}); + readonly attribute DOMString toolName; + readonly attribute Element? element; +}; + +dictionary ToolActivatedEventInit : EventInit { + DOMString toolName = ""; + Element? element = null; +}; + + +
+ : toolName + :: Returns the name of the tool that was activated. + : element + :: Returns the form element associated with the tool, if any. +
+ +

ToolCancelEvent Interface

+ +The {{ToolCancelEvent}} interface represents a toolcancel event that is dispatched at {{Navigator/modelContext}} when a tool's invocation is canceled by an [=agent=]. + + +[Exposed=Window, SecureContext] +interface ToolCancelEvent : Event { + constructor(DOMString type, optional ToolCancelEventInit eventInitDict = {}); + readonly attribute DOMString toolName; + readonly attribute Element? element; +}; + +dictionary ToolCancelEventInit : EventInit { + DOMString toolName = ""; + Element? element = null; +}; + + +
+ : toolName + :: Returns the name of the tool that was canceled. + : element + :: Returns the form element associated with the tool, if any. +
+

Declarative WebMCP

This section is entirely a TODO. For now, refer to the [explainer draft](https://github.com/webmachinelearning/webmcp/pull/76). From 9f30276fa4cbdf3a74a4ece07aabcc0fba242898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Wed, 27 May 2026 08:43:20 +0200 Subject: [PATCH 2/2] Rebase --- index.bs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/index.bs b/index.bs index 729bd0c..bb715a1 100644 --- a/index.bs +++ b/index.bs @@ -352,13 +352,6 @@ is a [=model context=] [=struct=] created alongside the {{ModelContext}}. -
- : ontoolactivated - :: An [=event handler IDL attribute=] for the {{ModelContext/toolactivated}} event type. - : ontoolcancel - :: An [=event handler IDL attribute=] for the {{ModelContext/toolcancel}} event type. -
-
The registerTool(tool, options) method steps are: @@ -600,7 +593,7 @@ The requestUserInteraction(callba

ToolActivatedEvent Interface

-The {{ToolActivatedEvent}} interface represents a toolactivated event that is dispatched at {{Navigator/modelContext}} when a tool is invoked by an [=agent=]. +The {{ToolActivatedEvent}} interface represents a {{ModelContext/toolactivated}} event that is dispatched at {{ModelContext}} when a tool is invoked by an [=agent=]. [Exposed=Window, SecureContext] @@ -625,7 +618,7 @@ dictionary ToolActivatedEventInit : EventInit { <h4 id="tool-cancel-event">ToolCancelEvent Interface</h4> -The {{ToolCancelEvent}} interface represents a <dfn event for=ModelContext>toolcancel</dfn> event that is dispatched at {{Navigator/modelContext}} when a tool's invocation is canceled by an [=agent=]. +The {{ToolCancelEvent}} interface represents a {{ModelContext/toolcancel}} event that is dispatched at {{ModelContext}} when a tool's invocation is canceled by an [=agent=]. <xmp class="idl"> [Exposed=Window, SecureContext] @@ -690,6 +683,12 @@ that must be supported, as [=event handler IDL attributes=], by all {{ModelConte <tr> <td><dfn attribute for="ModelContext">ontoolchange</dfn> <td><dfn event for="ModelContext">toolchange</dfn> + <tr> + <td><dfn attribute for="ModelContext">ontoolactivated</dfn> + <td><dfn event for="ModelContext">toolactivated</dfn> + <tr> + <td><dfn attribute for="ModelContext">ontoolcancel</dfn> + <td><dfn event for="ModelContext">toolcancel</dfn> </table> <h3 id="permissions-policy">Permissions policy integration</h3>