Skip to content

document.modelContext.registerTool() now returns a promise #2

Description

@aogz

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions