Skip to content

feat(webmcp): register the WebMCP tool catalog on form load - #1985

Merged
rismehta merged 18 commits into
devfrom
feat/webmcp-runtime
Oct 2, 2026
Merged

rismehta merged 18 commits into
devfrom
feat/webmcp-runtime

Conversation

@rismehta

@rismehta rismehta commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

What

Exposes each rendered form's WebMCP tool catalog to in-browser AI agents (Gemini-in-Chrome, ChatGPT Site tools, etc.) so they can drive the form through a declared tool catalog instead of scraping the DOM.

A single call at the form-container bootstrap seam (Utils.setupFormContainer, right after fields are initialised) hands the af-core model to the adapter:

registerFormWebMCP(formContainer.getModel(), Utils.getWebMcpOptions(formContainer));

Opt-in and safe by default

  • Per-form opt-in via the authored form property fd:webMcpEnabled (read by af-core's form.webMcpEnabled). Absent → nothing registers.
  • No-ops when no browser modelContext is available (SSR/unsupported browser).
  • Default behaviour is unchanged.

Changes

  • ui.frontend/src/utils.js — import registerFormWebMCP and call it once per form load.
  • ui.frontend/package.json and lockfile — align @aemforms/af-core, @aemforms/af-formatters, and @aemforms/af-webmcp to the published 1.0.6 release.
  • ui.frontend/jest.config.js — allow @aemforms/af-webmcp through the ESM transform.
  • ui.frontend/__tests__/webmcp.test.js — asserts the catalog is registered once with the form model.
  • ui.frontend/__tests__/webmcp.integration.test.js — exercises the actual published packages, including opt-in, field mutation, focus bridging, RUM no-ops, completeness annotations, and registration cleanup.
  • ui.tests/test-module/specs/webmcp/webmcp.authoring.cy.js — an enabled, latest-addon Cypress authoring-to-preview scenario using the existing accessibility form. It enables the container checkbox, previews the saved form with a preview-scoped test-only browser host installed before runtime scripts, asserts the actual 12-tool catalog plus list_forms, and reads the form summary. Authenticated browser cleanup restores the original opt-in property and its type.
  • IT OSGi toggle configuration enables FT_FORMS-28233 in enabledToggles.

Dependency / release note

The public npm release is available. All three runtime dependencies use ^1.0.6 and resolve to 1.0.6 in the regenerated lockfile, with public registry.npmjs.org tarballs. XFA and custom-function package versions remain independently versioned at 0.1.6 and 1.0.18 respectively.

Validation

  • All 45 frontend Jest tests pass, including unmocked integration with the published SDK and core.
  • Production builds pass for both the standard and XFA browser runtimes; webpack reports bundle-size warnings.
  • All 74 v2 FormContainerImplTest tests pass, including the existing REST/spreadsheet submission JSON comparisons and absent/Boolean-true/Boolean-false/String-true/String-false WebMCP serialization coverage. Existing JSON fixtures are unchanged.
  • The enabled Cypress spec passes against local AEM with real authoring, checkbox/save, preview bootstrap, all 13 tool descriptors, completeness annotations, form discovery, and a real field summary containing more than 10 fields. The host fixture replaces only the browser transport, not the form model, opt-in, or registration logic. Teardown restores the shared fixture's original absent property. Local prerequisites include matching Java/browser packages, IT content/config, the examples page component, and the development toggle provider.
  • The branch contains the current adobe/dev base, including upstream CAPTCHA fixes, custom-functions 1.0.18, and both CAPTCHA v3 and WebMCP IT toggles.

Design doc

Adaptive Forms Runtime via WebMCP (wiki)

🤖 Generated with Claude Code

Authoring opt-in

The Adaptive Form Container dialog exposes Enable AI assistant access (WebMCP) and persists the Boolean fd:webMcpEnabled property. FormContainerImpl exports this reserved property only when authored, preserving both explicit true and false. An absent property is omitted so existing form JSON stays unchanged; af-core defaults to no tool registration.

Jira tracking

  • Core Components: FORMS-28234.
  • Epic: FORMS-28233.
  • The authoring checkbox is gated by FT_FORMS-28233; runtime access still requires the per-form fd:webMcpEnabled opt-in.

@rismehta

rismehta commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Added the requested explicitly skipped Cypress authoring-to-preview scenario in ui.tests/test-module/specs/webmcp/webmcp.authoring.cy.js.

It reuses the existing accessibility form, opens its container dialog, enables the WebMCP checkbox, saves, and previews the form. A test-only document.modelContext host is installed before runtime initialization; the actual runtime must register all 12 form tools plus list_forms. The test verifies one discoverable form and reads its real multi-field summary. Cleanup restores the original opt-in property so other accessibility tests are unaffected. FT_FORMS-28233 is enabled in the IT DynamicToggleProvider OSGi configuration.

Cypress 13.17.0 compiled and collected the final spec with one pending test and zero failures, preserving describe.skip. The full authoring flow was not executed: the local instance returns 404 for both the accessibility collateral and the WebMCP dialog node. It needs matching deployed components, IT content, and IT toggle configuration before temporarily enabling the suite.

@rismehta

rismehta commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Fixed the reported REST/spreadsheet JSON comparison failures without changing their fixtures. The optional Sling Boolean is now nullable and only exported when authored: absent means no fd:webMcpEnabled key; explicit true and explicit false retain their Boolean values. Runtime default opt-out is unchanged.

All 72 v2 FormContainerImplTest tests pass, including both reported submission tests and three new map/JSON serialization regressions. Next I am running the temporarily unskipped Cypress authoring scenario against the newly installed collateral; the committed suite remains skipped.

@rismehta

rismehta commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Actual local Cypress execution update: temporarily removed describe.skip and ran the authoring scenario against localhost:4502. The first run exposed a missing forms-components-examples page component. Deployed the examples application package and the accessibility form now renders correctly; the editor initializes on rerun.

The second actual run fails only at the explicit FT_FORMS-28233 prerequisite in before(). The installed IT OSGi configuration contains the flag, but this AEM instance has only com.adobe.granite.toggle.impl.static (no development DynamicToggleProviderImpl), so the effective toggle endpoint does not enable it. The checkbox/save/preview/tool-registration flow has not yet executed and is not claimed to pass. Restored describe.skip; no authored opt-in was left on the shared accessibility fixture. Waiting for a toggle-enabled local setup to finish end-to-end verification.

rismehta and others added 13 commits October 1, 2026 21:59
Expose each rendered form's WebMCP tool catalog to in-browser AI agents by calling
registerFormWebMCP(model) from @aemforms/af-webmcp at the form-container bootstrap
seam (Utils.setupFormContainer, after fields init). No-ops unless the form opted in
via fd:webMcpEnabled and a browser modelContext is available, so default behaviour is
unchanged. Adds @aemforms/af-webmcp as a dependency and to the jest ESM allowlist.

Requires the @aemforms/af-core / @aemforms/af-webmcp release that ships the WebMCP
catalog (buildFormTools + the form.webMcpEnabled getter); until it publishes, CI
install of af-webmcp will fail.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Persist fd:webMcpEnabled from the Form Container dialog and explicitly export it in form JSON for the runtime adapter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Explain the AI-assistant capabilities and user-confirmation boundary in the WebMCP authoring control.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the hook experimental and form-scoped, support pre-init and connected updates, and remove the page-global factory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the established Granite featuretoggle render condition with FT_FORMS-28233, preserving the Boolean opt-in values and runtime contract.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the dialog XML test and its unused imports while retaining the authoring feature-toggle render condition.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse accessibility collateral, enable FT_FORMS-28233 in IT configuration, verify the dialog opt-in and actual preview catalog with a test host, and restore the shared form property after the test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the optional Sling property nullable and serialize authored Boolean values only. Preserve existing JSON fixtures and cover absent, enabled, and disabled exports.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rismehta

rismehta commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased the existing PR branch onto adobe/dev at f5c75dd and resolved the dependency-lock and IT-toggle conflicts. Kept upstream custom-functions 1.0.18 and CAPTCHA v3 FT_FORMS-27648, alongside the released core/formatters/WebMCP 1.0.6 packages and the conditional opt-in serialization fix. The updated history is pushed with an exact force-with-lease.

Local Cypress validation is continuing before enabling the test in the PR. It exposed an outdated deployed Java bundle that does not export the authored opt-in; I am deploying the matching rebased bundle and finishing browser-context cleanup coverage.

@rismehta
rismehta force-pushed the feat/webmcp-runtime branch from 9c82737 to 738675c Compare October 1, 2026 16:40
Cover authoring String opt-in values, wait for the container dialog, install the preview host before runtime bootstrap, and restore the original property through authenticated browser cleanup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rismehta

rismehta commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed d4391aa. The WebMCP authoring Cypress spec is now enabled for the latest addon and passed two consecutive real local runs (1 passing, 0 pending, 0 skipped). It opens the existing accessibility form editor, enables the actual checkbox, saves, previews, verifies all 13 registered tools and completeness annotations, discovers one form, and reads a real summary with more than 10 fields. The preview-scoped fixture supplies only the browser modelContext transport; the form model, opt-in and registration remain real. Authenticated teardown succeeds and the shared opt-in is confirmed absent again. Added Java coverage for authoring String true/false conversion: all 74 v2 form-container tests pass, including both reported REST/spreadsheet JSON failures; existing expected JSON fixtures remain unchanged. After the adobe/dev rebase, all 45 frontend tests, standard/XFA production builds and the scoped ESLint check pass. Upstream CAPTCHA fixes, custom-functions 1.0.18 and the v3 toggle remain intact. PR description and developer setup guidance are updated.

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

1 similar comment
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

rismehta and others added 2 commits October 2, 2026 09:36
Remove the persisted text-input fixture before each attempt and after failures through authenticated Sling requests, verify cleanup, and assert exactly one saved change handler without depending on JCR metadata serialization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the public runtime release that restores validation of visible disabled fields.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

rismehta and others added 2 commits October 2, 2026 12:04
…sible dialogs

Skip the WebMCP authoring suite when FT_FORMS-28233 is disabled. Query only the active insertion dialog and re-query search inputs after clearing to avoid hidden or detached controls. Cover retained dialogs and input replacement with browser regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… spec

Keep the WebMCP authoring feature-toggle guard and its documentation unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rismehta
rismehta merged commit cf5211b into dev Oct 2, 2026
5 of 7 checks passed
@rismehta
rismehta deleted the feat/webmcp-runtime branch October 2, 2026 06:36
rismehta added a commit that referenced this pull request Oct 2, 2026
feat(webmcp): register the WebMCP tool catalog on form load

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
page-has-heading-one moderate
target-size serious

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
page-has-heading-one moderate
target-size serious

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

2 participants