Repository navigation
Conversation
|
WordPress.com
Automattic for Agencies
|
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~49 bytes added 📈 [gzipped]) Details
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. App Entrypoints (~22 bytes added 📈 [gzipped]) Details
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~2073 bytes added 📈 [gzipped]) Details
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~130 bytes added 📈 [gzipped]) Details
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. |
This comment was marked as outdated.
This comment was marked as outdated.
|
@artpi and @glendaviesnz, I'm still learning the codebase and iterating on the WebMCP integration. However, I would appreciate any pointers if you notice anything out of the ordinary. The primary goal here is to reuse the client-side abilities registry from WordPress core as the source for WebMCP tools. In addition, I would like to establish conditions for how these abilities get approved as candidates for WebMCP tools. I'm happy to extract parts of this exploration if you believe some aspects could land in production already. |
There was a problem hiding this comment.
🟡 Changes recommended
Provider dispatch can bypass the validated definition, and malformed schemas can halt reconciliation of otherwise valid tools.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Extends Agents Manager’s experimental WebMCP adapter to expose eligible REST, provider-chain, and WordPress registry abilities.
Changes:
- Adds metadata-based exposure, source precedence, collision handling, and REST method routing.
- Replaces polling with registry subscriptions and live reconciliation.
- Expands documentation and regression coverage.
File summaries
| File | Description |
|---|---|
packages/agents-manager/WEBMCP.md |
Documents sources, policy, lifecycle, and testing. |
packages/agents-manager/AGENTS.md |
Clarifies WebMCP versus chat routing. |
src/webmcp/types.ts |
Expands WebMCP contracts and annotations. |
src/webmcp/server-ability-provider.ts |
Implements REST discovery and execution routing. |
src/webmcp/registry-tool-provider.ts |
Adds registry-backed execution. |
src/webmcp/provider-abilities-setup.tsx |
Extracts external ability setup. |
src/webmcp/mount.ts |
Composes sources and store subscription. |
src/webmcp/exposure.ts |
Implements metadata exposure and collision policy. |
src/webmcp/contracts.ts |
Centralizes ability-specific projections. |
src/webmcp/compose-tool-providers.ts |
Adds first-wins source composition. |
src/webmcp/adapter.ts |
Adds reconciliation and stale-definition checks. |
src/webmcp/ability-names.ts |
Centralizes policy names. |
src/webmcp/__tests__/server-ability-provider.test.ts |
Tests REST routing and retries. |
src/webmcp/__tests__/registry-tool-provider.test.ts |
Tests registry execution. |
src/webmcp/__tests__/mount.test.ts |
Tests lifecycle and precedence. |
src/webmcp/__tests__/exposure.test.ts |
Tests exposure rules and collisions. |
src/webmcp/__tests__/contracts.test.ts |
Tests schema and description projection. |
src/webmcp/__tests__/compose-tool-providers.test.ts |
Tests provider composition. |
src/webmcp/__tests__/adapter.test.ts |
Expands adapter regression coverage. |
src/utils/load-external-providers.ts |
Makes merged provider contracts defined-only. |
src/utils/legacy-style-variation-css.ts |
Uses shared record validation. |
src/utils/is-record.ts |
Adds shared object narrowing. |
src/utils/canvas-guard.ts |
Requires a defined provider. |
src/utils/ability-completion-broadcast.ts |
Requires a defined provider. |
src/utils/__tests__/canvas-guard.test.ts |
Updates guard tests for defined providers. |
src/utils/__tests__/ability-completion-broadcast.test.ts |
Updates broadcast tests. |
src/hooks/use-webmcp-tools.ts |
Replaces polling with mounted synchronization. |
src/hooks/__tests__/use-webmcp-tools.test.ts |
Tests registry and provider synchronization. |
src/components/agents-manager.tsx |
Uses extracted WebMCP setup component. |
src/components/__tests__/agent-setup.test.tsx |
Isolates setup tests from WebMCP runtime. |
Review details
- Files reviewed: 30/30 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…based gate Read client abilities from the core/abilities store and register them as WebMCP tools. Exposure follows meta.webmcp.public first, then meta.public for read-only abilities, then the existing allowlists. Replace the two-second polling with a store subscription, skip colliding tool names, add untrustedContentHint, and keep registering other tools when one fails. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UUhsdoUsXmAhdW4sFxUdLL
withCanvasGuard() and withAbilityCompletionBroadcast() now take a provider and return a wrapped provider. The merged provider always exists, so the undefined pass-through and the overload it forced on the registry path are gone. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UUhsdoUsXmAhdW4sFxUdLL
…ntracts Merge the REST, provider-chain, and registry sources with one first-wins helper instead of two wrappers that each re-implemented the routing. Move every ability-specific adjustment into a contract table so the adapter no longer checks ability names, keep collision selection next to the exposure policy, share one isRecord helper, and move the WebMCP setup component out of the root component. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UUhsdoUsXmAhdW4sFxUdLL
The WebMCP draft defines readOnlyHint, untrustedContentHint, and consequentialHint only. Stop emitting the MCP-style destructiveHint and idempotentHint, and derive consequentialHint from the contract table, meta.webmcp.consequential, or the ability's destructive annotation. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UUhsdoUsXmAhdW4sFxUdLL
Simplify the WebMCP adapter after review feedback. - Resolve the owner of an ability live on every call, as the chat provider chain does, instead of keeping a provider per registration. A tool call re-reads the current winner for its ability name and is rejected when that winner is gone, opted out, or has a different descriptor. A source change with an identical descriptor keeps the registration, so tools no longer flicker when the provider chain arrives after the registry. - Keep the merge helper WebMCP-only under src/webmcp/ and leave the chat provider chain untouched. - Drop the timed retries from the mount. A source that fails to load is reported and skipped, the other sources still register, and the uncached REST failure is fetched again on the next reconcile. - Update WEBMCP.md, AGENTS.md, and the tests to match. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011tWfc3eeKKSXcPGPMxJeHc
…bilities Document that the local REST provider mirrors the upstream @wordpress/core-abilities loader, why that loader cannot replace it yet, and the steps that would let us delete the local copy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011tWfc3eeKKSXcPGPMxJeHc
A registry ability can carry a schema that cannot be serialized, such as a cyclic object. Building its fingerprint threw outside the per-tool try block and aborted the whole reconcile, so the valid tools after it were never registered. - Build the descriptor and fingerprint through a helper that reports that one ability as a failure and skips it, removes its registration when the live descriptor stops being serializable, and lets the other tools register. - Treat a descriptor that cannot be serialized as a changed tool at dispatch. - Build the adapter test harness with the real merge helper over a single source, so the tests use the same seam as the mount. - Document the name-based dispatch inside each owner as a known limit. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011tWfc3eeKKSXcPGPMxJeHc
…t test The assertion for wpcom/get-posts with a stored public: false read as if the flag opted the ability in. Rename the test, add the control case of a non-allowlisted ability with the same flag and annotations, and explain why the stored default cannot be an opt-out. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011tWfc3eeKKSXcPGPMxJeHc
1a211cd to
bbcfc91
Compare
d92f957 to
415ce66
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Duplicate provider setup instances share module-level state, allowing inert actions to stop the shimmer, emit premature completion, and clear the pending block during an active transformation.
2 open issues
Review effort: Balanced
A stale tool call starts a reconcile before it rejects. A failure of that reconcile was dropped without a message. The adapter now takes the mount's onSyncError, so every sync failure is reported in one place. Also remove a WebMCP hook mock from the agent setup tests. Nothing asserted it, and the suite passes without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
WebMCP landed in the WordPress AI plugin: WordPress/ai#1081 Both approaches register tools with the browser through
The main difference is scope: the AI plugin focuses on the current page and leaves server abilities to MCP. This PR also exposes selected site capabilities, such as fetching patterns and uploading media, through the same browser interface. |


