Merge pull request #495 from koic/subscriptions_listen
Serve the `subscriptions/listen` notification stream per SEP-2575
This commit is contained in:
commit
ebed930927
1 changed files with 719 additions and 4 deletions
|
|
@ -941,7 +941,7 @@ module MCP
|
|||
def discover(_request)
|
||||
{
|
||||
supportedVersions: Configuration::SUPPORTED_MODERN_PROTOCOL_VERSIONS,
|
||||
capabilities: capabilities,
|
||||
capabilities: discover_capabilities,
|
||||
instructions: instructions,
|
||||
_meta: { RequestEnvelope::SERVER_INFO_META_KEY => server_info },
|
||||
}.compact.merge(
|
||||
|
|
@ -953,6 +953,21 @@ module MCP
|
|||
)
|
||||
end
|
||||
|
||||
# Capabilities as advertised by `server/discover`. In the modern lifecycle, `listChanged` and `subscribe` flags
|
||||
# promise delivery over `subscriptions/listen` streams, so they are stripped when the transport does not serve that RPC
|
||||
# (e.g. stdio), matching the Python SDK's era-aware capability derivation.
|
||||
def discover_capabilities
|
||||
return capabilities if @transport.respond_to?(:serves_subscriptions_listen?) && @transport.serves_subscriptions_listen?
|
||||
|
||||
capabilities.each_with_object({}) do |(name, value), stripped|
|
||||
stripped[name] = if value.is_a?(Hash)
|
||||
value.reject { |flag, _| ["listChanged", "subscribe"].include?(flag.to_s) }
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def configure_logging_level(request, session: nil)
|
||||
if capabilities[:logging].nil?
|
||||
raise RequestHandlerError.new("Server does not support logging", request, error_type: :internal_error)
|
||||
|
|
|
|||
Loading…
Reference in a new issue