mcp 1.10.0 → 1.11.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.
@@ -3,6 +3,7 @@
3
3
  module MCP
4
4
  class Server
5
5
  module Transports
6
+ autoload :EventStore, "mcp/server/transports/event_store"
6
7
  autoload :StdioTransport, "mcp/server/transports/stdio_transport"
7
8
  autoload :StreamableHTTPTransport, "mcp/server/transports/streamable_http_transport"
8
9
  end
data/lib/mcp/server.rb CHANGED
@@ -824,6 +824,7 @@ module MCP
824
824
  when Methods::INITIALIZE
825
825
  init(params, session: session)
826
826
  when Methods::RESOURCES_READ
827
+ validate_resource_read_params!(params)
827
828
  contents = read_resource_contents(params, instrumentation_data: instrumentation_data, session: session, related_request_id: related_request_id, cancellation: cancellation, envelope: envelope, auth_info: auth_info)
828
829
 
829
830
  # An SEP-2322 `input_required` result must not be wrapped as `contents` or stamped with SEP-2549 cache hints.
@@ -1286,6 +1287,12 @@ module MCP
1286
1287
  }.compact
1287
1288
  end
1288
1289
 
1290
+ def validate_resource_read_params!(params)
1291
+ unless params.is_a?(Hash) && params[:uri].is_a?(String)
1292
+ raise RequestHandlerError.new("Missing or invalid uri", params, error_type: :invalid_params)
1293
+ end
1294
+ end
1295
+
1289
1296
  def validate_resource_subscription_params!(params)
1290
1297
  unless params.is_a?(Hash) && params[:uri].is_a?(String)
1291
1298
  raise RequestHandlerError.new("Missing or invalid uri", params, error_type: :invalid_params)
@@ -154,6 +154,25 @@ module MCP
154
154
  @notification_target.notify_resources_updated(uri: uri)
155
155
  end
156
156
 
157
+ # Closes the SSE connection carrying the current request's stream without ending the request (SEP-1699):
158
+ # the client reconnects with `Last-Event-ID` after the transport's `retry_interval`, and the messages
159
+ # the handler emits meanwhile are replayed to it. Use it to let a long-running operation go on without
160
+ # a connection held open for it. Returns `true` when a connection was closed and `false` when there was none to close:
161
+ # a transport without an event store, a client that negotiated a protocol version before 2025-11-25,
162
+ # a request answered as JSON, or a connection closed already.
163
+ def close_sse_stream
164
+ return false unless @related_request_id && @notification_target.respond_to?(:close_sse_stream)
165
+
166
+ @notification_target.close_sse_stream(related_request_id: @related_request_id)
167
+ end
168
+
169
+ # Closes the session's standalone GET stream the same way, so the client polls for server-initiated messages.
170
+ def close_standalone_sse_stream
171
+ return false unless @notification_target.respond_to?(:close_standalone_sse_stream)
172
+
173
+ @notification_target.close_standalone_sse_stream
174
+ end
175
+
157
176
  # Delegates to the session so the request is scoped to the originating client.
158
177
  # The originating request id is stamped as `related_request_id`, satisfying
159
178
  # SEP-2260's requirement that server-to-client requests be associated with
@@ -323,6 +323,22 @@ module MCP
323
323
  @server.configuration.exception_reporter.call(e, { notification: "log_message" })
324
324
  end
325
325
 
326
+ # Closes the SSE connection of the request `related_request_id` without ending the request (SEP-1699), so
327
+ # the client polls the stream by reconnecting with `Last-Event-ID`; prefer `server_context.close_sse_stream`
328
+ # inside a handler, which names the current request. Returns `false` on a transport without resumable streams.
329
+ def close_sse_stream(related_request_id:)
330
+ return false unless @transport.respond_to?(:close_sse_stream)
331
+
332
+ @transport.close_sse_stream(@session_id, related_request_id)
333
+ end
334
+
335
+ # Closes the session's standalone GET stream the same way.
336
+ def close_standalone_sse_stream
337
+ return false unless @transport.respond_to?(:close_standalone_sse_stream)
338
+
339
+ @transport.close_standalone_sse_stream(@session_id)
340
+ end
341
+
326
342
  private
327
343
 
328
344
  def validate_era!(era)
data/lib/mcp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MCP
4
- VERSION = "1.10.0"
4
+ VERSION = "1.11.0"
5
5
  end
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: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Model Context Protocol
@@ -102,6 +102,7 @@ files:
102
102
  - lib/mcp/server/pending_response.rb
103
103
  - lib/mcp/server/request_state_security.rb
104
104
  - lib/mcp/server/transports.rb
105
+ - lib/mcp/server/transports/event_store.rb
105
106
  - lib/mcp/server/transports/stdio_transport.rb
106
107
  - lib/mcp/server/transports/streamable_http_transport.rb
107
108
  - lib/mcp/server_context.rb
@@ -125,7 +126,7 @@ licenses:
125
126
  - Apache-2.0
126
127
  metadata:
127
128
  allowed_push_host: https://rubygems.org
128
- changelog_uri: https://github.com/modelcontextprotocol/ruby-sdk/releases/tag/v1.10.0
129
+ changelog_uri: https://github.com/modelcontextprotocol/ruby-sdk/releases/tag/v1.11.0
129
130
  homepage_uri: https://ruby.sdk.modelcontextprotocol.io
130
131
  source_code_uri: https://github.com/modelcontextprotocol/ruby-sdk
131
132
  bug_tracker_uri: https://github.com/modelcontextprotocol/ruby-sdk/issues