Repository navigation
feat: support resource subscriptions and list-changed capabilities - #296
Merged
punkpeye merged 1 commit intoJul 21, 2026
Merged
Conversation
Add support for the MCP `resources/subscribe` / `resources/unsubscribe`
methods and per-URI `notifications/resources/updated` notifications, and
advertise the `subscribe` and `listChanged` capabilities so spec-compliant
clients discover them.
- Declare `resources: { listChanged: true, subscribe: true }` and
`prompts: { listChanged: true }` when those capabilities are enabled
(the server already emitted list_changed notifications but never
advertised them).
- Track each session's subscribed URIs and register handlers for
`resources/subscribe` and `resources/unsubscribe`.
- Add `FastMCP#sendResourceUpdated(uri)` (and the session-level
equivalent) to notify only the clients subscribed to that URI.
closes punkpeye#185
|
🎉 This PR is included in version 4.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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 #185.
Adds support for MCP resource subscriptions and makes the server's list-changed capabilities discoverable.
What's added
resources: { listChanged: true, subscribe: true }andprompts: { listChanged: true }when those features are enabled. The server already emittednotifications/resources/list_changedandnotifications/prompts/list_changed, but never advertised the capability, so spec-compliant clients didn't know to expect them.resources/subscribeandresources/unsubscribe, tracked per session.server.sendResourceUpdated(uri)emitsnotifications/resources/updatedonly to clients that subscribed to that URI (spec).Example
sendResourceUpdatedis a no-op for URIs no client has subscribed to, so it's safe to call whenever data changes.Design note
subscribe: trueis advertised for every server that exposes resources rather than being gated behind an opt-in flag, since the subscribe/update plumbing is generic andsendResourceUpdatedis a no-op for URIs nobody subscribed to. If you'd rather make it opt-in, happy to gate it behind a flag.Spec references
resources/subscribe,resources/unsubscribe,notifications/resources/updated: https://modelcontextprotocol.io/specification/2025-06-18/server/resources#subscriptionslistChangednotifications for resources and prompts.Tests
New
src/FastMCP.resource-subscriptions.test.tscovers capability advertisement (resources + prompts), notification delivery to a subscribed client, no delivery without a subscription, and unsubscribe stopping delivery. Full suite green: 388 tests passing, plusprettier,eslint, andtsc --noEmitall clean.