This document outlines the implementation strategy for integrating WebMCP (Web Model Context Protocol) into our website. WebMCP allows AI agents to interact with our site reliably and efficiently, moving beyond screen scraping.
Status: Early Preview (Chrome 146+) Goal: Make the site “agent-ready” for future sessions.
| Feature | Screen Scraping (Old Way) | WebMCP (New Way) |
|---|---|---|
| Reliability | Brittle; fails with UI changes | Deterministic; direct function calls |
| Efficiency | High compute/token cost | 67% reduction in overhead |
| Accuracy | ~70-80% success rate | ~98% success rate |
| Privacy | Agent sees entire screen | Agent only sees exposed tools |
WebMCP introduces navigator.modelContext. We can expose capabilities via two methods:
Best for simple interactions like form submissions or button clicks. Add tool-name attributes to existing elements.
Example:
<!-- Expose a flight booking action -->
<button
tool-name="book_flight"
tool-description="Books the currently selected flight"
>
Book Now
</button>
<!-- Expose a search form -->
<form tool-name="search_articles">
<input name="query" type="text" placeholder="Search..." />
<button type="submit">Go</button>
</form>
Best for complex logic or when no direct UI element exists. Use the mcp global object (available via navigator.modelContext or a polyfill).
Example:
if (navigator.modelContext) {
// Register a tool for an agent to call
navigator.modelContext.registerTool('delete_task', {
description: 'Deletes a task by ID',
parameters: {
type: 'object',
properties: {
id: { type: 'string', description: 'The ID of the task to delete' }
},
required: ['id']
},
execute: async ({ id }) => {
console.log(`Agent requested to delete task: ${id}`);
// await performDelete(id);
return { result: 'success' };
}
});
}
We will treat WebMCP as a progressive enhancement.
tool-name attributes are unique and descriptive.To ensure AI coding agents can interact flawlessly with your tools:
book_flight, delete_task, search_articles). Avoid ambiguous names like submit or click.<input>, <select>, and <textarea> MUST have a name attribute. This name becomes the parameter key in the tool schema.
<input type="text" /> (Agent sees: parameter: unknown)<input name="search_query" type="text" /> (Agent sees: parameter: search_query)tool-description attributes for any button or form where the action isn’t 100% obvious from the text content alone.#experimental-web-platform-features.For a full walkthrough, refer to the WebMCP Demo Video.