---
title: "Give in-browser agents your tools · Agent Wranglers"
url: https://agentwranglers.se/playbook/website/ready-for-ai-agents/webmcp
updated: 2026-10-20
licence: "All rights reserved"
---

# Give in-browser agents your tools

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Optional
- Chapter: [Ready for AI agents](https://agentwranglers.se/playbook/website/ready-for-ai-agents)
- Rule: Register the site's tools with the browser through WebMCP. Mark the ones with effects, and report expected failures in the tool's answer.
- How: Where `document.modelContext` exists, call `registerTool` for each tool with its schema. Older builds used `navigator.modelContext`. Set `readOnlyHint` on tools that only read, and `consequentialHint` on tools with effects. A thrown error reaches the agent without its message, so return expected failures as data. WebMCP is a draft from a W3C Community Group, and only some browsers ship it.
- Check: In a browser with WebMCP turned on, the tools appear with their schemas. Calling each one with a bad input returns a readable failure.

Example:

```js
const modelContext = document.modelContext ?? navigator.modelContext;
if (modelContext) {
  modelContext.registerTool({
    name: 'book_call',
    description: 'Book a call at a free time slot.',
    inputSchema: { type: 'object', properties: { slot: { type: 'string' } }, required: ['slot'] },
    annotations: { consequentialHint: true },
    async execute({ slot }) {
      const res = await fetch('/api/book', {
        method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ slot }),
      });
      if (!res.ok) return { booked: false, reason: 'Slot not available, pick another' };
      return { booked: true, slot };
    },
  });
}
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/ready-for-ai-agents/webmcp`.

- Previous: [Answer questions from your own pages](https://agentwranglers.se/playbook/website/ready-for-ai-agents/nlweb)
- Next: [Package your knowledge for agents](https://agentwranglers.se/playbook/website/ready-for-ai-agents/okf-bundle)
- [Ready for AI agents](https://agentwranglers.se/playbook/website/ready-for-ai-agents)
