Module: MCPClient::DeprecationNotices

Included in:
JsonRpcCommon
Defined in:
lib/mcp_client/deprecation_notices.rb

Overview

The 2026-07-28 deprecation notices raised from the TRANSPORT, so a host that drives a ServerStdio, ServerSSE, ServerHTTP or ServerStreamableHTTP object directly still sees them. Constructing a Client is not the only way to negotiate and serve Roots, Sampling or Logging: on_roots_list_request, on_sampling_request and on_notification are public transport APIs, and a notice tied to the Client constructor never fires for a caller that uses them.

Mixed into JsonRpcCommon, so every transport has it.

Instance Method Summary collapse

Instance Method Details

#warn_input_request_answer_deprecated(method, result) ⇒ void

This method returns an undefined value.

The half of the input-request notice that needs the handler's answer: Roots is deprecated, but answering roots/list with no roots is not use of it (see #warn_roots_deprecated).

Parameters:

  • method (String) —

    the input request's JSON-RPC method

  • result (Hash, nil) —

    the handler's result



90
91
92
# File 'lib/mcp_client/deprecation_notices.rb', line 90

def warn_input_request_answer_deprecated(method, result)
  warn_roots_deprecated(result) if method == 'roots/list'
end

#warn_input_request_deprecated(method, params) ⇒ void

This method returns an undefined value.

The notice for an input request fulfilled through the multi round-trip pattern, whose handler is the same callback the legacy server-initiated request would have reached. Asking for a sample IS the use of Sampling, so its notice is raised before the handler runs; Roots is only used once the answer carries a root, so its notice waits for #warn_input_request_answer_deprecated.

Parameters:

  • method (String) —

    the input request's JSON-RPC method

  • params (Hash, nil) —

    the input request's params



80
81
82
# File 'lib/mcp_client/deprecation_notices.rb', line 80

def warn_input_request_deprecated(method, params)
  warn_sampling_deprecated(params) if method == 'sampling/createMessage'
end

#warn_logging_deprecated ⇒ void

This method returns an undefined value.

Receiving or setting a log level over MCP: the whole Logging page is Deprecated (SEP-2577).



49
50
51
# File 'lib/mcp_client/deprecation_notices.rb', line 49

def warn_logging_deprecated
  MCPClient::Deprecations.warn(:logging, @logger)
end

#warn_request_log_level_deprecated(meta) ⇒ void

This method returns an undefined value.

A request whose effective _meta carries the log level. 2026-07-28 moved the level off logging/setLevel and onto every request, so log_level= and an incoming notifications/message are not the only ways in: a host that puts io.modelcontextprotocol/logLevel in request_meta or in a per-call _meta adopts the same deprecated utility, and JsonRpcCommon#with_request_meta deliberately forwards it on the wire. That is a first use like any other.

Parameters:

  • meta (Hash, nil) —

    the effective outgoing request metadata



62
63
64
65
66
67
68
69
# File 'lib/mcp_client/deprecation_notices.rb', line 62

def warn_request_log_level_deprecated(meta)
  return unless meta.is_a?(Hash)

  key = MCPClient::JsonRpcCommon::META_LOG_LEVEL
  return unless meta.key?(key) || meta.key?(key.to_sym)

  warn_logging_deprecated
end

#warn_roots_deprecated(result) ⇒ void

This method returns an undefined value.

Serving a roots/list request. The Roots capability counts as USED only when the answer actually carries a root: a transport's roots handler is registered independently of whether the host ever configured a root — Client registers one on every server so a later roots= is served, and answers with an empty list until a root is set — so a registered handler is no evidence the host adopted the feature, while a non-empty answer is. A host that never opted in must not be told it is using a deprecated feature.

Parameters:

  • result (Hash, nil) —

    the roots/list result about to be served



26
27
28
29
30
31
# File 'lib/mcp_client/deprecation_notices.rb', line 26

def warn_roots_deprecated(result)
  roots = result.is_a?(Hash) ? (result['roots'] || result[:roots]) : nil
  return unless roots.is_a?(Array) && !roots.empty?

  MCPClient::Deprecations.warn(:roots, @logger)
end

#warn_sampling_deprecated(params = nil) ⇒ void

This method returns an undefined value.

Serving a sampling/createMessage request. SEP-2596 also deprecated the includeContext values "thisServer" and "allServers", which arrive on the very same request, so both notices belong here.

Parameters:

  • params (Hash, nil) (defaults to: nil) —

    the sampling/createMessage params



38
39
40
41
42
43
44
# File 'lib/mcp_client/deprecation_notices.rb', line 38

def warn_sampling_deprecated(params = nil)
  MCPClient::Deprecations.warn(:sampling, @logger)
  value = params.is_a?(Hash) ? params['includeContext'] : nil
  return unless %w[thisServer allServers].include?(value)

  MCPClient::Deprecations.warn(:include_context, @logger, detail: "includeContext #{value}")
end