mcp 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,6 +54,9 @@ module MCP
54
54
  end
55
55
 
56
56
  # Delegates to the session so the request is scoped to the originating client.
57
+ # The originating request id is stamped as `related_request_id`, satisfying
58
+ # SEP-2260's requirement that server-to-client requests be associated with
59
+ # the client request being processed.
57
60
  # @deprecated MCP Roots (`roots/list` and
58
61
  # `notifications/roots/list_changed`) is deprecated as of MCP protocol
59
62
  # version 2026-07-28 (SEP-2577). Use tool parameters, resource URIs,
@@ -91,6 +94,11 @@ module MCP
91
94
  # Delegates to the session so the request is scoped to the originating client.
92
95
  # Falls back to `@context` (via `method_missing`) when `@notification_target`
93
96
  # does not support sampling.
97
+ #
98
+ # The originating request id is stamped as `related_request_id` and cannot be
99
+ # overridden by callers (the literal keyword after `**kwargs` wins),
100
+ # satisfying SEP-2260's requirement that server-to-client requests be
101
+ # associated with the client request being processed.
94
102
  # @deprecated MCP Sampling (`sampling/createMessage`) is deprecated as of
95
103
  # MCP protocol version 2026-07-28 (SEP-2577). Use direct LLM provider
96
104
  # APIs instead.
@@ -107,6 +115,8 @@ module MCP
107
115
  # Delegates to the session so the request is scoped to the originating client.
108
116
  # Falls back to `@context` (via `method_missing`) when `@notification_target`
109
117
  # does not support elicitation.
118
+ # The originating request id is stamped as a non-overridable
119
+ # `related_request_id`, as with `create_sampling_message` (SEP-2260).
110
120
  def create_form_elicitation(**kwargs)
111
121
  if @notification_target.respond_to?(:create_form_elicitation)
112
122
  @notification_target.create_form_elicitation(**kwargs, related_request_id: @related_request_id)
@@ -119,6 +129,8 @@ module MCP
119
129
 
120
130
  # Delegates to the session so the request is scoped to the originating client.
121
131
  # Falls back to `@context` when `@notification_target` does not support URL mode elicitation.
132
+ # The originating request id is stamped as a non-overridable `related_request_id`,
133
+ # as with `create_sampling_message` (SEP-2260).
122
134
  def create_url_elicitation(**kwargs)
123
135
  if @notification_target.respond_to?(:create_url_elicitation)
124
136
  @notification_target.create_url_elicitation(**kwargs, related_request_id: @related_request_id)
@@ -98,11 +98,17 @@ module MCP
98
98
  end
99
99
 
100
100
  # Sends a `roots/list` request scoped to this session.
101
+ #
102
+ # Per SEP-2260, the request must be associated with an originating client
103
+ # request; prefer `server_context.list_roots` inside a handler, which stamps
104
+ # the association automatically.
101
105
  # @deprecated MCP Roots (`roots/list` and
102
106
  # `notifications/roots/list_changed`) is deprecated as of MCP protocol
103
107
  # version 2026-07-28 (SEP-2577). Use tool parameters, resource URIs,
104
108
  # server configuration, or environment variables instead.
105
109
  def list_roots(related_request_id: nil)
110
+ warn_unassociated_request(__method__, related_request_id)
111
+
106
112
  unless client_capabilities&.dig(:roots)
107
113
  raise "Client does not support roots."
108
114
  end
@@ -119,16 +125,28 @@ module MCP
119
125
  end
120
126
 
121
127
  # Sends a `sampling/createMessage` request scoped to this session.
128
+ #
129
+ # Per SEP-2260, the request must be associated with an originating client
130
+ # request; prefer `server_context.create_sampling_message` inside a handler,
131
+ # which stamps the association automatically.
122
132
  # @deprecated MCP Sampling (`sampling/createMessage`) is deprecated as of
123
133
  # MCP protocol version 2026-07-28 (SEP-2577). Use direct LLM provider
124
134
  # APIs instead.
125
135
  def create_sampling_message(related_request_id: nil, **kwargs)
136
+ warn_unassociated_request(__method__, related_request_id)
137
+
126
138
  params = @server.build_sampling_params(client_capabilities, **kwargs)
127
139
  send_to_transport_request(Methods::SAMPLING_CREATE_MESSAGE, params, related_request_id: related_request_id)
128
140
  end
129
141
 
130
142
  # Sends an `elicitation/create` request (form mode) scoped to this session.
143
+ #
144
+ # Per SEP-2260, the request must be associated with an originating client
145
+ # request; prefer `server_context.create_form_elicitation` inside a handler,
146
+ # which stamps the association automatically.
131
147
  def create_form_elicitation(message:, requested_schema:, related_request_id: nil)
148
+ warn_unassociated_request(__method__, related_request_id)
149
+
132
150
  unless client_capabilities&.dig(:elicitation)
133
151
  raise "Client does not support elicitation. " \
134
152
  "The client must declare the `elicitation` capability during initialization."
@@ -139,7 +157,13 @@ module MCP
139
157
  end
140
158
 
141
159
  # Sends an `elicitation/create` request (URL mode) scoped to this session.
160
+ #
161
+ # Per SEP-2260, the request must be associated with an originating client
162
+ # request; prefer `server_context.create_url_elicitation` inside a handler,
163
+ # which stamps the association automatically.
142
164
  def create_url_elicitation(message:, url:, elicitation_id:, related_request_id: nil)
165
+ warn_unassociated_request(__method__, related_request_id)
166
+
143
167
  unless client_capabilities&.dig(:elicitation, :url)
144
168
  raise "Client does not support URL mode elicitation. " \
