# WebMCP declarative API See discussion in https://github.com/webmachinelearning/webmcp/issues/22 that led to the creation of this proposal. ## Motivation WebMCP lets developers expose intricate functionality backed by a website's JavaScript functions to an agent as "tools", effectively turning the site into an "MCP server". Agents can see the list of tools a site offers paired with natural language descriptions of what the tools do, and invoke them with structured data. With WebMCP, agents can perform complex actions like booking a flight or reserving a table by hooking into a site's own code designed to perform those actions, instead of the agent having to figure it out manually through a brittle series of screen shots, scrolls, and out-of-date screen reads. However, not all site functionality is exposed via JavaScript functions, and features that *are* take some effort to rewrite with an agent invoker in mind. Much of a site's functionality is provided via semantic HTML elements like `
`, and its various inputs. To **make it easier** for developers to expose this kind of site functionality while still using the semantic web, we propose: 1. New attributes that augment ``s and [form-associated elements](https://html.spec.whatwg.org/#form-associated-element), that expose these as WebMCP tools to agents. 2. Algorithms that deterministically "compile" a form and its associated inputs down to a WebMCP "input schema", so that the agent knows how to fill out the form and submit it. 3. Two ways of getting a form response back to the agent that invoked the form tool: 1. `SubmitEvent#respondWith()`, which lets JavaScript on the page override the default form action, and pipe a response back to the agent without navigating the page. 2. Extracting `