Published: May 18, 2026, Last updated: September 11, 2026
| Explainer | Web | Extensions | Chrome Status | Intent |
|---|---|---|---|---|
| GitHub | View | Intent to Experiment |
You can use the WebMCP Imperative API to define many types of tools with standard JavaScript. Your tools can execute different functions, such as form input, site navigation, and state management.
Before using this API, read about example use cases.
Provide model context
Use the modelContext interface to register tools. Tool registration requires
a name, description, and input schema with relevant properties.
Use registerTool to add a single tool to the model context.
WebMCPza Maker
await document.modelContext.registerTool({
name: 'toggle_layer',
description: 'Control pizza layers (sauce, cheese). Use "add", "remove", or "toggle".',
inputSchema: {
type: 'object',
properties: {
layer: { type: 'string', enum: ['sauce-layer', 'cheese-layer'] },
action: { type: 'string', enum: ['add', 'remove', 'toggle'] },
},
required: ['layer'],
},
execute: async ({ layer, action }) => {
await toggleLayer(layer,