Skip to content

Route MCP resource subscribe/unsubscribe through Rust gateway - #40

Merged
dawid-nowak merged 7 commits into
mainfrom
user/luca/mcp-subscribe-pass-through
Jul 14, 2026
Merged

Route MCP resource subscribe/unsubscribe through Rust gateway#40
dawid-nowak merged 7 commits into
mainfrom
user/luca/mcp-subscribe-pass-through

Conversation

@lucarlig

Copy link
Copy Markdown
Contributor

Route MCP resources/subscribe and resources/unsubscribe through the Rust gateway, replacing the local in-memory subscription set.

  • subscribe/unsubscribe now 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. Mirrors read_resource/get_prompt.
  • Drops the now-unused subscriptions HashSet field.
  • Adds an integration test: a namespaced subscribe/unsubscribe round-trips to the backend, and an unrouted URI fails with a gateway routing error. The mock backend only accepts its own backend-local URIs, so a successful call proves the prefix was stripped.

Implements IBM/mcp-context-forge#5253

@lucarlig lucarlig self-assigned this Jun 23, 2026
@lucarlig
lucarlig marked this pull request as ready for review June 23, 2026 09:51
@lucarlig
lucarlig requested a review from dawid-nowak June 23, 2026 09:53

@dawid-nowak dawid-nowak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid implementation... and how is this going to work if the customer wants to subscribe to changes on two different MCP servers

lucarlig added 3 commits July 7, 2026 09:59
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
lucarlig force-pushed the user/luca/mcp-subscribe-pass-through branch from cc4be55 to c58ff13 Compare July 7, 2026 09:09
lucarlig added 3 commits July 7, 2026 10:15
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>
@lucarlig

lucarlig commented Jul 9, 2026

Copy link
Copy Markdown
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>
@lucarlig
lucarlig requested a review from dawid-nowak July 13, 2026 20:30
@dawid-nowak
dawid-nowak merged commit add67b7 into main Jul 14, 2026
7 checks passed
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.

2 participants