At Fastex we have long been building AI agents that don't stop at "answering with text" but carry out real actions in a controlled way. WebMCP is one of the pieces that makes this possible directly in the browser, with no intermediate servers. In this article we explain what it is, how it works and what it's for.
The Problem WebMCP Solves
A language model on its own can write and reason, but it doesn't know how to click buttons or fill in fields on your page. Traditionally, connecting an AI to a web application meant building a custom API, securing it and maintaining it. That means backend work, time and cost.
WebMCP turns that approach on its head. Instead of exposing an API on the server, it exposes the capabilities of the page itself as tools that an AI agent can discover and use. Whatever the user can do in the interface, the agent can do too, but programmatically and under supervision.
What Exactly Is WebMCP
WebMCP is an open-source JavaScript library that lets any website integrate with the Model Context Protocol (MCP), the open standard for connecting AI models to external tools and data.
In practice, WebMCP places a small widget on the page and offers a simple way to register three types of elements that the agent can use:
- Tools: actions the AI can run on your website. For example, "fill in the contact form" or "check the weather".
- Prompts: predefined templates to standardize common requests to the model.
- Resources: data and content from the page that the agent can read and use as context, identified by a URI.
It also includes sampling: when a tool needs a response from the model, the user can be asked to approve it through a dialog. This keeps human oversight over sensitive decisions.
How a Tool Is Registered
The central idea is registerTool. You give it a name, a natural-language description, a schema for the arguments it accepts and a function that runs when the agent invokes it. Conceptually:
1const mcp = new WebMCP({ color: '#1f6feb', position: 'bottom-right' });23mcp.registerTool(4 'rellenar_formulario_contacto',5 'Rellena el formulario de contacto con los datos del usuario',6 {7 nombre: { type: 'string' },8 email: { type: 'string' },9 mensaje:{ type: 'string' }10 },11 function (args) {12 document.querySelector('#nombre').value = args.nombre;13 document.querySelector('#email').value = args.email;14 document.querySelector('#mensaje').value = args.mensaje;15 return { content: [{ type: 'text', text: 'Formulario rellenado' }] };16 }17);
The description matters: it is what the agent reads to decide when and how to use the tool. A good description is as good as a good contract.
Practical recommendation: register all your tools right after loading the WebMCP script. Some MCP clients only detect the available tools at startup, so they should be declared from the very first moment.
Try It Yourself
Instead of staying with the theory, here is the mechanism actually working in your own browser: a sample form (left) and a sample chat (right), with a registerTool tool registered exactly as explained above. Type a message with your name and email into the chat (or use one of the suggestions) and watch the agent discover the tool, call it with specific arguments and fill in the form on its own. It is exactly the same mechanism the real assistant on this site uses to help fill in the contact form, here isolated and simplified so it is easy to follow.
Pruébalo tú mismo
Escribe en el chat un mensaje con tu nombre y tu email (o usa una sugerencia) y observa cómo el agente llama a la herramienta registrada para rellenar el formulario de la izquierda.
Formulario de contacto (demo)
Es un formulario de ejemplo, aislado: no envía nada real. Solo el agente puede rellenarlo, tú no puedes escribir directamente en él.
Chat con el agente (demo)
Hola 👋 Soy una versión de ejemplo del asistente. Escribe tu nombre y tu email (o usa una sugerencia) y verás cómo relleno el formulario de la izquierda llamando a una herramienta WebMCP.
Ver herramientas registradas
[]
The Key Difference: Actions Live on the Client
The most interesting thing about WebMCP is that the tools run in the user's own browser, with their session and permissions already in place. There is no need to replicate authentication logic or open new endpoints: if the user has access to an action in the interface, the agent runs it on their behalf, within their context.
This brings three advantages that we value especially at Fastex:
- Less backend surface. You don't multiply APIs for every AI integration.
- Privacy by design. Data doesn't have to leave the browser for the action to happen.
- Human oversight. With the sampling mechanism and confirmation dialogs, critical actions still go through the user.
WebMCP and the Direction of the Standard
WebMCP as a library coexists with a broader movement: browsers are starting to offer native mechanisms for pages to declare tools to agents. The underlying idea is always the same, making the web "agent-ready", that is, having it declaratively expose what an agent can do on it, and WebMCP is today the most direct and portable way to achieve that without waiting for everything to be standardized.
How We Apply It at Fastex
We use WebMCP for a very specific and very useful case: a conversational assistant that, when it can't resolve a question, helps the user fill in the contact form. The agent doesn't "guess" what your page looks like; it uses the tools we have explicitly declared for it. That makes it predictable and safe, which is exactly how we like to build at Fastex: AI as a bounded component within a system with clear rules.
If you want to see that use case in full (answering questions with local AI in the browser plus assisted form filling), we walk through it step by step in our article on the chat with Gemini Nano and WebMCP.
Want to bring AI agents to your website in a controlled way and with engineering rigor? At Fastex we design and implement this kind of solution. Get in touch through the contact form.