Skip to content

feat(transport): route notifications/resources/updated to subscribed clients#48

Open
DevAnuragT wants to merge 1 commit intoContextVM:masterfrom
DevAnuragT:feat/resource-updated-routing
Open

feat(transport): route notifications/resources/updated to subscribed clients#48
DevAnuragT wants to merge 1 commit intoContextVM:masterfrom
DevAnuragT:feat/resource-updated-routing

Conversation

@DevAnuragT
Copy link
Copy Markdown
Contributor

Fixes #45

Description

This PR properly routes notifications/resources/updated notifications to only the specific clients that have actively subscribed to those resources, replacing the previous fallback behavior that broadcasted these notifications to all initialized sessions.

This completes the missing handler tracking mentioned in the TODO comment in nostr-server-transport.ts.

Changes Made

  • Subscription Tracking: Added a resourceSubscriptions Map to NostrServerTransport mapping resource URIs to the set of subscribed client public keys.
  • Request Interception: handleIncomingRequest now hooks into resources/subscribe and resources/unsubscribe MCP method names to securely track intent.
  • Targeted Routing: When the MCP server emits a notifications/resources/updated notification, the transport reads the uri and relays it specifically to the subscribed clients.
  • Cleanup: Added garbage collection for resource subscriptions when a client session gets evicted or when the transport fully closes.
  • Added corresponding method name constants to constants.ts.

Testing Performed

  • Analyzed existing test coverage ensuring no regressions.
  • Ran all existing integration tests for the nostr-server-transport which passed successfully.

@DevAnuragT
Copy link
Copy Markdown
Contributor Author

It looks like the CI hit the same bun test --concurrent mock-relay socket timeouts that are currently happening randomly on master. If you'd like, I'm happy to open a quick separate PR to drop the --concurrent flag from the workflow to stabilize the checks else the actual transport logic changes here are all tested and working.
Same happening with PR #47

@1amKhush
Copy link
Copy Markdown
Contributor

1amKhush commented Apr 9, 2026

@DevAnuragT I have made a specifed PR for the corresponding issue - falky behaviour of the test runs. Can you try to run the tests again once it gets merged to verify the fix. Thanks!

@DevAnuragT
Copy link
Copy Markdown
Contributor Author

@DevAnuragT I have made a specifed PR for the corresponding issue - falky behaviour of the test runs. Can you try to run the tests again once it gets merged to verify the fix. Thanks!

yeah sure, I'll keep an eye on it.

@DevAnuragT DevAnuragT force-pushed the feat/resource-updated-routing branch from d5ae7b4 to 8eb247c Compare April 12, 2026 16:44
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.

feat(transport): implement notifications/resources/updated handling

2 participants