---
name: webmcp
description: Register WebMCP tools on the page via navigator.modelContext
---

# WebMCP — register tools in the browser

Expose your site's actions as agent-callable tools by registering them with `navigator.modelContext` on the homepage.

## Requirements

- Inline a script (or load one early) on the homepage
- Call `navigator.modelContext.registerTool({...})` for each exposed action
- Each tool needs: `name`, `description`, `inputSchema` (JSON Schema), `execute(input)`

## Example

```html
<script type="module">
if ("modelContext" in navigator) {
  navigator.modelContext.registerTool({
    name: "search_products",
    description: "Search the product catalog",
    inputSchema: {
      type: "object",
      properties: { query: { type: "string" } },
      required: ["query"]
    },
    execute: async ({ query }) => {
      const r = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
      return r.json();
    }
  });
}
</script>
```

## References

- [WebMCP draft spec](https://webmachinelearning.github.io/webmcp/)
- [Chrome WebMCP origin trial](https://developer.chrome.com/blog/webmcp-epp)
