The document.modelContext.registerTool() method now returns a promise in Chrome 151.0.7922.0.
This change, detailed in Issue #175, is necessary because cross-origin iframe integration allows tools to be shared across the frame tree, making registration fundamentally asynchronous. The Promise-based approach accurately reflects this process and resolves only when the tool is actually available to getTools() in other documents. This update ensures better error handling and forward compatibility as the API evolves.
Please update your code to use the new asynchronous pattern shown below. For practical examples, see how we updated our WebMCP demos in PR #228.
try {
await document.modelContext.registerTool(myTool);
} catch (e) {
console.error('Tool registration failed:', e);
}
The document.modelContext.registerTool() method now returns a promise in Chrome 151.0.7922.0.
This change, detailed in Issue #175, is necessary because cross-origin iframe integration allows tools to be shared across the frame tree, making registration fundamentally asynchronous. The Promise-based approach accurately reflects this process and resolves only when the tool is actually available to getTools() in other documents. This update ensures better error handling and forward compatibility as the API evolves.
Please update your code to use the new asynchronous pattern shown below. For practical examples, see how we updated our WebMCP demos in PR #228.