Repository navigation
Description
Unlike many MCP servers, where the available tool set is relatively stable for the lifetime of the server, WebMCP tools may change frequently as the user moves through a site:
- Framework components mount and unmount
- Async hydration completes after the page's
loadevent - SPA navigations / route changes
- Full-on MPA navigations
- Changes in UI state that usher in new tools and unregister irrelevant ones
In our experience, agents operating web pages generally have a heuristic for deciding when a page has "loaded" or "settled" enough to create a page observation for the model, including the page's list of WebMCP tool.
The problem is that registration of all of a site's relevant tools might not be synchronized with the agent's page-stability heuristic. A page may "look ready" to the agent while an important batch of tools is still being registered, and an observation might then end up with a partial view of relevant tools designed for it.
Based on how we've seen agents being built, we anticipate this will be an issue, but we'd love feedback from other real-world browser-use agents to know if this problem statement resonates. We'd love to get a signal from at least the following folks:
- @bwalderman for Copilot-in-Edge
- @justinrushing + @nmccormack-oai for ChatGPT/OAI
- @ekolve-ant + @jtang-ant
Does your experience with browser agents resonate with the issue described above, whether related to WebMCP or beyond it? Would your agents benefit from letting developers provide input to existing page/tool stability heuristics?
We propose an API to let developers signal to any listening agents:
"My currently registered tools are still in flux. If you are about to take an initial or refreshed observation of my tools, please wait until I signal that this transition is complete."
We don't intend to standardize how page observations are taken. This is just about giving developers a way to provide a signal that agents can incorporate in their observation heuristics.
Example problem
Consider a page whose initial HTML becomes interactive before its WebMCP-specific code finishes loading:
// The page may already appear "loaded" or "settled" to an agent.
await import("./webmcp-tools.js");
document.modelContext.registerTool({
name: "search_products",
// ...
});
document.modelContext.registerTool({
name: "issue_refund",
// ...
});
document.modelContext.registerTool({
name: "add_review",
// ...
});If the agent decides to observe the page between page readiness and completion of these registrations, the model may see only a partial tool set.
A similar issue can occur during SPA navigations, where a route transition causes one group of tools to disappear and another group to be registered asynchronously.
Strawman API proposal
One possible shape is an explicit begin/end signal:
const stability = document.modelContext.beginToolUpdate();
try {
const tools = await import("./webmcp-tools.js");
await tools.register();
} finally {
stability.end();
}While the tool-update scope is active, the page is indicating that its registered tool set should not yet be considered stable. The API could be nestable so that independent components can participate without coordinating through a single global promise:
const a = document.modelContext.beginToolUpdate();
const b = document.modelContext.beginToolUpdate();
a.end();
// Tool set is still unstable.
b.end();
// Tool set is now stable.The browser should impose an upper bound on how long an outstanding stability signal can delay an observation, and agents will likely need their own preotections regardless. Both of these mreasures prevent a broken (or misbehaving) page from indefinitely blocking an agent.
(Disclaimer: the exact shape of the API above are only illustrative and are very up for debate).
SPA and dynamic transitions
One of the most common use cases for this API would be during SPA navigations, which are common on the web, and where agent page stability heuristics are likely to vary a lot:
async function navigate(path) {
const update = document.modelContext.beginToolUpdate();
try {
await router.navigate(path);
await registerToolsForRoute(path);
} finally {
update.end();
}
}Initial page load
To signal tool instability on initial page load, I think we have two options:
- Force developers to call
beginToolUpdate()super early, in<head>JavaScript for example; or - Provide a declarative,
<meta>tag way to load a page with an immediate signal of tool instability, and make developers signal the end of that imperatively with JS
<meta name="tool-stability" content="pending">
<script>
await App.slowHydration(); // Loads lots of tools asynchronously.
document.modelContext.toolsAreStable();
</script>Alternatives considered: "tool snapshot requested" event
Another possible design is for the browser to fire an event immediately before it intends to observe tools:
[SecureContext, Exposed=Window]
interface ToolObservationEvent : Event {
undefined waitUntil(Promise<any> promise);
};
partial interface ModelContext {
attribute EventHandler ontoolobservation;
};A page could then delay the agent's observation with waitUntil(). This is attractive because it directly synchronizes the page with an observation attempt. But it assumes that agents have a discrete "tool snapshot" step that the browser can expose, and achieves the same thing as our above proposal, while unnecessarily exposing implementation details of the agent. It also gets confusing to developers when there are multiple agents driving a page.
The developer would likely use this API like this:
window.toolsAreStable = true;
async function loadMoreTools() {
window.toolsAreStable = false;
// Load more tools
// ...
window.toolsAreStable = true;
}
document.modelContext.ontoolsnapshotrequested = e => {
if (!window.toolsAreStable) {
e.waitUntil(/*some promise*/);
}
// Otherwise, do nothing.
}In this case, the developer isn't interested in knowing when the agent is grabbing the list of tools, or how many agents are grabbing the list of tools. Instead, they're maintaining their own tool stability bookkeeping that simple gets surfaced to the agent through the event, making the event unimportant in the exchange.
Relationship to toolchange
Agents can still react incrementally to toolchange throughout the lifetime of the document, but since we've observed that an agent's heavy "page snapshot" / "page observation" infrastructure is unlikely to take place on every toolchange event, we still wind up with the page observation gap that motivates this issue.
Activity
sjdallst2 commentedon Oct 1, 2026
@domfarolino, for future communications, @bwalderman is working on multiple projects, and I am now the main point of contact for WebMCP dev at Microsoft.
I like the idea of the proposal. Judging from the code we have, there is a clear information issue where we do not know when tools are available, and we have to guess when a page will be ready. And, like you said, page snapshots can be heavy.
I like the idea of keeping everything within the websites control instead of the proposal where the agent sends an event that the page must respond to.
Have you thought about having the modelContext be unstable by default (no declaration necessary), then adding something like an isFinal parameter for ModelContextRegisterToolOptions, or would that be confusing?
dhrumil83 commentedon Oct 1, 2026
One use case for this is progressive disclosure of tools through skills.
For example, a page supports three skills and 20 tools across those skills. Initially, it exposes only a load_skill tool, with the three available skills as options.
When the external agent loads a skill, the page returns its instructions and registers the eight tools needed for that workflow. The external agent then orchestrates those tools using its own model.
A tool-stability signal would help the external agent know when all the skill’s tools are registered and ready to use.
khushalsagar commentedon Oct 13, 2026
+1 to the idea here. Digging into the details:
On the tool provider side, I agree it would be nice to allow different components to manage the delay for their own registration instead of a global hook. I like a promise based API instead of multiple begin/end APIs. Each component can call the API with their own promise and tools are in "not ready" state if there's any unresolved promises.
We might want to add a
toolsReadyboolean on modelContext for convenience so authors can read this state. Naming is tricky becausemodelContext.getToolstechnically provides tools from multiple frames and we can't synchronously provide this state for other frames. MaybeselfToolsReadyorlocalToolsReady?For the initial page load case, this reminded me of the render blocking. The idea there was that the browser needed a signal to know when the page is ready to render for a human user and this is the same concept except for an agent. We expected other blocking cases to be added when the concept was introduced.
We can start with keeping a Document in "new-page-loading-tools" until the body element is parsed. Observations are guaranteed to be blocked until then. After that, an observation is blocked based on whether there's any unresolved promises from
waitForToolsUntil. This means authors need to use this API in a script inhead.Going forward, we can add a
toolsormodelContextkeyword to theblockingattribute so async scripts can be used to register tools:The user agent can timeout and take an observation even if the tools aren't ready (render-blocking does it too). I wasn't sure how much control non built-in tool consumers should have in configuring this timeout. Something like this, we can probably punt on this for now.
Tool consumers should have a way to at least know that the tools are incomplete. We don't have a good hook for this in the API right now.
getToolsreturns a list of tools so we can't provide any metadata about the tool set itself. Since this state would be per window, maybe we could change the return type to the following and move window out of Registered Tool?Or future proof it further with a wrapper struct that has a
sequence<WindowToolGroup>so metadata about the complete observation can be added later.domfarolino commentedon Oct 13, 2026
I think we'll be moving
document.modelContext=>window.modelContextin service of #236 (see https://docs.google.com/document/d/1b2OfZcP2oEZ9JZi-DWN26VPCflNYSpue7-N76PxMAjQ/edit?tab=t.0#heading=h.7r7ujkqj2bm8) so I thinktoolsReadyis nice.I suppose this makes sense, but the choice of unblocking observations after the
<body>element feels a bit arbitrary. It requires developers to put promise-supplying script in<head>which is maybe good enough, but I'd be slightly worried about choosing<body>just because render blocking does. Render blocking understandably does because<head>does not render, while<body>does. But that distinction doesn't really mean anything for agents, right?Agreed. That's probably close to the shape we might want to do if we had to, but for now IMO we should leave that bit out and see if it's needed later. We can always add it.
One alternative, given the fact that we're probably moving
modelContextover towindow, or something like that, would be to makemodelContext.toolsReadybe a method that returns aPromise<bool>that can be called on other window proxies. Thoughts?khushalsagar commentedon Oct 14, 2026
\o/
Fundamentally, we need to choose some point in the document lifecycle by when the author must signal whether observations should be blocked on tools. Delaying after
body(on something likedomContentLoaded) would unnecessarily block longer on pages which may not even have tools. The render blocking precedence also helps in that authors already set up relevant scripts (like A/B testing) to run before rendering is unblocked. Open to other ideas!A
ontoolreadystatechangedevent onwindowseems better. I skimmed through this. Assuming you're leaning towards option 2, other similar events likeontoolchangewill also move towindow? we can fire it with the current state the first time a handler is registered?khushalsagar commentedon Oct 14, 2026
Splitting the aspects of this issue so we can take them as separate resolutions:
Tools ready state on Document
Document has a
tools-readyboolean to indicate that its registered tools are complete. Authors use the API below to control that state.If there's any unresolved promises,
tools-readyis false. How that influences the requests to read tools should be defined for each algorithm.Initial page load
When a new Document commits,
tools-readystarts as false. We need a point in the Document's lifecycle where it toggles to true if there are no unresolved promises. I propose that this should happen when thebodyelement is parsed, so authors can reliably use script inheadto use the API above.getTools Delay
Script can call this method at any point. We'd likely need hooks to let tool consumers know when tools are ready or decide how long this call can block for tools to become ready. But let's pick a reasonable default: the user agent blocks this call for an implementation-defined timeout if
tools-readyis false on any Document.Actually, maybe we shouldn't block reading tools from your own Document on
tools-readybeing true since its easy to get into a deadlock in that scenario? It's also not helpful since if you have access to the Document you can technically synchronously read this state.Page Observation Delay
When the user agent makes a request to read the tool map via an Observation, it waits for an implementation-defined timeout if
tools-readyis false on any Document.Punting on the hooks for 3) for now.
markafoltz commentedon Oct 15, 2026
Valid transitions:
kLoading=>kWaitingif there is a pending Promise on load or async blocking scriptkLoading=>kReadyif no pending Promise on load / async blocking scriptkWaiting=>kReadyif Promise settlesYou could make this assignable as the signaling mechanism, instead of registering a Promise. But most developers will just trigger
kWaiting=>kReadyvia a Promise anyway, and there are invalid state transitions, so not really an improvement from an API ergonomics point of view.If there are multiple sets of tools per document, it should be possible to register a new Promise if the previous Promise has settled to signal a transition back into the
kWaitingstate. However, it should not delay an already-scheduled observation resulting from an existing Promise (settled or not).As a corollary to 2, pages can now signal re-observation an arbitrary number of times. Implementations may choose to cap this or have some backoff.
Should we allow replacing an unsettled Promise with a different Promise? In principle I don't see an issue.
Should we allow
document.modelContext.waitForToolsUntil(null)to cancel a unsettled Promise registration?khushalsagar commentedon Oct 15, 2026
kLoadingandkWaitingstate into thetoolsReady = false. Wasn't sure if its worth distinguishing these but not opposed to it.kReady=>kWaitingis also a valid transition (for SPAs in particular).Each time you call
waitForToolsUntil, the promise gets added to a set and the presence of unresolved promises does a transition tokWaiting. So that should work in the proposal.This is a good subtlety to clarify. I am expecting the algorithm to go:
a. When an observation is requested by the user-agent or
getToolsis called, check the ready state. If ready, schedule an observation.b. If not, start a timer and schedule an observation if a timeout occurs or the ready state toggles to true.
So an already-scheduled observation isn't further delayed if a new promise is added once the timer has started. Does that align with what you had in mind?
Didn't follow this.
If its a per-promise replace or clear then the author can just resolve that promise and set a new one. So doesn't seem that advantageous to me. But I could see the use-case for a
forceToolsReady()API to clear all promises, for a site driven global timeout.Eh maybe you're misunderstanding the API shape I'm proposing.
waitForToolsUntildoesn't track a single promise but a set of promises. So passing null doesn't mean anything.kenchris commentedon Oct 20, 2026
From the extension side, two things about the
toolsReadydirection, which we'd use.The wait in 3 and 4 (reading the tools waits for ready, with a timeout) needs to apply to extension callers too, and not only to the browser's own observation. We don't run inside the page, and today we re-list a tab's tools before every model turn because
toolchangeonly fires in the page, so a tool registered late can be missed in between. Two things would help us: the same wait when an extension reads a tab's tools, and a way to tell whether the list we got is complete or was returned because the timeout ran out. Otherwise a partial list looks the same as a finished one, and we would act on it.The other reason a settled tool list matters is prompt caching. The tool list sits at the start of the prompt, and serving stacks only reuse work for the longest identical start, so every change to the list means everything after it is computed again. A signal lets the host take one snapshot of the list per turn once it has settled, instead of seeing the set half registered, which is a real difference in cost. I wrote up how hosts avoid this with lazy loading, and what it needs from WebMCP, in #357.
markafoltz commentedon Oct 20, 2026
Following up on the comment above. I didn't gather that the API allows the registration of multiple promises, so some of my questions/suggestions were irrelevant - sorry about that!
The only advantage might be the developer would be able to tell if they are calling
waitForToolsUntilearly enough, in thekLoadingstate, to delay the first observation. I don't feel too strongly about this - there is probably a document lifecycle hook that they can use instead.Sounds good.
Sorry if I wasn't clear. I was wondering if we care whether pages can toggle the
toolsReadystate an arbitrary number of times, and whether that forces an observation even when it might be unnecessary or unused. So, suggesting a note that toggling the state does not guarantee a new observation.khushalsagar commentedon Oct 21, 2026
Makes sense. This is worth a note in the spec.
khushalsagar commentedon Oct 27, 2026
Hallway discussion right after with liad and jake:
The API is sufficient for async scripts with something like this.
Still an open question on what lifecycle state to wait for, top contenders are body parsed or domContentLoaded.
10 remaining items
DenisovAV commentedon Nov 24, 2026
Agent feedback request noted, here's a site-side data point for the SPA case.
We run three stores on one origin, split by path, each with its own tool set (3–4 tools bridged from a remote MCP server). Switching stores via client-side routing means aborting one set (AbortSignal) and registering the next asynchronously, because the new set comes from the server. We could not confirm that an agent mid-task would observe the new set rather than a partial or stale one, so we force a full page load on every store switch.
A
tools-readystate that we can hold false across the route transition (waitForToolsUntil()with the fetch-and-register promise) would cover exactly this and let us keep client-side navigation. It would also help if agents were expected to re-observe after a ready transition that follows a toolchange, not only on initial load.frostyhand commentedon Nov 26, 2026
Answering @beaufortfrancois's question from the preview list with data from sites that already ship WebMCP.
My Agentic Web Census finds WebMCP on 4 home pages in the Tranco top 10k. I fetched each one today and looked at where the registration code actually runs:
<head><head><head>; a Nuxt module bundle later aborts those tools and registers a fuller set<script type="module">in<head>(Astro); re-registers onastro:page-load<script type="module">in<body>; registers afterawait import(...)waitForToolsUntil()before its firstawaitWith the
<head>cutoff, 2 of the 4 would need a new classic inline stub (thePromise.withResolvers()pattern from the hallway discussion) just to hold agents. Both are module scripts emitted by their build setup (Astro and Vite). A module script placed in<head>looks like it meets a "script must be in the head" rule but runs too late, and I expect authors to hit that often. Neither site needs a change with DOMContentLoaded.So I prefer DOMContentLoaded. Two things I'd add if the group goes that way:
await. In Chrome, a body module that awaits logsbody module start | DCL | body module after await. Cookiebot's pattern (await import(), then register) would miss the cutoff unless it callswaitForToolsUntil()before the firstawait. That deserves a sentence in the spec note and in the developer docs.<head>cutoff to spare those pages the wait, I thinkblocking="modelContext"from @khushalsagar's earlier comment needs to ship at the same time, so module and deferred scripts have a way in. Without it, the most common modern setup misses the cutoff silently.The SPA case looks fine either way. Cloudflare already aborts on
astro:before-swapand re-registers onastro:page-load, which maps directly onto theonRouteChangeexample. Wrapping that re-registration inwaitForToolsUntil()is also what closes the gap @DenisovAV described.Caveats: home pages only, 4 sites, minified code read by hand. Once Chrome 160 is out I can add a census check for where
waitForToolsUntil()is called (classic in head, module in head, module in body) so the group can see which placements authors actually use.BullRulez commentedon Nov 26, 2026
DOMContentLoaded is the better cutoff.
Three practical reasons from shipping modern web apps:
type="module" and defer are the default. Vite, Next.js, and standard ESM builds emit deferred module scripts—and many MPAs still load scripts at the bottom of . Cutting off at forces developers to either add a render-blocking script in (hurting FCP/LCP) or inline a bootstrap stub just to call waitForToolsUntil(), which breaks under strict CSP (script-src without 'unsafe-inline').
Tool availability often depends on DOM/hydration state. Even in an MPA, deciding which tools to register frequently depends on reading serialized state or container elements in the body. Putting that logic inside isn't realistic without splitting registration into two places, which invites race conditions where agents silently miss tools.
Minimal latency penalty vs. load. DOMContentLoaded already avoids waiting on images, fonts, and third-party subresources, so agents aren't stalled—and any page that genuinely wants to register earlier still can.
If you want a fast path for pages with no tools or early tools, keeping the cutoff at DOMContentLoaded while letting pages optionally signal early readiness (e.g., an already-settled promise or declarative hint) gives the best of both worlds without breaking standard ESM bundling.
aeroxy commentedon Nov 26, 2026
Prefer DOMContentLoaded, with an angle not yet in the thread: pages written by an LLM from a template.
I run an app builder where a model writes each page as one HTML file from a skill's template. The template declares
in the body and registers the other tools from an inline classic script right after it. With a head cutoff, every such page needs a head stub whose only job is to hold agents. A page that misses the cutoff fails silently: the agent reads a partial list and nothing errors. I can fix our template, but not pages that are already published or written by hand. With DOMContentLoaded the template works unchanged. The one pitfall, a module that awaits before calling waitForToolsUntil(), takes a sentence of docs, as @frostyhand wrote.On point 3, I also read tools from page-world code: an extension's MAIN-world script, and a same-origin host reading an embedded app's document.modelContext. #373 leaves getTools() unwired, so that code can't tell a complete list from one cut off by the timeout. +1 to @kenchris. A read-only ready flag would be enough.
DanCanadian commentedon Nov 26, 2026
I favor
DOMContentLoadedfor the initial cutoff. One case worth testing is a serial registration queue where the set of tools is itself asynchronous. If the first two registrations finish while a feature decision is pending, waiting for the queue's current tail can still give the observer a plausible but incomplete list.I built a framework-neutral fixture with two baseline tools and a third selected asynchronously. I ran its scripts in Node with an explicitly modeled document lifecycle and observer:
These counts describe the model. Native Chrome 160 agent observations and timeout behavior still need a browser test.
For authors, I'd document passing a pending promise during the synchronous part of a deferred script or module, before awaiting hydration, configuration, or imports. That promise should cover selection and completion of the final registrations. A parser-executed head bootstrap can do the same under either cutoff. Feature-detecting the readiness method lets older browsers continue along the same registration path.
For a same-document navigation, I'd submit a fresh promise when the transition starts, before aborting the previous registrations. A regression test could start a second navigation while the first one's configuration is pending, then resolve the stale request last and inspect the tools available to an observing agent.
Could the browser tests pin down two boundaries explicitly: whether a call inside a
DOMContentLoadedlistener can still affect the first observation, and what an observer receives when the readiness deadline expires between the baseline and optional registrations?beaufortfrancois commentedon Nov 27, 2026
Posting on behalf of Francisco Angulo de Lafuente (ORCID 0009-0001-1634-7063), who sent this feedback by email after the preview-list announcement. He can't comment here directly right now. He works on EnigmAgent and PayPal Agentic Guardrail, which both keep three things separate: discovering operations, authorizing them, and running them through a broker.
1. Initial-load cutoff
He supports DOMContentLoaded. This builds on the module and deferred-script points @frostyhand raised above. He suggests:
waitForToolsUntil()) from the deadline for finishing that work.awaitor other async work that might run past the cutoff.He agrees the
<head>cutoff has a real latency advantage on some pages. He hasn't measured timing to compare the two.2. Relevance to broker-based tools
PayPal Agentic Guardrail exposes
list_payment_operationsandrun_payment_operation, and its policy-enforcing broker does the actual execution. EnigmAgent exposes named broker operations through MCP. For a possible WebMCP adapter, a readiness signal would help with discovery. But a tool being registered successfully must stay separate from authorizing it when it runs: "ready" shouldn't suggest "authorized."Francisco isn't claiming credit for lifecycle proposals already discussed here. Please credit him if any of this wording is used.
jagreehal commentedon Nov 27, 2026
A data point from the library side, measured in Chrome Canary 160 with
WebMCPTestingenabled. I maintain webmcpable, a small library overregisterTool. I logged whenDOMContentLoadedfired and when tools registered on two of its example pages:registerTooluseEffectDOMContentLoadedcustomElements.whenDefined()before registeringDOMContentLoadedBoth miss a
<head>cutoff, and both missDOMContentLoadedtoo. React renders and runs effects in a later task, so registration lands after the event. The library callswaitForToolsUntil()at the start of each registration pass, but that call itself comes too late to hold the first observation. This is the same problem as a module's top-levelawait, noted above, but authors don't write theawaitthemselves: the framework adds it.So framework apps need a classic inline stub under either cutoff. webmcpable now ships one as a string to inline in
<head>, and its first registration pass resolves it:With the stub, the React page logs: hold opened,
DOMContentLoaded, tools registered, hold settled.What I'd take from this:
DOMContentLoadedis still the better cutoff. It covers plain module and deferred scripts with no stub.type="module"script in<head>runs after parsing, so it looks right and still misses.blocking="modelContext"on an external script, or a declarative opt-in in markup, would let framework apps hold agents without inline script.DenisovAV commentedon Nov 27, 2026
Data point, Chrome 160: our tools come from a
tools/listfetch in a module script. At DOMContentLoadedgetTools()is empty in every run; tools land 120–500 ms later,<head>or<body>alike. So a<head>cutoff misses us; DOMContentLoaded works withwaitForToolsUntil()called before the firstawait.hyik007 commentedon Nov 27, 2026
Strong vote for
DOMContentLoadedas the cutoff.In real-world static/vanilla apps (for example, we just wired
document.modelContext.registerTool+waitForToolsUntil(Promise.allSettled(...))into MemBridge), tool registration depends on app state/DOM bindings initialized by scripts placed at the end of<body>or loaded withdefer/type="module".Requiring a
<head>-only script forces authors either to split tool registration away from the application bootstrap or to add an artificial inline stub in<head>just to callwaitForToolsUntil()before the actual module executes. Waiting untilDOMContentLoadedkeepsdeferand<script type="module">working naturally without incurring the slowloadevent wait.johnrippy1980 commentedon Nov 27, 2026
Prefer DOMContentLoaded. Adding a WordPress data point, which the thread hasn't covered yet.
We run a WordPress plugin on 13 small-business sites that turns their existing contact and quote forms into declarative tools. The forms come from the theme or a form builder (Elementor, WPForms, Gravity Forms), so the plugin can't put
toolnamein the markup. Its script addstoolnameandtooldescriptionat DOMContentLoaded and loads at the end of<body>. On the sites I checked today, no served form carriestoolname; the attributes only exist after the script runs.<head>on every site, or a render-blocking script.waitForToolsUntil()before the event and settles it once the forms are annotated.One trap that applies to either cutoff: WordPress performance plugins with a "delay JavaScript until user interaction" setting (WP Rocket, LiteSpeed Cache, NitroPack) hold scripts until the first scroll, click or keypress. An agent does none of those, so a delayed tool script never runs,
waitForToolsUntil()is never called, and the agent sees no tools with no signal as to why. We hit this on a live site (NitroPack) and now exclude our script from those optimizers. A note for CMS and optimizer authors in the spec or the developer docs would save others the same debugging.andreibesleaga commentedon Nov 28, 2026
A data point from an extension, in support of what @kenchris and @aeroxy wrote about
getTools().WebAIAssist (I maintain with AI) reads a page's tools from a page-world script that it adds when the user opens the side panel, usually long after load. The initial cutoff does not reach it. It gets whatever
getTools()returns at that moment.In Chrome 157 the first list of a test page came back empty, because the page registered its tools a moment later. The first fix was a guess: when the list is empty, list again after 1 s and after 3 s (code). A list with two of three tools is not empty, so it gets no second look, and the model plans without the third tool until a
toolchangearrives.A readable
tools-readystate, or thereadyboolean ontoolchange, would replace both timers with one wait. (not tried on Chrome 160 yet).SeCuReDmE-main-dev commentedon Nov 28, 2026
Another production data point in favor of
DOMContentLoaded, from a static Astro MPA running under a strict CSP (https://formation.dev.securedme.ca— 27 static pages, a single-source catalog of 49 implemented tools, 39 of which are also served via JSON-RPC/mcp, scoped to 5–12 active tools per page state, with the Origin Trial active).Building on @frostyhand's Astro ESM observation and @jagreehal's CSP note:
1. Reading page state from
<body>underscript-src 'self'(no'unsafe-inline')Each compiled page declares its tool state on
<body data-webmcp-state="...">(home,beta,legal,composer:edit, etc.), and the shared layout emits an external<script type="module" src="/_astro/...">.With an end-of-
<head>cutoff, we miss the window for two reasons at once:<script type="module">is deferred until parsing completes.<head>,<body data-webmcp-state>has not been parsed yet.Adding a classic inline stub in
<head>to hold a deferred promise conflicts with our strictscript-src 'self'CSP (forcing per-build script hashes just for the workaround). WithDOMContentLoaded, the external module readsdocument.body.dataset.webmcpStateand callswaitForToolsUntil(Promise.allSettled(...))synchronously before its firstawait, with zero inline scripts.2. Mid-task state transitions triggered inside a tool's
execute()(re: @dhrumil83 & @DanCanadian)Our
/betapage implements the progressive-disclosure pattern @dhrumil83 described: it loads read-only (5 tools, including adescribe_page_skillsdoor-handle). When an agent invokesdescribe_page_skills, the tool transitions the page tobeta:apply(6 tools, exposing the submission tool withconsequentialHint: true). Our multi-tab editor does the same acrosscomposer:edit→composer:structure→composer:review.On each transition we abort the previous
AbortControllerand synchronously pass aPromise.allSettled(...)promise (with error handling contained inside.then()so a single rejected tool never releaseswaitForToolsUntil()prematurely or drops the otherN - 1tools):One edge case worth pinning down in the spec: when an existing tool's
execute()triggersabort()+waitForToolsUntil(nextBatch)before returning its result to the agent, it would help to state explicitly that the agent's next observation (andgetTools()when wired) waits for that new promise to settle, so the model never observes an intermediate empty/partial tool list betweenabort()and re-registration.— Jean-Sébastien Beaulieu (https://orcid.org/0009-0007-2904-0443)
Pacamaraprogress commentedon Nov 28, 2026
Another WordPress data point, this time for imperative tools (the one above covers declarative forms), in favour of DOMContentLoaded.
We run small plugins on five production WordPress sites, 7 to 15 imperative tools each. Each plugin prints one inline script at the end of
<body>(wp_footer, where WordPress plugins normally print scripts): the config, and a loader that injects the tools file only whendocument.modelContextexists, afterloadplusrequestIdleCallback(2 s timeout). Browsers without WebMCP download nothing, and the tools file never competes with the page's own content.Measured on three of the sites (Chrome 158, desktop, cold profile, third-party requests blocked, so real visits are slower):
Without a call, an agent that reads the tools at either cutoff finds none on all three.
What the plugins do now (live on all five since 28 Nov, behind feature detection, tested with a stand-in method because our Chrome does not have it yet): the footer loader calls
waitForToolsUntil()while the document is still loading, with a promise whose resolver it leaves on the config object. The tools file takes the resolver and resolves it afterPromise.allSettled()over itsregisterTool()promises, including one tool that registers after a fetch. The injected script'sloadanderrorevents resolve it if the file never takes it over (a 404, an old cached file). This works with a DOMContentLoaded cutoff and needs nothing in<head>.Why an end-of-
<head>cutoff is harder here:<head>. For a plugin that means a second inline script inwp_head, only to call the method and keep the resolver, and that script then has to be kept away from the optimisation plugins that defer, combine, delay or move scripts.<head>spends the body parse and the whole load on that timer before the tools file is even requested. With Chrome's 10 seconds, a slow phone on a page with heavy third-party scripts could run out before the tools arrive. A DOMContentLoaded cutoff leaves more of the budget for the tools themselves.Questions:
InvalidStateError, say) or warned in the console, a page could find out in testing that it calls too late. This is close to DanCanadian's question about a call inside aDOMContentLoadedlistener.toolchange? The spec's note says that toggling tools ready does not by itself cause an observation.beaufortfrancois commentedon Nov 30, 2026
Thinking out loud, a
readyread-onlytoolManagerproperty that would return a promise with tools oncewaitForToolsUntilresolves could also be useful from an extension/3rd party perspective.frostyhand commentedon Nov 30, 2026
+1. This is the read side that @kenchris, @aeroxy and @andreibesleaga asked for, and it would let extensions drop their relist timers.
document.fonts.readyfrom CSS Font Loading is a close precedent. Three details from it that I think carry over:fonts.readyis replaced with a fresh pending promise when the font set goes from loaded back to loading. Tools need the same. After a route change callswaitForToolsUntil()again,readyshould return a new pending promise. Otherwise a caller that awaits it mid-transition gets the old, already resolved promise with the previous route's tools, which is the partial list this issue is meant to prevent.readyalso resolves when the implementation-defined timeout runs out, a caller can't tell a complete list from a cut-off one, the gap @kenchris raised. If it resolves only when tools are actually ready, resolution always means complete, and a caller that needs a bound can race it against its own timer. If the group would rather have it settle on timeout too, the value should say so, for example{ tools, complete: false }.The resolved array is a snapshot, so callers still need
toolchangeafterwards. Thereadyboolean ontoolchangefrom @khushalsagar's earlier comment pairs well with this: the promise for the first read, the event for everything after.If this shape gets support, I'm happy to draft the spec text and a WPT for the route-change case: await
readyduring a transition, then check that the resolved list matches the new route's tools.