Skip to content

Agents Manager: WebMCP for isDevMode - #113839

Merged
artpi merged 10 commits into
trunkfrom
try/bsky-2070-webmcp
Aug 28, 2026
Merged

artpi merged 10 commits into
trunkfrom
try/bsky-2070-webmcp

Conversation

@artpi

@artpi artpi commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of BSKY-2070

This exposes a deliberately small set of abilities through WebMCP on Gutenberg canvases while Agents Manager reports isDevMode. The browser supplies the model and reasoning; the adapter does not start an Agenttic agent or open Agents Manager chat.

WebMCP tools running in the editor

Proposed Changes

  • Add an editor-only WebMCP adapter behind the existing isDevMode check.
  • Preserve the existing chat-owned ability-registration lifecycle unless WebMCP is eligible.
  • Expose the client-side editor loop through agents_manager__get_block_tree, big_sky__show_template, and big_sky__apply_block_edits.
  • Expose seven explicitly allowlisted, read-only server abilities: wpcom__get_block_schemas, wpcom__get_content_guidelines, wpcom__get_posts, wpcom__get_site_stats, wpcom__patterns_list, wpcom__patterns_get, and core__get_site_info.
  • Expose wpcom__media_create as the sole explicitly allowlisted mutating server ability. Mutating calls use POST with a JSON body, while read-only calls remain GET.
  • Preserve the media ability's existing confirmation, authentication, site capability, MIME validation, integrity, and size checks.
  • Let the WebMCP-only edit schema accept serialized Gutenberg markup returned by wpcom__patterns_get, parse it in the browser, and stage all top-level blocks in order.
  • Keep the WebMCP tools out of ordinary Agents Manager agent routes and tool configuration. The companion dotcom change is Automattic/wpcom#237669.

What's next?

  1. Keep iterating under the development flag.
  2. Validate the flow across Simple, Atomic, and self-hosted Jetpack editors.
  3. Decompose more Big Sky use cases into narrow, reusable abilities before broadening exposure.

Testing Instructions

Automated

  • yarn jest -c test/packages/jest.config.js --runInBand --testPathPattern=agents-manager
  • NODE_OPTIONS=--max-old-space-size=8192 yarn typecheck-client
  • yarn eslint packages/agents-manager/src/webmcp/contracts.ts packages/agents-manager/src/webmcp/adapter.ts packages/agents-manager/src/webmcp/server-ability-provider.ts packages/agents-manager/src/webmcp/__tests__/server-ability-provider.test.ts packages/agents-manager/src/webmcp/__tests__/adapter.test.ts

Codex built-in browser

  1. Sync Automattic/wpcom#237669 to wpdev, including public-api.wordpress.com in the sandbox routing.
  2. Sandbox widgets.wp.com and run NODE_OPTIONS=--max-old-space-size=8192 WPCOM_SANDBOX=wpdev yarn dev --sync from apps/agents-manager.
  3. Sign in to a test site in the Codex built-in browser and open an existing post, page, or site editor while isDevMode is true.
  4. Ask Codex to inspect the page's Site tools. Confirm it discovers all eleven WebMCP tools, including wpcom__media_create, wpcom__patterns_list, and wpcom__patterns_get.
  5. Call wpcom__patterns_list, fetch a suitable pattern with wpcom__patterns_get, and pass its returned content to big_sky__apply_block_edits as inserts[0].blockMarkup.
  6. Read the block tree again and confirm the pattern's top-level blocks were staged in order. Do not publish; remove the test insertion or discard the editor changes.
  7. After explicit user confirmation, call wpcom__media_create with a small base64-encoded image. Confirm the response includes a valid attachment ID and URL, then delete the test attachment from the media library.
  8. Force isDevMode false and confirm the editor exposes no WebMCP tools and the base Agents Manager UI still opens, sends a message, and handles history normally.

