From 16fb5e4350e6418a8ceec78913187469af4c4d3b Mon Sep 17 00:00:00 2001 From: Ryan Westfall Date: Thu, 2 Jul 2026 13:01:50 -0500 Subject: [PATCH] Fix WebMCP schema validity on contact form for Lighthouse audits. Add toolparamdescription to contact fields, move reCAPTCHA outside the annotated form, and always render declarative WebMCP form attributes. --- company_site/docs/agentic-browsing.md | 4 +-- company_site/docs/webmcp.md | 16 +++++---- company_site/public/forms.py | 5 +-- .../public/static/public/css/style.css | 8 +++++ .../templates/django_recaptcha/widget_v3.html | 8 +++++ .../public/templates/public/contact.html | 36 ++++++++++++------- company_site/public/tests.py | 12 +++++++ 7 files changed, 67 insertions(+), 22 deletions(-) create mode 100644 company_site/public/templates/django_recaptcha/widget_v3.html diff --git a/company_site/docs/agentic-browsing.md b/company_site/docs/agentic-browsing.md index 0aac6c3..cde1dc1 100644 --- a/company_site/docs/agentic-browsing.md +++ b/company_site/docs/agentic-browsing.md @@ -32,7 +32,7 @@ Test at minimum: 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` +- Contact page registers `submit_contact_inquiry` via declarative form annotations (`toolname`, `tooldescription`, `toolparamdescription`); reCAPTCHA renders outside the annotated form - 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)** @@ -45,7 +45,7 @@ Before merging public-facing template or CSS changes: 2. Nav dropdowns use ` + {% endif %} + + {% if capchaForm %} +
+ {{ capchaForm }} +
+ + {% endif %} diff --git a/company_site/public/tests.py b/company_site/public/tests.py index 7e52a2d..0f8577a 100644 --- a/company_site/public/tests.py +++ b/company_site/public/tests.py @@ -196,10 +196,22 @@ class WebMcpTests(TestCase): response = self.client.get(reverse("contact")) self.assertEqual(response.status_code, 200) + self.assertContains(response, 'id="contact-form"') self.assertContains(response, 'toolname="submit_contact_inquiry"') self.assertContains(response, "tooldescription=") + self.assertContains(response, "toolparamdescription=") self.assertContains(response, "submit_contact_inquiry") + @override_settings(DEBUG=False) + def test_contact_page_renders_captcha_outside_annotated_form(self): + response = self.client.get(reverse("contact")) + + self.assertEqual(response.status_code, 200) + form_end = response.content.index(b"") + captcha_index = response.content.index(b"g-recaptcha") + self.assertGreater(captcha_index, form_end) + self.assertContains(response, b'form="contact-form"') + def test_webmcp_services_json_includes_all_service_pages(self): response = self.client.get(reverse("public_index")) -- 2.54.0