Skip to content

Prevent scripts from unregistering tools they didn't register #129

@victorhuangwq

Description

@victorhuangwq

Spun out from #101

If tool unregistration is purely using a string match, navigator.modelContext.unregisterTool('tool_name'), this can be an easy footgun. For example, if a site imports two third-party scripts and they both register webmcp tools, one script could easily unregister the other's tool by accident. (If the scripts are doing this on purpose... that's really a different problem altogether).

One idea from the above mentioned issue was to have registerTool return a teardown handle instead of using a global method. This naturally scopes the unregister capability to the component that registered it:

const unregister = navigator.modelContext.registerTool({ name: 'my_tool', ... });
unregister();

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