77require_relative "methods"
88require_relative "logging_message_notification"
99require_relative "progress"
10+ require_relative "protocol_deprecations"
1011require_relative "server_context"
1112require_relative "server/capabilities"
1213require_relative "server/pagination"
@@ -140,6 +141,7 @@ def initialize(
140141 self . page_size = page_size
141142 @configuration = MCP . configuration . merge ( configuration )
142143 @client = nil
144+ @client_protocol_version = nil
143145
144146 validate!
145147
@@ -256,7 +258,12 @@ def notify_resources_list_changed
256258 report_exception ( e , { notification : "resources_list_changed" } )
257259 end
258260
261+ # @deprecated MCP Logging (`logging/setLevel` and `notifications/message`)
262+ # is deprecated as of MCP protocol version 2026-07-28 (SEP-2577).
263+ # Use stderr or OpenTelemetry instead.
259264 def notify_log_message ( data :, level :, logger : nil )
265+ warn_if_deprecated_protocol_feature ( :logging , uplevel : 1 )
266+
260267 return unless @transport
261268 return unless logging_message_notification &.should_notify? ( level )
262269
@@ -272,7 +279,13 @@ def notify_log_message(data:, level:, logger: nil)
272279 # Called when a client notifies the server that its filesystem roots have changed.
273280 #
274281 # @yield [params] The notification params (typically `nil`).
282+ # @deprecated MCP Roots (`roots/list` and
283+ # `notifications/roots/list_changed`) is deprecated as of MCP protocol
284+ # version 2026-07-28 (SEP-2577). Use tool parameters, resource URIs,
285+ # server configuration, or environment variables instead.
275286 def roots_list_changed_handler ( &block )
287+ warn_if_deprecated_protocol_feature ( :roots , uplevel : 1 )
288+
276289 @handlers [ Methods ::NOTIFICATIONS_ROOTS_LIST_CHANGED ] = block
277290 end
278291
@@ -430,6 +443,13 @@ def handle_request(request, method, session: nil, related_request_id: nil)
430443 return -> ( params ) { handle_cancelled_notification ( params , session : session ) }
431444 end
432445
446+ case method
447+ when Methods ::NOTIFICATIONS_ROOTS_LIST_CHANGED
448+ warn_if_deprecated_protocol_feature ( :roots , session : session , uplevel : 2 )
449+ when Methods ::LOGGING_SET_LEVEL
450+ warn_if_deprecated_protocol_feature ( :logging , session : session , uplevel : 2 )
451+ end
452+
433453 handler = @handlers [ method ]
434454 unless handler
435455 instrument_call ( "unsupported_method" , server_context : { request : request } ) do
@@ -568,7 +588,11 @@ def init(params, session: nil)
568588 response_instructions = nil
569589 end
570590
571- session &.mark_initialized!
591+ if session
592+ session . mark_initialized! ( protocol_version : negotiated_version )
593+ else
594+ @client_protocol_version = negotiated_version
595+ end
572596
573597 {
574598 protocolVersion : negotiated_version ,
@@ -594,6 +618,19 @@ def configure_logging_level(request, session: nil)
594618 { }
595619 end
596620
621+ def warn_if_deprecated_protocol_feature ( feature , session : nil , uplevel : 1 )
622+ protocol_version = effective_deprecation_protocol_version ( session )
623+ MCP ::ProtocolDeprecations . warn_for ( feature , protocol_version : protocol_version , uplevel : uplevel )
624+ end
625+
626+ def effective_deprecation_protocol_version ( session )
627+ session &.protocol_version || @client_protocol_version || explicit_protocol_version
628+ end
629+
630+ def explicit_protocol_version
631+ configuration . protocol_version if configuration . protocol_version?
632+ end
633+
597634 def list_tools ( request )
598635 page = paginate ( @tools . values , cursor : cursor_from ( request ) , page_size : @page_size , request : request , &:to_h )
599636
0 commit comments