Route MCP resource subscribe/unsubscribe through Rust gateway - #40
Merged
Conversation
dawid-nowak
reviewed
Jul 7, 2026
dawid-nowak
left a comment
Contributor
There was a problem hiding this comment.
Is this valid implementation... and how is this going to work if the customer wants to subscribe to changes on two different MCP servers
Replace the local in-memory subscription set with real backend routing: subscribe/unsubscribe now validate the request, split the namespaced resource URI, resolve the single owning backend, and forward the call with the prefix stripped, returning backend and routing errors instead of reporting local-only success. Mirrors read_resource/get_prompt and drops the now-unused subscriptions HashSet field. The mock backend gains subscribe/unsubscribe handlers that only accept its own backend-local URIs, and a new integration test proves a namespaced subscribe/unsubscribe round-trips to the backend and that an unrouted URI fails with a gateway routing error. Implements IBM/mcp-context-forge#5253 Signed-off-by: lucarlig <luca.carlig@ibm.com>
Now that subscribe/unsubscribe route to backends, declare the resources.subscribe server capability so spec-compliant clients discover and use the feature. Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
lucarlig
force-pushed
the
user/luca/mcp-subscribe-pass-through
branch
from
July 7, 2026 09:09
cc4be55 to
c58ff13
Compare
Signed-off-by: lucarlig <luca.carlig@ibm.com>
call_tool, read_resource, get_prompt, complete, subscribe, and unsubscribe all repeated the same split-prefix/resolve-backend preamble; extract it into route_prefixed_name. Signed-off-by: lucarlig <luca.carlig@ibm.com>
The mock backend now notifies on an interval and deliberately keeps notifying after unsubscribe, so the round-trip test can assert the gateway itself stops forwarding updates for unsubscribed URIs. This also decouples the test's update threshold from a hardcoded mock notification count. Signed-off-by: lucarlig <luca.carlig@ibm.com>
Contributor
Author
|
@dawid-nowak we were just forwarding the sub unsub no forwarding changes derived from subscription, i have implemented that now |
Add prefixed_name as the inverse of split_prefixed_name and route all namespace joins through it, share one backend_forward_error helper across the forwarding handlers, make subscription tracking take &str, and reuse the support connect/config helpers instead of per-test copies. Signed-off-by: lucarlig <luca.carlig@ibm.com>
dawid-nowak
approved these changes
Jul 14, 2026
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.
Route MCP
resources/subscribeandresources/unsubscribethrough the Rust gateway, replacing the local in-memory subscription set.subscribe/unsubscribenow validate the request, split the namespaced resource URI, resolve the single owning backend (split_prefixed_name+resolve_backend), and forward the call with the prefix stripped — returning backend and routing errors instead of local-only success. Mirrorsread_resource/get_prompt.subscriptionsHashSetfield.Implements IBM/mcp-context-forge#5253