Skip to content

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

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

Activity

  1. domfarolino commented on Mar 5, 2026

    @domfarolino
    Collaborator

    Hey, thanks for filing this! It looks like you wrote this at the same time I was writing #130, and you beat me to it. I left a whole braindump over there of different design approaches we can take. I made to capture the approach you mention above among the few others I outlined. Since the OP over there has a full list of options forward, do you mind if we continue discussion in that issue, just so we have a full record of our options to choose from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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