policycheck-extension

vibegpt/policycheck-extension Checked 2 days ago

Chrome extension that injects check_seller_policy WebMCP tool into e-commerce sites for AI agent trust verification

A Chrome extension that injects a check_seller_policy WebMCP tool into e-commerce sites, enabling AI agents to verify seller trustworthiness before purchasing. When you visit an e-commerce site in Chrome Canary 146+ (with WebMCP enabled), this extension automatically registers a check_seller_policy tool via navigator.modelContext.registerTool(). Any AI agent operating on the page can discover and call this tool alongside the seller's own tools.

Summary extracted from the README.

PolicyCheck Chrome Extension

A Chrome extension that injects a check_seller_policy WebMCP tool into e-commerce sites, enabling AI agents to verify seller trustworthiness before purchasing.

What it does

When you visit an e-commerce site in Chrome Canary 146+ (with WebMCP enabled), this extension automatically registers a check_seller_policy tool via navigator.modelContext.registerTool(). Any AI agent operating on the page can discover and call this tool alongside the seller's own tools.

The tool calls the PolicyCheck API and returns:

  • Risk score (0-10)
  • Risk level (low / medium / high / critical)
  • Buyer protection rating (A+ to F)
  • Risk factors with severity ratings (binding arbitration, no-refund clauses, restocking fees, liability caps, etc.)
  • Plain-language summary

How it works

  1. Extension detects e-commerce pages via heuristics (known domains, Shopify/WooCommerce markers, Schema.org Product markup, cart/checkout signals)
  2. If WebMCP is available (navigator.modelContext exists), registers check_seller_policy tool
  3. Tool attempts to extract policy text from the current page (footer links, policy sections)
  4. When an agent calls the tool, it sends the data to the PolicyCheck API and returns structured risk data
  5. Extension badge shows status: ✓ (registered), ! (e-commerce but no WebMCP), or number of risk factors found

Install (Developer Mode)

  1. Open Chrome Canary 146+
  2. Enable chrome://flags/#enable-webmcp-testing
  3. Go to chrome://extensions/
  4. Enable Developer mode (toggle in top right)
  5. Click Load unpacked
  6. Select the policycheck-extension folder
  7. Visit any e-commerce site — the extension icon will show a green ✓ when the tool is registered

Architecture

┌─────────────────────────────────────────────┐
│  Web Page (MAIN world)                      │
│                                             │
│  content.js                                 │
│  ├── Detects e-commerce page                │
│  ├── Registers check_seller_policy tool     │
│  │   via navigator.modelContext             │
│  └── Posts status via window.postMessage    │
├─────────────────────────────────────────────┤
│  bridge.js (ISOLATED world)                 │
│  └── Relays postMessage → chrome.runtime    │
├─────────────────────────────────────────────┤
│  background.js (Service Worker)             │
│  ├── Updates badge icon/text                │
│  └── Stores status/results for popup        │
├─────────────────────────────────────────────┤
│  popup.html/js                              │
│  └── Shows status and last risk assessment  │
└─────────────────────────────────────────────┘

The content script runs in the MAIN world (required for navigator.modelContext access). A bridge script in the ISOLATED world relays messages to the background service worker for badge updates and popup state.

E-commerce Detection

The extension uses multiple heuristics:

  • Known domain matching (Amazon, eBay, Shopify stores, etc.)
  • Shopify platform markers (meta[name="shopify-checkout-api-token"], window.Shopify)
  • WooCommerce markers (.woocommerce class)
  • Cart/checkout signal counting (add-to-cart, buy-now, shopping-cart, checkout, product-price)
  • Schema.org Product structured data
  • Open Graph product meta tags

Files

policycheck-extension/
├── manifest.json          # Manifest V3
├── icons/                 # Extension icons (16/32/48/128)
├── src/
│   ├── content.js         # MAIN world — tool registration + e-commerce detection
│   ├── bridge.js          # ISOLATED world — message relay
│   ├── background.js      # Service worker — badge + storage
│   ├── popup.html         # Extension popup UI
│   └── popup.js           # Popup logic
└── README.md

Requirements

  • Chrome Canary 146+ with chrome://flags/#enable-webmcp-testing enabled
  • The PolicyCheck API at https://policycheck.tools/api/check must be accessible

License

MIT