Problem
Server#resources_subscribe_handler / resources_unsubscribe_handler accept a block, but the dispatch path invokes the handler and then unconditionally responds with an empty object — the handler's return value is discarded (lib/mcp/server.rb:622-625 at ref f0c9665):
when Methods::RESOURCES_SUBSCRIBE, Methods::RESOURCES_UNSUBSCRIBE
validate_resource_subscription_params!(params)
dispatch_optional_context_handler(@handlers[method], params, ...)
{}
So a server cannot include anything in the subscribe response (e.g. a subscription identifier for later correlation, or advisory metadata). The handler is effectively side-effect-only, which is surprising given other handlers' return values shape the response.
If this is intentional (the spec's resources/subscribe result is an empty object), a doc note on resources_subscribe_handler saying the return value is ignored would prevent the surprise — we hit this while migrating from a hand-rolled server whose subscribe response carried a subscriptionId, and pinned the difference in our compatibility specs after discovering the discard empirically.
Context
Production MCP surface on Rails, recently cut over to this gem. Related prior contribution: #493.
Problem
Server#resources_subscribe_handler/resources_unsubscribe_handleraccept a block, but the dispatch path invokes the handler and then unconditionally responds with an empty object — the handler's return value is discarded (lib/mcp/server.rb:622-625at ref f0c9665):So a server cannot include anything in the subscribe response (e.g. a subscription identifier for later correlation, or advisory metadata). The handler is effectively side-effect-only, which is surprising given other handlers' return values shape the response.
If this is intentional (the spec's
resources/subscriberesult is an empty object), a doc note onresources_subscribe_handlersaying the return value is ignored would prevent the surprise — we hit this while migrating from a hand-rolled server whose subscribe response carried asubscriptionId, and pinned the difference in our compatibility specs after discovering the discard empirically.Context
Production MCP surface on Rails, recently cut over to this gem. Related prior contribution: #493.