From bb5aa6de824c7434a2df67cf4221d2312e69a2c3 Mon Sep 17 00:00:00 2001 From: Ryan Westfall Date: Thu, 2 Jul 2026 16:57:47 +0000 Subject: [PATCH] Add WebMCP tool registration for agentic browsing (#9) (#12) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Add `WEBMCP_ENABLED` setting and guarded `webmcp-tools.js` loader on public pages - Register navigation tools (`list_services`, `get_page_content`, `navigate_to_service`, `open_contact_with_subject`) and contact tool (`submit_contact_inquiry`) - Annotate contact form with declarative WebMCP attributes for Lighthouse form coverage - Extend `PUBLIC_PAGE_ENTRIES` with summaries shared by SEO and WebMCP tools - Add `docs/webmcp.md`, update `docs/agentic-browsing.md`, and regression tests Closes #9 ## Test plan - [x] `python manage.py test public.tests` — 20 tests pass - [ ] Set `WEBMCP_ENABLED=True`, enable Chrome experimental web platform features flag - [ ] Verify homepage HTML includes `webmcp-config` and `webmcp-tools.js` - [ ] Verify `/contact` form has `toolname="submit_contact_inquiry"` - [ ] Run Lighthouse agentic-browsing on `/` and `/contact` with experimental flag - [ ] Call `list_services` from WebMCP-capable Chrome on homepage - [ ] Call `submit_contact_inquiry` on `/contact` with `DEBUG=True` (reCAPTCHA bypass) Reviewed-on: https://git.aimloperations.com/ai_ml_operations/company_site/pulls/12 --- company_site/company_site/settings.py | 2 + company_site/docs/agentic-browsing.md | 17 +- company_site/docs/webmcp.md | 104 +++++++ company_site/public/context_processors.py | 34 +++ company_site/public/seo.py | 126 +++++++- .../public/static/public/js/webmcp-tools.js | 286 ++++++++++++++++++ company_site/public/templates/base.html | 14 + .../public/templates/public/contact.html | 3 +- company_site/public/tests.py | 60 ++++ 9 files changed, 628 insertions(+), 18 deletions(-) create mode 100644 company_site/docs/webmcp.md create mode 100644 company_site/public/static/public/js/webmcp-tools.js diff --git a/company_site/company_site/settings.py b/company_site/company_site/settings.py index 5fcbf01..0026c84 100644 --- a/company_site/company_site/settings.py +++ b/company_site/company_site/settings.py @@ -26,6 +26,7 @@ SECRET_KEY = 'django-insecure-0$+hho_6%-(ud^t%0zos(q&i@2&)9m+u&dgj77&51g$m#hr^0s # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True TIANJI_ENABLED = not DEBUG +WEBMCP_ENABLED = False ALLOWED_HOSTS = ["*"] @@ -71,6 +72,7 @@ TEMPLATES = [ 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'public.context_processors.tianji_tracking', + 'public.context_processors.webmcp_context', ], }, }, diff --git a/company_site/docs/agentic-browsing.md b/company_site/docs/agentic-browsing.md index c67bc33..0aac6c3 100644 --- a/company_site/docs/agentic-browsing.md +++ b/company_site/docs/agentic-browsing.md @@ -25,8 +25,17 @@ Test at minimum: | **sitemap.xml** | `GET /sitemap.xml` — public marketing URLs | | **Accessibility tree** | Form labels, semantic nav controls, ARIA on dialogs | | **Layout stability** | Fixed cookie banner, reserved hero/marquee space, font fallbacks | +| **WebMCP tools** | `navigator.modelContext` tools behind `WEBMCP_ENABLED` (see [webmcp.md](webmcp.md)) | -WebMCP is intentionally deferred until browser and agent support stabilizes. +## WebMCP (issue #9) + +When `WEBMCP_ENABLED=True`: + +- Navigation tools (`list_services`, `get_page_content`, `navigate_to_service`, `open_contact_with_subject`) load on all public pages +- Contact page registers `submit_contact_inquiry` and annotates the HTML form with `toolname` / `tooldescription` +- Default is **disabled** (`WEBMCP_ENABLED=False`) until deliberately enabled per environment + +Full tool catalog, Chrome flag setup, and reCAPTCHA notes: **[docs/webmcp.md](webmcp.md)** ## Regression checklist @@ -36,10 +45,12 @@ Before merging public-facing template or CSS changes: 2. Nav dropdowns use `