diff --git a/README.md b/README.md
index ae92828..abab03b 100644
--- a/README.md
+++ b/README.md
@@ -347,13 +347,15 @@ await document.modelContext.registerTool({
Any document in the tree matching these origins (and allowed to use `tools` permission) will:
- Receive the `toolchange` event on its `document.modelContext` when the tool is registered or unregistered.
-- Be able to discover and run the tools
+- Be able to discover the tools (for cross-origin discovery, the consumer's `fromOrigins` must include the provider's origin or `"*"`), and run them subject to execution checks.
#### Discovering and running tools: `getTools()` and `executeTool()`
Once tools are registered, in-page agents can discover and invoke them using `getTools()` and `executeTool()`.
-Calling `document.modelContext.getTools()` returns a promise that resolves with an array of [`Tool`](https://webmachinelearning.github.io/webmcp/#tool) objects. Each `Tool` exposes the tool's `name`, `title`, `description`, `inputSchema`, `outputSchema`, `annotations`, `origin`, and `source` (the owner window). By default, `getTools()` only returns tools registered by documents same-origin with the caller in the frame tree. To retrieve cross-origin tools, you must explicitly list their origins in the `fromOrigins` option. This array only supports secure origins.
+Calling `document.modelContext.getTools()` returns a promise that resolves with an array of [`Tool`](https://webmachinelearning.github.io/webmcp/#tool) objects. Each `Tool` exposes the tool's `name`, `title`, `description`, `inputSchema`, `outputSchema`, `annotations`, `origin`, and `source` (the owner window). By default, `getTools()` only returns tools registered by documents same-origin with the caller in the frame tree. To retrieve cross-origin tools, you must explicitly list their origins in the `fromOrigins` option, or use `{ fromOrigins: ["*"] }` to query all origins in that tree, including opaque origins. The API's secure-context restriction still applies.
+
+In `fromOrigins`, only the exact `"*"` string is special. It does not bypass Permissions Policy or execution checks. Discovery still requires the provider's explicit `exposedTo` origin list to allow the caller. A wildcard opts into any eligible origin, not just origins trusted by the author; wildcard consumers may discover tools with untrusted descriptions. Prefer explicit origin lists when possible. Other entries are still validated even when `"*"` is present.
```js
// Discover tools exposed by same-origin frames in the tree (default)
@@ -371,9 +373,14 @@ for (const tool of tools) {
const crossOriginTools = await document.modelContext.getTools({
fromOrigins: ["https://trusted-partner.example"]
});
+
+// Discover tools exposed to the caller by frames of any origin:
+const allOriginTools = await document.modelContext.getTools({
+ fromOrigins: ["*"]
+});
```
-An agent executes a discovered `Tool` by passing it and input arguments along to `document.modelContext.executeTool()`. The browser securely mediates the execution, ensuring the [`exposedTo`](https://webmachinelearning.github.io/webmcp/#dom-modelcontextregistertooloptions-exposedto) and [`fromOrigins`](https://webmachinelearning.github.io/webmcp/#dom-modelcontextgettooloptions-fromorigins) agree, and the tool runs in the tool owner's execution context. `Tool` objects can only be obtained from `getTools()`, and each one refers to the specific tool registration it was returned for: if that tool is unregistered, executing the `Tool` fails, even if a new tool is later registered under the same name.
+An agent executes a discovered `Tool` by passing it and input arguments along to `document.modelContext.executeTool()`. The browser securely mediates the execution, checking [`exposedTo`](https://webmachinelearning.github.io/webmcp/#dom-modelcontextregistertooloptions-exposedto) again, and the tool runs in the tool owner's execution context. [`fromOrigins`](https://webmachinelearning.github.io/webmcp/#dom-modelcontextgettooloptions-fromorigins) filters discovery, not execution. `Tool` objects can only be obtained from `getTools()`, and each one refers to the specific tool registration it was returned for: if that tool is unregistered, executing the `Tool` fails, even if a new tool is later registered under the same name.
```js
const tools = await document.modelContext.getTools();
diff --git a/index.bs b/index.bs
index 95d6872..4e14754 100644
--- a/index.bs
+++ b/index.bs
@@ -175,6 +175,15 @@ An AI platform is a provider of agentic assistants such as OpenAI’s
Supporting concepts
+An origin wildcard is the [=string=] "`*`", used in
+{{ModelContextGetToolOptions/fromOrigins}} to request discovery from all origins.
+
+In {{ModelContextGetToolOptions/fromOrigins}},
+only the exact string "`*`" is an [=origin wildcard=]. All other entries are parsed and validated
+as origins, even when the array also contains an [=origin wildcard=].
+
+Issue(#317): Consider supporting {{URLPattern}} objects for more selective origin matching.
+
A model context is a [=struct=] with the following [=struct/items=]:
@@ -1066,10 +1075,18 @@ The getTools(options) method steps
1. Let |from origins| be an empty [=list=] of [=origins=].
+1. Let |includeAllOrigins| be false.
+
1. If |options|'s {{ModelContextGetToolOptions/fromOrigins}} [=map/exists=], then:
1. [=list/For each=] |origin| of |options|'s {{ModelContextGetToolOptions/fromOrigins}}:
+ 1. If |origin| is the [=origin wildcard=], then:
+
+ 1. Set |includeAllOrigins| to true.
+
+ 1. [=iteration/continue=].
+
1. Let |parsedURL| be the result of running the [=URL parser=] on |origin|.
1. If |parsedURL| is failure or its [=url/origin=] is not [$is origin potentially
@@ -1101,7 +1118,8 @@ The getTools(options) method steps
1. Let |callerOrigin| be |toolRequestor|'s [=Document/origin=].
1. Let |toolOwnerIsRequested| be true if |targetOrigin| is [=same origin=] with
- |callerOrigin|, or if |from origins| [=list/contains=] |targetOrigin|; otherwise, false.
+ |callerOrigin|, |from origins| [=list/contains=] |targetOrigin|, or |includeAllOrigins|
+ is true; otherwise, false.
1. If |toolOwnerIsRequested| is false, then [=iteration/continue=].
@@ -1472,7 +1490,9 @@ dictionary ModelContextRegisterToolOptions {
: options["{{ModelContextRegisterToolOptions/exposedTo}}"]
- :: An array of origins that control which documents this tool is exposed to, in the current document's tree.
+ :: An array of origin strings that control which documents this tool is exposed to, in the
+ current document's tree.
+ An omitted or empty array only permits same-origin access by documents.
: options["{{ModelContextRegisterToolOptions/signal}}"]
:: An {{AbortSignal}} that unregisters the tool when aborted.
@@ -1493,9 +1513,22 @@ dictionary ModelContextGetToolOptions {
: options["{{ModelContextGetToolOptions/fromOrigins}}"]
:: An array of origins from which to query tools. Documents whose origin appears in this list, or
are same-origin with the caller, have their tools queried. An empty list only includes
- same-origin documents.
+ same-origin documents. The [=origin wildcard=] queries documents regardless of their origin,
+ including [=opaque origins=], in the current document's tree.
+ Tools must still be exposed to the caller, and documents must be [=allowed to use=] the
+ "{{tools}}" feature.
+
+ Use the [=origin wildcard=] to discover tools exposed to the caller by documents of any origin
+ in the current document's tree:
+
+ ```js
+ const tools = await document.modelContext.getTools({ fromOrigins: ["*"] });
+ ```
+
+
+
ModelContextExecuteToolOptions Dictionary
The {{ModelContextExecuteToolOptions}} dictionary allows web applications to pass options to
@@ -2271,9 +2304,9 @@ operations or extract sensitive state from another [=origin=].
By default, WebMCP enforces strict [=same origin=] isolation: a tool registered via document.{{Document/modelContext}}.{{ModelContext/registerTool()}} is only
visible to and executable by {{Document}}s that are [=same origin=] with the registering
-{{Document}} (tool owner). Cross-origin {{Document}}s cannot discover, observe
-{{ModelContext/toolchange}} events for, or execute a tool unless three independent access-control
-gates are satisfied:
+{{Document}} (tool owner). Cross-origin tool discovery requires three independent access-control
+gates. Tool invocation and {{ModelContext/toolchange}} notifications require the first two gates;
+{{ModelContextGetToolOptions/fromOrigins}} filters discovery, not invocation or notifications:
-
@@ -2289,9 +2322,10 @@ gates are satisfied:
-
Tool Provider Opt-In ({{ModelContextRegisterToolOptions/exposedTo}}): A
{{Document}} registering a tool must explicitly opt in to cross-origin exposure by specifying
- the permitted caller [=origins=] in {{ModelContextRegisterToolOptions/exposedTo}}. Each listed
- [=origin=] must be a valid, [$is origin potentially trustworthy?|potentially trustworthy$]
- [=origin=]. During both discovery ({{ModelContext/getTools()}}) and invocation
+ the permitted caller [=origins=] in
+ {{ModelContextRegisterToolOptions/exposedTo}}. Each entry
+ must be a valid, [$is origin potentially trustworthy?|potentially trustworthy$] [=origin=].
+ During both discovery ({{ModelContext/getTools()}}) and invocation
({{ModelContext/executeTool()}}), the [=user agent=] evaluates the [=tool is exposed to an
origin=] algorithm, ensuring that only callers whose [=Document/origin=] is [=same origin=] with
the tool owner or explicitly listed in {{ModelContextRegisterToolOptions/exposedTo}} can access
@@ -2303,14 +2337,15 @@ gates are satisfied:
a tool to its parent [=origin=] via {{ModelContextRegisterToolOptions/exposedTo}},
{{ModelContext/getTools()}} only returns tools from [=same origin=] {{Document}}s by default. To
discover tools from a cross-origin descendant [=navigable=], the calling {{Document}} must also
- explicitly list the target [=origin=] in {{ModelContextGetToolOptions/fromOrigins}}.
+ explicitly list the target [=origin=] or the [=origin wildcard=] in
+ {{ModelContextGetToolOptions/fromOrigins}}.
-**Why Two-Sided Opt-In Matters**: Requiring mutual consent from both the tool provider
+**Why Two-Sided Opt-In Matters**: Requiring opt-in from both the tool provider
({{ModelContextRegisterToolOptions/exposedTo}}) and the tool consumer
-({{ModelContextGetToolOptions/fromOrigins}}) prevents both unauthorized cross-origin actuation and
-unsolicited tool-list pollution. Without provider opt-in
+({{ModelContextGetToolOptions/fromOrigins}}) lets each restrict the origins involved in discovery.
+Provider opt-in also protects against unauthorized cross-origin actuation. Without provider opt-in
({{ModelContextRegisterToolOptions/exposedTo}}), a malicious parent page could invoke internal tools
inside an embedded third-party widget that were intended only for [=same origin=] use. Conversely,
without consumer opt-in ({{ModelContextGetToolOptions/fromOrigins}}), a compromised or untrusted
@@ -2341,6 +2376,12 @@ await document.modelContext.registerTool(
);
```
+The [=origin wildcard=] opts into all origins in the document's tree, not only origins trusted by
+the author. Authors should prefer explicit origin lists when possible. In particular, a consumer
+using the [=origin wildcard=] accepts tools exposed to it by any eligible document in that tree.
+The provider's {{ModelContextRegisterToolOptions/exposedTo}} origin list and the "{{tools}}"
+Permissions Policy still apply.
+
Residual Risks
Even when cross-origin access is governed by the mechanisms above, two categories of residual risk
@@ -2348,7 +2389,7 @@ remain:
-
- Direct Cross-Origin Exposure: Even when two [=origins=] mutually opt in via
+ Direct Cross-Origin Exposure: Even when the provider and consumer opt in via
{{ModelContextRegisterToolOptions/exposedTo}} and {{ModelContextGetToolOptions/fromOrigins}},
they remain separate trust domains: tool providers must still treat caller-supplied arguments as
untrusted input, and callers must treat cross-origin tool descriptions and return values as
diff --git a/security-privacy-questionnaire.md b/security-privacy-questionnaire.md
index ec5cf77..9a6b778 100644
--- a/security-privacy-questionnaire.md
+++ b/security-privacy-questionnaire.md
@@ -74,6 +74,8 @@ The feature is gated by the [`"tools"`](https://webmachinelearning.github.io/web
Additionally, tools can specify [`exposedTo`](https://webmachinelearning.github.io/webmcp/#dom-modelcontextregistertooloptions-exposedto) to control which origins can discover them. Whether tool authors in cross origin iframes can explicitly control exposure to the browser's built in agent, for example through a `native-agent` keyword, is an open design question tracked under [Built-in agent exposure by default](https://github.com/webmachinelearning/webmcp/blob/main/README.md#built-in-agent-default-exposure) in the README.
+Consumers can use the origin wildcard `"*"` in [`fromOrigins`](https://webmachinelearning.github.io/webmcp/#dom-modelcontextgettooloptions-fromorigins) to query all origins in the document's tree, including opaque origins. The API is restricted to secure contexts, which can include opaque-origin documents. The wildcard does not bypass Permissions Policy or the provider's `exposedTo` origin list. A wildcard accepts any eligible origin rather than a specific trusted party; explicit origin lists are preferable when possible.
+
> 15. How do the features in this specification work in the context of a browser's Private Browsing or Incognito mode?
We do not anticipate any differences, but implementers should be aware of how to safely handle private browsing modes. See [Interaction with Private Browsing Modes](https://webmachinelearning.github.io/webmcp/#interaction-with-private-browsing).
@@ -101,7 +103,7 @@ Note: this behavior is not yet spec'd but is the intended direction.
> 20. Does your spec define when and how new kinds of errors should be raised?
-Yes. `registerTool()` throws `InvalidStateError` for inactive documents, duplicate names, or invalid name/description; `NotAllowedError` when the `"tools"` Permissions Policy is disallowed; `SecurityError` for non-trustworthy [`exposedTo`](https://webmachinelearning.github.io/webmcp/#dom-modelcontextregistertooloptions-exposedto) origins; and `TypeError` when `inputSchema` or `outputSchema` serialization fails. These errors only reflect the page's own state and inputs, so they do not leak new information.
+Yes. `registerTool()` throws `InvalidStateError` for inactive documents, duplicate names, or invalid name/description; `NotAllowedError` when the `"tools"` Permissions Policy is disallowed; `SecurityError` for invalid or non-trustworthy [`exposedTo`](https://webmachinelearning.github.io/webmcp/#dom-modelcontextregistertooloptions-exposedto) entries; and `TypeError` when `inputSchema` or `outputSchema` serialization fails. `getTools()` likewise rejects with `SecurityError` for invalid or non-trustworthy `fromOrigins` entries other than `"*"`. All non-wildcard `fromOrigins` entries are validated even when `"*"` is present. These errors only reflect the page's own state and inputs, so they do not leak new information.
> 21. Does your feature allow sites to learn about the user's use of assistive technology?