Part of BSKY-2070
Follow-up to #113839.
Proposed Changes
core/abilitiesregistry abilities alongside REST and provider-chain abilities on supported editor pages withisDevMode: trueand a WebMCP-capable browser. Opening chat is not required for independently registered abilities, including Agents Manager’s editor tools.useAbilitiesSetuphooks owned solely by chat, with live chat actions. WebMCP queries providers and subscribes to the registry without mounting a second setup hook, avoiding conflicts with sidebar processing state. Third-party abilities registered only by chat setup become available after chat opens.meta.webmcp.publicfor explicit channel opt-in/out, thenmeta.publicfor read-only opt-in, then the transitional allowlists. Registry execution retains permission callbacks and schema validation. Existing canvas guards cover known abilities; other plugins remain responsible for permissions and target scoping.contracts.ts, exposure policy inexposure.ts, and source composition incompose-tool-providers.ts.packages/agents-manager/src/webmcp/README.mdandAGENTS.md. Consolidate overlapping tests while retaining coverage for precedence, ownership, collisions, registration recovery, and cancellation.Why are these changes being made?
The prototype exposed a fixed set of abilities. Registry discovery and metadata flags let plugins participate without extending client-side allowlists. Exposure, browser hints, and execution must refer to the same current definition and source, including when a source recovers or an ability changes after registration.
The REST source remains a local stand-in for
@wordpress/core-abilities. The WebMCP README describes the metadata, loading, and query-argument requirements that would let us remove it.Future considerations
Timed discovery retries are deliberately omitted for this dev-mode experiment. Successful REST discovery is cached for the mount; later tool-execution failures do not invalidate that cache or remove tools. Failed discovery is uncached and can be attempted again after a registry/provider change or another tool dispatch. Without further activity, recovery may require a remount or reload. Other sources remain available, and a failed higher-priority source can allow a same-named fallback to win.
If automatic recovery becomes a production requirement, consider bounded discovery retries with backoff. Successful preloading of the exact discovery request could avoid the initial network request, but preload coverage has not been verified here. Tool executions, especially writes, are never retried automatically.
Deploy dependencies
None added by this PR. The experiment uses the existing Agents Manager inline development-mode flag and ability sources; REST tools require the existing site's Abilities API. Removing the local REST source would require the upstream changes described in the WebMCP README.
Testing Instructions
Automated validation
Passed on the current branch:
yarn test-packages 'agents-manager|jetpack-ai-sidebar' --runInBand— 202 suites, 3,643 tests.yarn typecheck-packagesNODE_OPTIONS=--max-old-space-size=8192 yarn typecheck-clientThe focused WebMCP and hook suites pass: 9 suites, 79 tests. Coverage includes source precedence and opt-outs, dispatch from a single validated snapshot, collisions appearing after registration, private colliding abilities, recovery through fresh registrations, GET/POST/DELETE routing, partial discovery failures, malformed descriptors, cancellation, and disposal races.
Live browser checks and a fresh production bundle-size comparison after rebasing remain outstanding; previous bundle measurements are not representative of the current branch.
Calypso
Run
yarn startusing the existing configured port. Regression checks: open and reopen Agents Manager on a hosting screen; confirm normal chat ability execution. Confirm non-editor screens do not register WebMCP tools or fetch theam-webmcpchunk.Dashboard
Run
yarn start-dashboard. Regression checks: open Agents Manager and confirm normal chat operation. Confirm the non-editor surface does not expose WebMCP tools.Simple and Atomic editors
Sandbox
widgets.wp.com, then runyarn dev --syncfromapps/agents-manager. Open a post, page, custom-post-type block editor, or site editor withisDevMode: truein a WebMCP-capable browser.Must test:
packages/agents-manager/src/webmcp/README.md. Confirm available tools target the current editor. Use disposable content and leave editor changes unpublished.Regression checks: open and close chat while WebMCP is active; verify provider abilities and chat callbacks still work and registrations survive the chat lifecycle. During an active sidebar block request, trigger an Agents Manager rerender and confirm the shimmer and pending target remain active until the request completes. Check lazy-chunk requests and the browser console.
WooCommerce AI and Reader Chat
Using the same sandbox bundle setup, open the WooCommerce AI admin and Reader Chat on a public blog. Regression checks: confirm existing chat functionality and no WebMCP registrations on non-editor pages. Include a self-hosted Jetpack/WooCommerce test environment where available.
Pre-merge Checklist