Skip to content

Tool descriptor updates, toolchange event, and registration error handling#24

Merged
kashishhora merged 4 commits into
mainfrom
feat/webmcp-descriptor-and-events
Jun 23, 2026
Merged

Tool descriptor updates, toolchange event, and registration error handling#24
kashishhora merged 4 commits into
mainfrom
feat/webmcp-descriptor-and-events

Conversation

@kashishhora

Copy link
Copy Markdown
Member

Summary

Builds on the document.modelContext migration (#23). Updates the tool descriptor to the current spec shape, adds the toolchange event, and makes registration error handling robust:

  • Annotations narrowed to { readOnlyHint?, untrustedContentHint? } and a top-level title added to the tool config/descriptor (the classic destructiveHint / idempotentHint / openWorldHint and annotations.title are dropped, matching the spec).
  • exposedTo?: string[] is forwarded from the tool config to registerTool, and the tool re-registers when it changes.
  • toolchange event on document.modelContext (now an EventTarget) — supports addEventListener('toolchange', …) and an ontoolchange handler. Notifications fan out to the testing shim and the event dispatcher.
  • Registration error handling: rejections route into the hook's error state + onError (AbortError from teardown is ignored). Ownership uses compare-and-set so a duplicate-name registration can't evict the existing owner. schemaFingerprint is hardened against non-serializable schemas so a bad schema can't throw during render.

Test plan

  • pnpm typecheck — clean
  • pnpm lint — clean
  • pnpm test — 171 passing (Vitest + jsdom, incl. StrictMode double-mount + duplicate-name ownership)
  • pnpm build

@kashishhora kashishhora requested a review from naji247 June 23, 2026 19:59
@kashishhora kashishhora merged commit 59c0322 into main Jun 23, 2026
3 checks passed
@kashishhora kashishhora deleted the feat/webmcp-descriptor-and-events branch June 23, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants