Support AbortSignal-based tool unregistration (Chrome 148)#21
Open
kashishhora wants to merge 1 commit intomainfrom
Open
Support AbortSignal-based tool unregistration (Chrome 148)#21kashishhora wants to merge 1 commit intomainfrom
kashishhora wants to merge 1 commit intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Chrome 148 removes
unregisterTool()fromnavigator.modelContextand replaces it with anAbortSignalpassed toregisterTool(). This aligns with theaddEventListenerownership pattern — you can only unregister a tool if you hold the originalAbortController.What changed
Types (
src/types.ts,src/index.ts)RegisterToolOptionsinterface with optionalsignal?: AbortSignalregisterToolaccepts optional second argoptions?: RegisterToolOptionsunregisterToolis now optional (?) — won't exist on Chrome 148+RegisterToolOptionsexported for consumersPolyfill registry (
src/polyfill/registry.ts)registerToolaccepts signal optionunregisterToolstays on the polyfill for backward compatReact hook (
src/hooks/useMcpTool.ts)AbortControllerper effect cycle{ signal }toregisterToolmc.unregisterTool?.(name)(optional chaining) +controller.abort()Breaking change
navigator.modelContext.unregisterToolis now typed as optional. Downstream TS code calling it directly must add optional chaining (?.). This matches the Chrome 148 runtime behavior.Testing
pnpm test— 158/158 passpnpm typecheck— cleanpnpm lint— cleanpnpm build— CJS + ESM + types build successfullyNew tests: