Repository navigation
Conversation
…193) Enable the standalone SSE GET stream (remove DisableStandaloneSSE) and wire the three list-changed notification handlers (ToolListChangedHandler, PromptListChangedHandler, ResourceListChangedHandler) in Server.dial — the single construction site reused by Connect and reconnect, so a reconnect re-attaches them automatically. Each handler only sets a dirty flag + logs a WARN; it does NOT re-list eagerly (it runs on the SDK's SSE goroutine, where a network call would stall notification processing and could deadlock against s.mu). The accessors (Tools/Resources/Prompts) lazily re-list on the next read under a bounded context.Background(), swapping in the fresh snapshot. The re-list runs WITHOUT s.mu held across the network (only the check + swap hold it) to avoid deadlocking against reconnect, which re-acquires s.mu. No catalog mutation: the registered remoteTool specs are untouched; a tool the server dropped surfaces a tool-call error on use. Live catalog refresh (Phase 2, needs a tool.Catalog Replace/Unregister seam) is deferred to its own ADR. Lifecycle: the SDK spawns one handleSSE goroutine per connected server, drained by session.Close() → conn.Close() cancelling connCtx. Added a goleak gate (leakmain_test.go) with a targeted ignore list for the SDK + stdlib goroutines that unwind asynchronously after close. The SSE stream composes with #177's reconnect: a transient SSE drop is healed by the SDK's own reconnect loop; when that exhausts, the connection fails → next POST surfaces ErrSessionMissing → #177 reconnects the session. Test teardown ordering fix: with SSE on, httptest.Server.Close() blocks if the SDK's SSE reader is still attached. The test fixtures (newTestServer, newToolsOnlyServer, and the internal/app MCP test helpers) now self-register t.Cleanup(httpSrv.Close) so the listener closes AFTER *Server.Close/ mgr.Close (LIFO), and callers no longer defer stop() (which closed the listener before the session). This is the bulk of the test-file churn. Tests: TestToolListChangedNotificationRefreshesSnapshot + TestResourceListChangedNotificationRefreshesSnapshot (the Phase-1 acceptance gate — drive a notifications/tools/list_changed from an in-process server, assert the handler fires + the lazy re-list picks up the new tool). The goleak gate catches a leaked SSE goroutine. Docs: ADR 0057 (frozen), ADR 0027 List 1 row 28 (SSE goroutine inventory), architecture/extensibility.md, PRODUCTION-READINESS.md, llms.txt regenerated. Phase 2 (live catalog refresh) is referenced in ADR 0057 as the deferred follow-up. Closes #193
Contributor
Author
|
Closing in favor of a clean follow-up PR — #195 already merged the pre-review version to main; this PR carries the post-review fixes that need to land separately. |
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.
Closes #193. Phase 1 only (Phase 2 — live catalog refresh — deferred to its own ADR+PR).
Enables the standalone SSE GET stream on the MCP client (removes DisableStandaloneSSE: true) and wires the three listChanged notification handlers on mcpsdk.NewClient in Server.dial — the single construction site reused by Connect and #177's reconnect, so a reconnect re-attaches them automatically.
Design: handlers set a dirty flag + log a WARN (deduped to the false→true transition); accessors lazily re-list under a bounded context.Background(). No catalog mutation (Phase 1). Composes with #177's reconnect. Lifecycle: one persistent handleSSE goroutine per server, drained by session.Close() (ADR 0027 List 1 row 28).
Review: ran the dev-pipeline panel review (spec + standards + secure-code-reviewer + software-architect + QA). Fixed: notification-storm log dedup (Medium), test-helper footgun (Low), ADR latency doc gap (Low), added prompts test (QA). Spec axis clean.
Verification: task lint && task test green; go test -race -count=3 ./internal/adapter/mcp/... green; mecademo smoke intact; llms.txt regenerated.
Out of scope (Phase 2): live catalog refresh (tool.Catalog has no Remove/Replace), ResourceUpdatedHandler, LoggingMessageHandler — own ADR+PR.