145
169
  "The client must declare the `elicitation.url` capability during initialization."
@@ -264,5 +288,21 @@ module MCP
264
288
  # The explicit splat suppresses that conversion and is a no-op when `supported` is empty.
265
289
  transport_method.call(method, params, **supported)
266
290
  end
291
+
292
+ # Per SEP-2260, servers MUST send `roots/list`, `sampling/createMessage`, and `elicitation/create` only
293
+ # in association with an originating client request (`ping` is exempt). A request without `related_request_id:` is
294
+ # delivered on the standalone GET stream by the Streamable HTTP transport, which the 2026-07-28 spec forbids;
295
+ # warn so callers migrate to the `server_context` helpers before this becomes an error.
296
+ # https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2260
297
+ def warn_unassociated_request(method_name, related_request_id)
298
+ return if related_request_id
299
+
300
+ warn(
301
+ "Calling `ServerSession##{method_name}` without `related_request_id:` is deprecated (SEP-2260): " \
302
+ "server-to-client #{method_name} requests must be associated with an originating client request. " \
303
+ "Use `server_context.#{method_name}` inside a handler, or pass `related_request_id:` explicitly.",
304
+ uplevel: 2,
305
+ )
306
+ end
267
307
  end
268
308
  end
data/lib/mcp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MCP
4
- VERSION = "0.23.0"
4
+ VERSION = "0.25.0"
5
5
  end
data/lib/mcp.rb CHANGED
@@ -8,14 +8,17 @@ require_relative "mcp/version"
8
8
 
9
9
  module MCP
10
10
  autoload :Annotations, "mcp/annotations"
11
+ autoload :Apps, "mcp/apps"
11
12
  autoload :Cancellation, "mcp/cancellation"
12
13
  autoload :CancelledError, "mcp/cancelled_error"
13
14
  autoload :Client, "mcp/client"
14
15
  autoload :Content, "mcp/content"
16
+ autoload :ErrorCodes, "mcp/error_codes"
15
17
  autoload :Icon, "mcp/icon"
16
18
  autoload :Prompt, "mcp/prompt"
17
19
  autoload :Resource, "mcp/resource"
18
20
  autoload :ResourceTemplate, "mcp/resource_template"
21
+ autoload :ResultType, "mcp/result_type"
19
22
  autoload :Server, "mcp/server"
20
23
  autoload :ServerSession, "mcp/server_session"
21
24
  autoload :Tool, "mcp/tool"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Model Context Protocol
@@ -37,15 +37,20 @@ files:
37
37
  - lib/json_rpc_handler.rb
38
38
  - lib/mcp.rb
39
39
  - lib/mcp/annotations.rb
40
+ - lib/mcp/apps.rb
40
41
  - lib/mcp/cancellation.rb
41
42
  - lib/mcp/cancelled_error.rb
42
43
  - lib/mcp/client.rb
44
+ - lib/mcp/client/elicitation.rb
43
45
  - lib/mcp/client/http.rb
44
46
  - lib/mcp/client/oauth.rb
45
47
  - lib/mcp/client/oauth/client_credentials_provider.rb
48
+ - lib/mcp/client/oauth/cross_app_access_provider.rb
46
49
  - lib/mcp/client/oauth/discovery.rb
47
50
  - lib/mcp/client/oauth/flow.rb
51
+ - lib/mcp/client/oauth/id_jag_token_exchange.rb
48
52
  - lib/mcp/client/oauth/in_memory_storage.rb
53
+ - lib/mcp/client/oauth/jwt_client_assertion.rb
49
54
  - lib/mcp/client/oauth/pkce.rb
50
55
  - lib/mcp/client/oauth/provider.rb
51
56
  - lib/mcp/client/oauth/storage_backed_provider.rb
@@ -54,6 +59,7 @@ files:
54
59
  - lib/mcp/client/tool.rb
55
60
  - lib/mcp/configuration.rb
56
61
  - lib/mcp/content.rb
62
+ - lib/mcp/error_codes.rb
57
63
  - lib/mcp/icon.rb
58
64
  - lib/mcp/instrumentation.rb
59
65
  - lib/mcp/logging_message_notification.rb
@@ -67,6 +73,7 @@ files:
67
73
  - lib/mcp/resource/contents.rb
68
74
  - lib/mcp/resource/embedded.rb
69
75
  - lib/mcp/resource_template.rb
76
+ - lib/mcp/result_type.rb
70
77
  - lib/mcp/server.rb
71
78
  - lib/mcp/server/capabilities.rb
72
79
  - lib/mcp/server/pagination.rb
@@ -90,7 +97,7 @@ licenses:
90
97
  - Apache-2.0
91
98
  metadata:
92
99
  allowed_push_host: https://rubygems.org
93
- changelog_uri: https://github.com/modelcontextprotocol/ruby-sdk/releases/tag/v0.23.0
100
+ changelog_uri: https://github.com/modelcontextprotocol/ruby-sdk/releases/tag/v0.25.0
94
101
  homepage_uri: https://ruby.sdk.modelcontextprotocol.io
95
102
  source_code_uri: https://github.com/modelcontextprotocol/ruby-sdk
96
103
  bug_tracker_uri: https://github.com/modelcontextprotocol/ruby-sdk/issues
@@ -109,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
116
  - !ruby/object:Gem::Version
110
117
  version: '0'
111
118
  requirements: []
112
- rubygems_version: 4.0.10
119
+ rubygems_version: 4.0.16
113
120
  specification_version: 4
114
121
  summary: The official Ruby SDK for Model Context Protocol servers and clients
115
122
  test_files: []