docs(specs): WebMCP host — the SPA as an agent-callable surface - #1004
Open
philmerrell wants to merge 1 commit into
Open
docs(specs): WebMCP host — the SPA as an agent-callable surface#1004philmerrell wants to merge 1 commit into
philmerrell wants to merge 1 commit into
Conversation
Spec for inbound WebMCP: our Angular SPA declares tools that the agent can call in the user's own authenticated session. Inverts the "browser agent first" framing — WebMCP's payoff for us is inbound, and inbound needs no AgentCore Browser, Playwright, or headless anything. Shaping constraint (§D3): page tools are route-scoped, so they churn on navigation. All tool sources converge at `_build_filtered_tools()` into `toolConfig`, which is the cached prefix — putting them there would rewrite a 30k-150k-token prefix on every navigation. So `toolConfig` gains exactly one stable `page_action(name, arguments)` entry, and the available-tool list rides the per-turn context mechanism MCP Apps PR-6 already built. Own-registry-first (§D1) hedges both moving specs: Angular's API is `provideExperimental*`, and W3C renamed the global and replaced provideContext() with registerTool() within months. PR-1..3 deliver the capability without depending on WebMCP; PR-4's document.modelContext projection is the only piece coupled to the unstable part. Outbound browsing is unbundled, not cancelled (Appendix B). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Spec only — no code.
docs/specs/webmcp-host-spa-tools.md.Started as "how do we build a browser agent so we can use WebMCP later?" and the research inverted the ordering.
The reframe
WebMCP yields two different products, and only one is worth building now:
Inbound pays off immediately, depends on nobody else's adoption curve, and needs no AgentCore Browser, no Playwright, no headless anything. It's also strictly cheaper: outbound produces unbounded payloads by construction, while an inbound call returns a bounded structured result — the page already knows its own state, so there's nothing to scrape.
We already ship most of a WebMCP host
It's just pointed at iframes:
mcp-app-bridge.ts:186/:648— host→View JSON-RPC requests with promise correlation already exist (used for resource teardown)app_tool_dispatch.py— page→agenttools/callwith full auth/OAuth/consent, no model turn, echoed into the live streamapp_context_dispatch.py:79/:155— a prompt-cache-safe way to get page state into a turnsession_lease.py— a proven owner-scoped side channel into a running turn (Stop, mid-turn steering)What's missing: any notion of the top-level SPA as a provider, and the transport from the inference container out to the browser mid-turn.
The decision that shapes everything (§D3)
Page tools are route-scoped, so they churn on navigation. All tool sources converge at
_build_filtered_tools()(base_agent.py:448) intotoolConfig— the cached prefix. Putting page tools there rewrites a 30k–150k-token prefix at the cache-write premium every time the user navigates.So
toolConfiggains exactly one stable entry,page_action(name, arguments), and the list of available tools rides the per-turn context mechanism MCP Apps PR-6 already built (stashed onagent.state, rendered into that turn's prompt only, sorted by name). Same lever astool-search-token-bloat-strategy.md, except here it's mandatory rather than advisable.PR sequence
page_action,page_tool_callSSE event, lease-row side channel. Carries the real risk.toolConfigbyte-stability test across a navigationdocument.modelContextprojection for third-party agentsPR-1–3 deliver the capability. PR-4 is the standards bet, and the only piece coupled to an unstable external spec — §D1 keeps our own registry as the primitive so Angular's
provideExperimental*churn is a one-file adapter change.Worth arguing about
CfnBrowserCustomstays idle — that's optionality, not sunk cost.🤖 Generated with Claude Code