Verified

  • All 83 Agents Manager suites pass: 1,068 tests.
  • The focused WebMCP adapter/provider suites pass: 21 tests.
  • NODE_OPTIONS=--max-old-space-size=8192 yarn typecheck-client passes.
  • Focused ESLint passes.
  • On wpdev, the Codex built-in browser discovered the original ten tools on an existing sandboxed page.
  • wpcom__patterns_list returned the live pattern library and wpcom__patterns_get returned the serialized content for a8c/page-title-1.
  • Passing that exact content to big_sky__apply_block_edits staged the complete seven-block pattern (4 → 11 blocks), then cleanup returned the tree to four blocks without publishing.
  • The built-in browser discovered all eleven tools and wpcom__media_create successfully uploaded a 68-byte PNG as attachment 617 with the expected ID, URL, MIME, dimensions, alt text, and edit link. The test attachment was deleted and wpdev was restored to read-only mode.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • For UI changes, have you tested the affected components in dark mode?
  • Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Webpack Runtime (~29 bytes added 📈 [gzipped])

Details
Name Parsed Gzip
runtime +121 B +0.1% +29 B +0.0%

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 (~4 bytes added 📈 [gzipped])

Details
Name Parsed Gzip
entry-stepper +68 B +0.0% +2 B +0.0%
entry-main +19 B +0.0% +2 B +0.0%

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~2389 bytes added 📈 [gzipped])

Details
Name Parsed Gzip
am-webmcp +276.45 kB new +99.85 kB new
am-editor-abilities +1.88 kB +0.0% +1.30 kB +0.1%
am-selected-block -276 B -0.0% +727 B +0.1%
patterns -227 B -0.0% +29 B +0.0%
am-font-picker -173 B -0.0% +710 B +0.1%
am-color-picker -173 B -0.0% +631 B +0.1%
am-button-picker -173 B -0.0% +635 B +0.1%
theme +68 B +0.0% +3 B +0.0%

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 (~1316 bytes added 📈 [gzipped])

Details
Name Parsed Gzip
async-load-automattic-agents-manager +2.14 kB +0.1% +556 B +0.1%
async-load-automattic-global-styles-src-components-global... -173 B -0.0% +760 B +0.1%

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.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

@artpi artpi self-assigned this Aug 26, 2026
@artpi
artpi force-pushed the try/bsky-2070-webmcp branch from f132015 to b5412af Compare August 26, 2026 19:29
@artpi

artpi commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Native built-in-browser verification completed on the artpitesting test site. Codex discovered both page-defined Site tools through the browser WebMCP proxy (no DevTools execution), called agents_manager__get_block_tree on an empty editor, inserted a core/heading through big_sky__apply_block_edits, and read the canvas again to confirm one heading with the expected attributes and a real client ID. The branch-only tools being present also confirms the built-in browser reached the wpdev-sandboxed widgets.wp.com bundle. The page remains unsaved and unpublished.

@artpi

artpi commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Native Codex built-in browser verification completed against the wpdev-synced build at 7f5fd7ba878:

  • Codex discovered all three Site tools without DevTools or direct document.modelContext access: agents_manager__get_block_tree, big_sky__show_template, and big_sky__apply_block_edits.
  • The initial block-tree read returned 0 blocks on a fresh page.
  • big_sky__show_template succeeded and returned follow-up guidance naming agents_manager__get_block_tree.
  • The next native block-tree read returned 12 blocks, including the newly available template structure.
  • The earlier native read → edit → read run also inserted a heading and confirmed it through the reader. Nothing was published.

The PR testing instructions now document this Codex-native path and the direct browser API fallback separately.

@artpi
artpi force-pushed the try/bsky-2070-webmcp branch from 782e2db to f7c4b63 Compare August 27, 2026 09:22
@artpi
artpi marked this pull request as ready for review August 27, 2026 11:02
@artpi artpi changed the title Agents Manager: Explore a frontend-only WebMCP editor adapter Agents Manager: WebMCP for isDevMode Aug 27, 2026
@artpi
artpi requested a review from jom August 27, 2026 11:56
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Aug 27, 2026
@artpi
artpi merged commit 9da64cf into trunk Aug 28, 2026
13 checks passed
@artpi
artpi deleted the try/bsky-2070-webmcp branch August 28, 2026 11:49
@github-actions github-actions Bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Aug 28, 2026
@a8ci18n

a8ci18n commented Aug 28, 2026 •

Copy link
Copy Markdown

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/35211514

Some locales (Arabic, Brazilian Portuguese, Chinese (China), Dutch, French, German, Hebrew, Japanese, Korean, Russian, Spanish) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday.

Thank you @artpi for including a screenshot in the description! This is really helpful for our translators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants