mcp: debounce server change notifications (#717)

Debounce and batch notifications for changes in server feature sets
(adding or removing tools, prompts, resources, or resource templates).

This PR handles server-side change notifications only. We could do the
same for client-side notifications (e.g. roots changed), but at the
moment we don't need to.

Fixes #649.
This commit is contained in:
Robert Findley 2025-12-11 15:11:32 -05:00 • committed by GitHub
commit 1a964ae23d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -394,6 +394,8 @@ func notifySessions[S Session, P Params](sessions []S, method string, params P,
if sessions == nil {
return
}
// Notify with the background context, so the messages are sent on the
// standalone stream.
// TODO: make this timeout configurable, or call handleNotify asynchronously.
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()