ruby-mcp-client 2.1.0 → 3.0.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.
- checksums.yaml +4 -4
- data/OAUTH.md +555 -0
- data/README.md +825 -48
- data/lib/mcp_client/audio_content.rb +1 -1
- data/lib/mcp_client/auth/browser_oauth.rb +131 -21
- data/lib/mcp_client/auth/oauth_provider/challenge_handling.rb +532 -0
- data/lib/mcp_client/auth/oauth_provider/client_authentication.rb +121 -0
- data/lib/mcp_client/auth/oauth_provider/pending_requests.rb +51 -0
- data/lib/mcp_client/auth/oauth_provider/registration_store.rb +486 -0
- data/lib/mcp_client/auth/oauth_provider/response_validation.rb +441 -0
- data/lib/mcp_client/auth/oauth_provider/scope_selection.rb +134 -0
- data/lib/mcp_client/auth/oauth_provider/token_store.rb +419 -0
- data/lib/mcp_client/auth/oauth_provider.rb +1354 -386
- data/lib/mcp_client/auth/peer_text.rb +174 -0
- data/lib/mcp_client/auth.rb +298 -32
- data/lib/mcp_client/cached_result.rb +145 -0
- data/lib/mcp_client/called_tool_definition.rb +138 -0
- data/lib/mcp_client/client/cache_slices.rb +195 -0
- data/lib/mcp_client/client/list_aggregation.rb +243 -0
- data/lib/mcp_client/client/notification_routing.rb +155 -0
- data/lib/mcp_client/client/sampling_validation.rb +200 -0
- data/lib/mcp_client/client/task_api.rb +531 -0
- data/lib/mcp_client/client/task_lifetimes.rb +269 -0
- data/lib/mcp_client/client/task_registry.rb +254 -0
- data/lib/mcp_client/client/task_shape.rb +102 -0
- data/lib/mcp_client/client/task_support.rb +1166 -0
- data/lib/mcp_client/client/task_updates.rb +457 -0
- data/lib/mcp_client/client/task_wait_boundaries.rb +198 -0
- data/lib/mcp_client/client/task_workers.rb +63 -0
- data/lib/mcp_client/client.rb +796 -518
- data/lib/mcp_client/deep_copy.rb +49 -0
- data/lib/mcp_client/deprecation_notices.rb +94 -0
- data/lib/mcp_client/deprecations.rb +419 -0
- data/lib/mcp_client/errors.rb +474 -7
- data/lib/mcp_client/header_params.rb +320 -0
- data/lib/mcp_client/http_transport_base/bounded_inflate.rb +41 -0
- data/lib/mcp_client/http_transport_base/cache_support.rb +694 -0
- data/lib/mcp_client/http_transport_base/era_detection.rb +134 -0
- data/lib/mcp_client/http_transport_base/listen_stream.rb +763 -0
- data/lib/mcp_client/http_transport_base/param_headers.rb +35 -0
- data/lib/mcp_client/http_transport_base/request_recovery.rb +156 -0
- data/lib/mcp_client/http_transport_base/session_recovery.rb +113 -0
- data/lib/mcp_client/http_transport_base/sse_event_scanner.rb +145 -0
- data/lib/mcp_client/http_transport_base/stream_capture.rb +160 -0
- data/lib/mcp_client/http_transport_base/stream_recovery.rb +318 -0
- data/lib/mcp_client/http_transport_base/tool_listing.rb +277 -0
- data/lib/mcp_client/http_transport_base.rb +666 -120
- data/lib/mcp_client/input_round_trips.rb +128 -0
- data/lib/mcp_client/json_rpc_common/envelopes.rb +32 -0
- data/lib/mcp_client/json_rpc_common/error_bodies.rb +105 -0
- data/lib/mcp_client/json_rpc_common/input_waits.rb +167 -0
- data/lib/mcp_client/json_rpc_common.rb +900 -13
- data/lib/mcp_client/oauth_client.rb +14 -5
- data/lib/mcp_client/prompt.rb +4 -0
- data/lib/mcp_client/request_authorization.rb +128 -0
- data/lib/mcp_client/request_meta_scope.rb +77 -0
- data/lib/mcp_client/request_metadata.rb +287 -0
- data/lib/mcp_client/resource.rb +4 -0
- data/lib/mcp_client/resource_content.rb +20 -0
- data/lib/mcp_client/resource_template.rb +4 -0
- data/lib/mcp_client/result_caching.rb +999 -0
- data/lib/mcp_client/result_completeness.rb +34 -0
- data/lib/mcp_client/root.rb +6 -0
- data/lib/mcp_client/round_trip_marker.rb +28 -0
- data/lib/mcp_client/schema_validator/annotations.rb +82 -0
- data/lib/mcp_client/schema_validator/composition.rb +86 -0
- data/lib/mcp_client/schema_validator/dialects.rb +66 -0
- data/lib/mcp_client/schema_validator/ecma_patterns.rb +567 -0
- data/lib/mcp_client/schema_validator/evaluation.rb +517 -0
- data/lib/mcp_client/schema_validator/input_requirements.rb +84 -0
- data/lib/mcp_client/schema_validator/instances.rb +449 -0
- data/lib/mcp_client/schema_validator/keyword_scan.rb +121 -0
- data/lib/mcp_client/schema_validator/normalization.rb +104 -0
- data/lib/mcp_client/schema_validator/references.rb +610 -0
- data/lib/mcp_client/schema_validator/scalars.rb +126 -0
- data/lib/mcp_client/schema_validator/shapes.rb +319 -0
- data/lib/mcp_client/schema_validator/uri_references.rb +153 -0
- data/lib/mcp_client/schema_validator.rb +882 -208
- data/lib/mcp_client/server_base.rb +233 -5
- data/lib/mcp_client/server_factory.rb +9 -3
- data/lib/mcp_client/server_http/json_rpc_transport.rb +219 -4
- data/lib/mcp_client/server_http.rb +307 -90
- data/lib/mcp_client/server_sse/json_rpc_transport.rb +113 -25
- data/lib/mcp_client/server_sse/sse_parser.rb +39 -6
- data/lib/mcp_client/server_sse.rb +227 -62
- data/lib/mcp_client/server_stdio/child_session.rb +98 -0
- data/lib/mcp_client/server_stdio/json_rpc_transport.rb +1003 -28
- data/lib/mcp_client/server_stdio.rb +772 -183
- data/lib/mcp_client/server_streamable_http/json_rpc_transport.rb +189 -25
- data/lib/mcp_client/server_streamable_http.rb +302 -115
- data/lib/mcp_client/session_pin.rb +119 -0
- data/lib/mcp_client/subscription/notification_dispatcher.rb +354 -0
- data/lib/mcp_client/subscription.rb +852 -0
- data/lib/mcp_client/subscription_support.rb +715 -0
- data/lib/mcp_client/task.rb +286 -14
- data/lib/mcp_client/tool.rb +31 -3
- data/lib/mcp_client/version.rb +21 -6
- data/lib/mcp_client.rb +108 -19
- metadata +68 -2
data/lib/mcp_client.rb
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Load all MCPClient components
|
|
4
4
|
require_relative 'mcp_client/errors'
|
|
5
|
+
require_relative 'mcp_client/deep_copy'
|
|
6
|
+
require_relative 'mcp_client/deprecations'
|
|
5
7
|
require_relative 'mcp_client/tool'
|
|
6
8
|
require_relative 'mcp_client/prompt'
|
|
7
9
|
require_relative 'mcp_client/resource'
|
|
@@ -12,14 +14,26 @@ require_relative 'mcp_client/resource_link'
|
|
|
12
14
|
require_relative 'mcp_client/root'
|
|
13
15
|
require_relative 'mcp_client/elicitation_validator'
|
|
14
16
|
require_relative 'mcp_client/schema_validator'
|
|
17
|
+
require_relative 'mcp_client/header_params'
|
|
18
|
+
require_relative 'mcp_client/called_tool_definition'
|
|
15
19
|
require_relative 'mcp_client/task'
|
|
20
|
+
require_relative 'mcp_client/subscription'
|
|
16
21
|
require_relative 'mcp_client/server_base'
|
|
17
22
|
require_relative 'mcp_client/server_stdio'
|
|
18
23
|
require_relative 'mcp_client/server_sse'
|
|
19
24
|
require_relative 'mcp_client/server_http'
|
|
20
25
|
require_relative 'mcp_client/server_streamable_http'
|
|
21
26
|
require_relative 'mcp_client/server_factory'
|
|
27
|
+
require_relative 'mcp_client/client/task_support'
|
|
28
|
+
require_relative 'mcp_client/client/task_api'
|
|
22
29
|
require_relative 'mcp_client/client'
|
|
30
|
+
|
|
31
|
+
# The tasks extension's SubscriptionFilter field (extensions/tasks
|
|
32
|
+
# "Subscriptions"): `taskIds`, beyond the four published core fields. Known
|
|
33
|
+
# to the filter from the start so a host can spell it before declaring the
|
|
34
|
+
# extension; MCPClient::Client#listen still refuses it on a client that has
|
|
35
|
+
# not declared the extension.
|
|
36
|
+
MCPClient::Subscription.register_filter_field('taskIds', :string_array, alias_name: 'task_ids')
|
|
23
37
|
require_relative 'mcp_client/version'
|
|
24
38
|
require_relative 'mcp_client/config_parser'
|
|
25
39
|
require_relative 'mcp_client/auth'
|
|
@@ -32,11 +46,17 @@ module MCPClient
|
|
|
32
46
|
# Simplified connection API - auto-detects transport and returns connected client
|
|
33
47
|
#
|
|
34
48
|
# @param target [String, Array<String>] URL(s) or command for connection
|
|
35
|
-
# - URLs ending in /sse -> SSE transport
|
|
49
|
+
# - URLs ending in /sse -> SSE transport. The HTTP+SSE transport has been
|
|
50
|
+
# deprecated since MCP 2025-03-26 and is listed in the 2026-07-28
|
|
51
|
+
# deprecated features registry (SEP-2596); earliest removal is three
|
|
52
|
+
# months after SEP-2596 reaches Final. New integrations should use
|
|
53
|
+
# Streamable HTTP.
|
|
36
54
|
# - URLs ending in /mcp -> Streamable HTTP transport
|
|
37
55
|
# - stdio://command or Array commands -> stdio transport
|
|
38
56
|
# - Commands starting with npx, node, python, ruby, etc. -> stdio transport
|
|
39
|
-
# - Other HTTP URLs -> Try Streamable HTTP,
|
|
57
|
+
# - Other HTTP URLs -> Try Streamable HTTP, then the deprecated HTTP+SSE
|
|
58
|
+
# transport (SEP-2596), then HTTP. The SSE step is a fallback for an
|
|
59
|
+
# existing server, not a choice a new integration should rely on.
|
|
40
60
|
# Accepts keyword arguments for connection options:
|
|
41
61
|
# - headers [Hash] HTTP headers for remote transports
|
|
42
62
|
# - read_timeout [Integer] Request timeout in seconds (default: 30)
|
|
@@ -47,19 +67,30 @@ module MCPClient
|
|
|
47
67
|
# - env [Hash] Environment variables for stdio
|
|
48
68
|
# - ping [Integer] Ping interval for SSE (default: 10)
|
|
49
69
|
# - endpoint [String] JSON-RPC endpoint path (default: '/rpc')
|
|
50
|
-
# - transport [Symbol] Force transport type (:stdio, :sse, :http, :streamable_http)
|
|
51
|
-
#
|
|
70
|
+
# - transport [Symbol] Force transport type (:stdio, :sse, :http, :streamable_http).
|
|
71
|
+
# :sse forces the deprecated HTTP+SSE transport (SEP-2596); earliest
|
|
72
|
+
# removal is three months after SEP-2596 reaches Final. Prefer
|
|
73
|
+
# :streamable_http.
|
|
74
|
+
# - sampling_handler [Proc] Handler for sampling requests. Deprecated since MCP
|
|
75
|
+
# 2026-07-28 (SEP-2577); earliest removal is the first revision released on or
|
|
76
|
+
# after 2027-07-28. Integrate directly with the LLM provider API instead.
|
|
77
|
+
# - protocol [Symbol] :auto (default), :modern or :legacy — which protocol era
|
|
78
|
+
# to speak (stdio, HTTP and Streamable HTTP; :modern with transport: :sse
|
|
79
|
+
# raises ArgumentError, the HTTP+SSE transport being legacy-only)
|
|
80
|
+
# - discover_timeout [Numeric] bound on the server/discover probe in seconds
|
|
81
|
+
# - extensions [Array<String>] MCP extensions the client declares, e.g.
|
|
82
|
+
# 'io.modelcontextprotocol/tasks'
|
|
52
83
|
# @yield [Faraday::Connection] Optional block for Faraday customization
|
|
53
84
|
# @return [MCPClient::Client] Connected client ready to use
|
|
54
85
|
# @raise [MCPClient::Errors::ConnectionError] if connection fails
|
|
55
86
|
# @raise [MCPClient::Errors::TransportDetectionError] if transport cannot be determined
|
|
56
87
|
#
|
|
57
|
-
# @example Connect to SSE server
|
|
58
|
-
# client = MCPClient.connect('http://localhost:8000/sse')
|
|
59
|
-
#
|
|
60
88
|
# @example Connect to Streamable HTTP server
|
|
61
89
|
# client = MCPClient.connect('http://localhost:8000/mcp')
|
|
62
90
|
#
|
|
91
|
+
# @example Connect to SSE server (deprecated transport; prefer Streamable HTTP)
|
|
92
|
+
# client = MCPClient.connect('http://localhost:8000/sse')
|
|
93
|
+
#
|
|
63
94
|
# @example Connect with options
|
|
64
95
|
# client = MCPClient.connect('http://api.example.com/mcp',
|
|
65
96
|
# headers: { 'Authorization' => 'Bearer token' },
|
|
@@ -72,7 +103,7 @@ module MCPClient
|
|
|
72
103
|
# client = MCPClient.connect(['npx', '-y', '@modelcontextprotocol/server-filesystem', '/home'])
|
|
73
104
|
#
|
|
74
105
|
# @example Connect to multiple servers
|
|
75
|
-
# client = MCPClient.connect(['http://server1/mcp', 'http://server2/
|
|
106
|
+
# client = MCPClient.connect(['http://server1/mcp', 'http://server2/mcp'])
|
|
76
107
|
#
|
|
77
108
|
# @example Force transport type
|
|
78
109
|
# client = MCPClient.connect('http://custom-server.com', transport: :streamable_http)
|
|
@@ -101,7 +132,7 @@ module MCPClient
|
|
|
101
132
|
|
|
102
133
|
# Connect to a single server
|
|
103
134
|
def connect_single(target, **options, &)
|
|
104
|
-
transport = options[:transport]&.to_sym || detect_transport(target)
|
|
135
|
+
transport = options[:transport]&.to_sym || detect_transport(target, options)
|
|
105
136
|
|
|
106
137
|
case transport
|
|
107
138
|
when :stdio
|
|
@@ -129,7 +160,8 @@ module MCPClient
|
|
|
129
160
|
client = Client.new(
|
|
130
161
|
mcp_server_configs: configs,
|
|
131
162
|
logger: options[:logger],
|
|
132
|
-
sampling_handler: options[:sampling_handler]
|
|
163
|
+
sampling_handler: options[:sampling_handler],
|
|
164
|
+
extensions: options[:extensions]
|
|
133
165
|
)
|
|
134
166
|
|
|
135
167
|
# Connect all servers
|
|
@@ -167,7 +199,8 @@ module MCPClient
|
|
|
167
199
|
client = Client.new(
|
|
168
200
|
mcp_server_configs: [config],
|
|
169
201
|
logger: options[:logger],
|
|
170
|
-
sampling_handler: options[:sampling_handler]
|
|
202
|
+
sampling_handler: options[:sampling_handler],
|
|
203
|
+
extensions: options[:extensions]
|
|
171
204
|
)
|
|
172
205
|
client.servers.first.connect
|
|
173
206
|
client
|
|
@@ -183,7 +216,17 @@ module MCPClient
|
|
|
183
216
|
begin
|
|
184
217
|
logger.debug("MCPClient.connect: Attempting Streamable HTTP connection to #{url}")
|
|
185
218
|
return connect_streamable_http(url, **options, &)
|
|
219
|
+
rescue Errors::ModernServerError
|
|
220
|
+
# The probe identified a modern (2026-07-28+) MCP server. The era is
|
|
221
|
+
# settled, so the legacy SSE and HTTP+POST fallbacks cannot do better
|
|
222
|
+
# — and trying them would hide the real, actionable failure.
|
|
223
|
+
raise
|
|
186
224
|
rescue Errors::ConnectionError, Errors::TransportError => e
|
|
225
|
+
# protocol: :modern rules out the initialize handshake, and both
|
|
226
|
+
# remaining fallbacks are legacy-only transports that silently ignore
|
|
227
|
+
# the option.
|
|
228
|
+
raise if modern_only?(options)
|
|
229
|
+
|
|
187
230
|
errors << "Streamable HTTP: #{e.message}"
|
|
188
231
|
logger.debug("MCPClient.connect: Streamable HTTP failed: #{e.message}")
|
|
189
232
|
end
|
|
@@ -210,8 +253,18 @@ module MCPClient
|
|
|
210
253
|
"Failed to connect to #{url}. Tried all transports:\n #{errors.join("\n ")}"
|
|
211
254
|
end
|
|
212
255
|
|
|
256
|
+
# Whether the caller demanded a modern (2026-07-28+) server, which rules
|
|
257
|
+
# out falling back to the legacy-only transports.
|
|
258
|
+
# @param options [Hash] the connect options
|
|
259
|
+
# @return [Boolean]
|
|
260
|
+
def modern_only?(options)
|
|
261
|
+
options[:protocol].respond_to?(:to_sym) && options[:protocol].to_sym == :modern
|
|
262
|
+
end
|
|
263
|
+
|
|
213
264
|
# Detect transport type from target
|
|
214
|
-
|
|
265
|
+
# @param target [String, Array] the connection target
|
|
266
|
+
# @param options [Hash] the connect options, consulted for protocol:
|
|
267
|
+
def detect_transport(target, options = {})
|
|
215
268
|
return :stdio if target.is_a?(Array) && stdio_command_array?(target)
|
|
216
269
|
return :stdio if stdio_target?(target)
|
|
217
270
|
|
|
@@ -228,6 +281,11 @@ module MCPClient
|
|
|
228
281
|
end
|
|
229
282
|
|
|
230
283
|
path = uri.path.to_s.downcase
|
|
284
|
+
# A URL path is not a protocol declaration: protocol: :modern asks for a
|
|
285
|
+
# 2026-07-28 server, which only Streamable HTTP can speak. Honouring the
|
|
286
|
+
# /sse suffix there would select the legacy-only SSE transport, which
|
|
287
|
+
# drops the option and opens a GET stream instead of probing.
|
|
288
|
+
return :streamable_http if modern_only?(options)
|
|
231
289
|
return :sse if path.end_with?('/sse')
|
|
232
290
|
return :streamable_http if path.end_with?('/mcp')
|
|
233
291
|
|
|
@@ -295,12 +353,21 @@ module MCPClient
|
|
|
295
353
|
def extract_http_options(options)
|
|
296
354
|
extract_common_options(options).merge({
|
|
297
355
|
headers: options[:headers] || {},
|
|
298
|
-
endpoint: options[:endpoint]
|
|
356
|
+
endpoint: options[:endpoint],
|
|
357
|
+
protocol: options[:protocol],
|
|
358
|
+
discover_timeout: options[:discover_timeout]
|
|
299
359
|
}.compact)
|
|
300
360
|
end
|
|
301
361
|
|
|
302
362
|
# Extract SSE transport specific options
|
|
363
|
+
# @raise [ArgumentError] when protocol: :modern is combined with the SSE
|
|
364
|
+
# transport, which cannot speak a 2026-07-28 server
|
|
303
365
|
def extract_sse_options(options)
|
|
366
|
+
if modern_only?(options)
|
|
367
|
+
raise ArgumentError, 'transport: :sse cannot honour protocol: :modern: the HTTP+SSE transport is ' \
|
|
368
|
+
'legacy-only (SEP-2596). Use transport: :streamable_http for a 2026-07-28 server.'
|
|
369
|
+
end
|
|
370
|
+
|
|
304
371
|
extract_common_options(options).merge({
|
|
305
372
|
headers: options[:headers] || {},
|
|
306
373
|
ping: options[:ping]
|
|
@@ -310,13 +377,15 @@ module MCPClient
|
|
|
310
377
|
# Extract stdio transport specific options
|
|
311
378
|
def extract_stdio_options(options)
|
|
312
379
|
extract_common_options(options).merge({
|
|
313
|
-
env: options[:env] || {}
|
|
380
|
+
env: options[:env] || {},
|
|
381
|
+
protocol: options[:protocol],
|
|
382
|
+
discover_timeout: options[:discover_timeout]
|
|
314
383
|
}.compact)
|
|
315
384
|
end
|
|
316
385
|
|
|
317
386
|
# Build config hash for a target
|
|
318
387
|
def build_config_for_target(target, **options, &)
|
|
319
|
-
transport = options[:transport]&.to_sym || detect_transport(target)
|
|
388
|
+
transport = options[:transport]&.to_sym || detect_transport(target, options)
|
|
320
389
|
|
|
321
390
|
case transport
|
|
322
391
|
when :stdio
|
|
@@ -379,18 +448,30 @@ module MCPClient
|
|
|
379
448
|
# @param command [String, Array<String>] command to execute
|
|
380
449
|
# @param name [String, nil] optional name for this server
|
|
381
450
|
# @param logger [Logger, nil] optional logger for server operations
|
|
451
|
+
# @param env [Hash] environment variables for the subprocess
|
|
452
|
+
# @param protocol [Symbol] how to establish the server's MCP era: :auto (probe
|
|
453
|
+
# with server/discover, fall back to the initialize handshake), :modern
|
|
454
|
+
# (2026-07-28+ only) or :legacy (initialize handshake only)
|
|
455
|
+
# @param discover_timeout [Numeric, nil] seconds to wait for the server/discover probe
|
|
382
456
|
# @return [Hash] server configuration
|
|
383
|
-
def self.stdio_config(command:, name: nil, logger: nil, env: {})
|
|
457
|
+
def self.stdio_config(command:, name: nil, logger: nil, env: {}, protocol: :auto, discover_timeout: nil)
|
|
384
458
|
{
|
|
385
459
|
type: 'stdio',
|
|
386
460
|
command: command,
|
|
387
461
|
name: name,
|
|
388
462
|
logger: logger,
|
|
389
|
-
env: env || {}
|
|
463
|
+
env: env || {},
|
|
464
|
+
protocol: protocol,
|
|
465
|
+
discover_timeout: discover_timeout
|
|
390
466
|
}
|
|
391
467
|
end
|
|
392
468
|
|
|
393
469
|
# Create a standard server configuration for SSE
|
|
470
|
+
#
|
|
471
|
+
# @deprecated The HTTP+SSE transport has been deprecated since MCP 2025-03-26
|
|
472
|
+
# and is listed in the 2026-07-28 deprecated features registry (SEP-2596);
|
|
473
|
+
# earliest removal is three months after SEP-2596 reaches Final. Use
|
|
474
|
+
# {MCPClient.streamable_http_config} and {MCPClient::ServerStreamableHTTP}.
|
|
394
475
|
# @param base_url [String] base URL for the server
|
|
395
476
|
# @param headers [Hash] HTTP headers to include in requests
|
|
396
477
|
# @param read_timeout [Integer] read timeout in seconds (default: 30)
|
|
@@ -424,11 +505,13 @@ module MCPClient
|
|
|
424
505
|
# @param retry_backoff [Integer] backoff delay in seconds (default: 1)
|
|
425
506
|
# @param name [String, nil] optional name for this server
|
|
426
507
|
# @param logger [Logger, nil] optional logger for server operations
|
|
508
|
+
# @param protocol [Symbol] :auto (default), :modern or :legacy — which protocol era to speak
|
|
509
|
+
# @param discover_timeout [Numeric, nil] bound on the server/discover probe in seconds
|
|
427
510
|
# @yieldparam faraday [Faraday::Connection] the configured connection instance for additional customization
|
|
428
511
|
# (e.g., SSL settings, custom middleware). The block is called after default configuration is applied.
|
|
429
512
|
# @return [Hash] server configuration
|
|
430
513
|
def self.http_config(base_url:, endpoint: '/rpc', headers: {}, read_timeout: 30, retries: 3, retry_backoff: 1,
|
|
431
|
-
name: nil, logger: nil, &faraday_config)
|
|
514
|
+
name: nil, logger: nil, protocol: :auto, discover_timeout: nil, &faraday_config)
|
|
432
515
|
{
|
|
433
516
|
type: 'http',
|
|
434
517
|
base_url: base_url,
|
|
@@ -439,6 +522,8 @@ module MCPClient
|
|
|
439
522
|
retry_backoff: retry_backoff,
|
|
440
523
|
name: name,
|
|
441
524
|
logger: logger,
|
|
525
|
+
protocol: protocol,
|
|
526
|
+
discover_timeout: discover_timeout,
|
|
442
527
|
faraday_config: faraday_config
|
|
443
528
|
}
|
|
444
529
|
end
|
|
@@ -456,6 +541,8 @@ module MCPClient
|
|
|
456
541
|
# @param max_decompressed_body_bytes [Integer] ceiling on how far a gzip-encoded
|
|
457
542
|
# response may expand before it is rejected, guarding against a small highly
|
|
458
543
|
# compressed body exhausting memory (default: 64 MiB)
|
|
544
|
+
# @param protocol [Symbol] :auto (default), :modern or :legacy — which protocol era to speak
|
|
545
|
+
# @param discover_timeout [Numeric, nil] bound on the server/discover probe in seconds
|
|
459
546
|
# @yieldparam faraday [Faraday::Connection] the configured connection instance for additional customization
|
|
460
547
|
# (e.g., SSL settings, custom middleware). The block is called after default configuration is applied.
|
|
461
548
|
# @return [Hash] server configuration
|
|
@@ -463,7 +550,7 @@ module MCPClient
|
|
|
463
550
|
retry_backoff: 1, name: nil, logger: nil,
|
|
464
551
|
max_decompressed_body_bytes:
|
|
465
552
|
MCPClient::ServerStreamableHTTP::JsonRpcTransport::MAX_DECOMPRESSED_BODY_BYTES,
|
|
466
|
-
&faraday_config)
|
|
553
|
+
protocol: :auto, discover_timeout: nil, &faraday_config)
|
|
467
554
|
{
|
|
468
555
|
type: 'streamable_http',
|
|
469
556
|
base_url: base_url,
|
|
@@ -475,6 +562,8 @@ module MCPClient
|
|
|
475
562
|
name: name,
|
|
476
563
|
logger: logger,
|
|
477
564
|
max_decompressed_body_bytes: max_decompressed_body_bytes,
|
|
565
|
+
protocol: protocol,
|
|
566
|
+
discover_timeout: discover_timeout,
|
|
478
567
|
faraday_config: faraday_config
|
|
479
568
|
}
|
|
480
569
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-mcp-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Szymon Kurcab
|
|
@@ -130,26 +130,87 @@ extensions: []
|
|
|
130
130
|
extra_rdoc_files: []
|
|
131
131
|
files:
|
|
132
132
|
- LICENSE
|
|
133
|
+
- OAUTH.md
|
|
133
134
|
- README.md
|
|
134
135
|
- lib/mcp_client.rb
|
|
135
136
|
- lib/mcp_client/audio_content.rb
|
|
136
137
|
- lib/mcp_client/auth.rb
|
|
137
138
|
- lib/mcp_client/auth/browser_oauth.rb
|
|
138
139
|
- lib/mcp_client/auth/oauth_provider.rb
|
|
140
|
+
- lib/mcp_client/auth/oauth_provider/challenge_handling.rb
|
|
141
|
+
- lib/mcp_client/auth/oauth_provider/client_authentication.rb
|
|
142
|
+
- lib/mcp_client/auth/oauth_provider/pending_requests.rb
|
|
143
|
+
- lib/mcp_client/auth/oauth_provider/registration_store.rb
|
|
144
|
+
- lib/mcp_client/auth/oauth_provider/response_validation.rb
|
|
145
|
+
- lib/mcp_client/auth/oauth_provider/scope_selection.rb
|
|
146
|
+
- lib/mcp_client/auth/oauth_provider/token_store.rb
|
|
147
|
+
- lib/mcp_client/auth/peer_text.rb
|
|
148
|
+
- lib/mcp_client/cached_result.rb
|
|
149
|
+
- lib/mcp_client/called_tool_definition.rb
|
|
139
150
|
- lib/mcp_client/client.rb
|
|
151
|
+
- lib/mcp_client/client/cache_slices.rb
|
|
152
|
+
- lib/mcp_client/client/list_aggregation.rb
|
|
153
|
+
- lib/mcp_client/client/notification_routing.rb
|
|
154
|
+
- lib/mcp_client/client/sampling_validation.rb
|
|
155
|
+
- lib/mcp_client/client/task_api.rb
|
|
156
|
+
- lib/mcp_client/client/task_lifetimes.rb
|
|
157
|
+
- lib/mcp_client/client/task_registry.rb
|
|
158
|
+
- lib/mcp_client/client/task_shape.rb
|
|
159
|
+
- lib/mcp_client/client/task_support.rb
|
|
160
|
+
- lib/mcp_client/client/task_updates.rb
|
|
161
|
+
- lib/mcp_client/client/task_wait_boundaries.rb
|
|
162
|
+
- lib/mcp_client/client/task_workers.rb
|
|
140
163
|
- lib/mcp_client/config_parser.rb
|
|
164
|
+
- lib/mcp_client/deep_copy.rb
|
|
165
|
+
- lib/mcp_client/deprecation_notices.rb
|
|
166
|
+
- lib/mcp_client/deprecations.rb
|
|
141
167
|
- lib/mcp_client/elicitation_validator.rb
|
|
142
168
|
- lib/mcp_client/errors.rb
|
|
169
|
+
- lib/mcp_client/header_params.rb
|
|
143
170
|
- lib/mcp_client/http_transport_base.rb
|
|
171
|
+
- lib/mcp_client/http_transport_base/bounded_inflate.rb
|
|
172
|
+
- lib/mcp_client/http_transport_base/cache_support.rb
|
|
173
|
+
- lib/mcp_client/http_transport_base/era_detection.rb
|
|
174
|
+
- lib/mcp_client/http_transport_base/listen_stream.rb
|
|
175
|
+
- lib/mcp_client/http_transport_base/param_headers.rb
|
|
176
|
+
- lib/mcp_client/http_transport_base/request_recovery.rb
|
|
177
|
+
- lib/mcp_client/http_transport_base/session_recovery.rb
|
|
178
|
+
- lib/mcp_client/http_transport_base/sse_event_scanner.rb
|
|
179
|
+
- lib/mcp_client/http_transport_base/stream_capture.rb
|
|
180
|
+
- lib/mcp_client/http_transport_base/stream_recovery.rb
|
|
181
|
+
- lib/mcp_client/http_transport_base/tool_listing.rb
|
|
182
|
+
- lib/mcp_client/input_round_trips.rb
|
|
144
183
|
- lib/mcp_client/json_rpc_common.rb
|
|
184
|
+
- lib/mcp_client/json_rpc_common/envelopes.rb
|
|
185
|
+
- lib/mcp_client/json_rpc_common/error_bodies.rb
|
|
186
|
+
- lib/mcp_client/json_rpc_common/input_waits.rb
|
|
145
187
|
- lib/mcp_client/oauth_client.rb
|
|
146
188
|
- lib/mcp_client/prompt.rb
|
|
189
|
+
- lib/mcp_client/request_authorization.rb
|
|
190
|
+
- lib/mcp_client/request_meta_scope.rb
|
|
191
|
+
- lib/mcp_client/request_metadata.rb
|
|
147
192
|
- lib/mcp_client/resource.rb
|
|
148
193
|
- lib/mcp_client/resource_content.rb
|
|
149
194
|
- lib/mcp_client/resource_link.rb
|
|
150
195
|
- lib/mcp_client/resource_template.rb
|
|
196
|
+
- lib/mcp_client/result_caching.rb
|
|
197
|
+
- lib/mcp_client/result_completeness.rb
|
|
151
198
|
- lib/mcp_client/root.rb
|
|
199
|
+
- lib/mcp_client/round_trip_marker.rb
|
|
152
200
|
- lib/mcp_client/schema_validator.rb
|
|
201
|
+
- lib/mcp_client/schema_validator/annotations.rb
|
|
202
|
+
- lib/mcp_client/schema_validator/composition.rb
|
|
203
|
+
- lib/mcp_client/schema_validator/dialects.rb
|
|
204
|
+
- lib/mcp_client/schema_validator/ecma_patterns.rb
|
|
205
|
+
- lib/mcp_client/schema_validator/evaluation.rb
|
|
206
|
+
- lib/mcp_client/schema_validator/input_requirements.rb
|
|
207
|
+
- lib/mcp_client/schema_validator/instances.rb
|
|
208
|
+
- lib/mcp_client/schema_validator/keyword_scan.rb
|
|
209
|
+
- lib/mcp_client/schema_validator/normalization.rb
|
|
210
|
+
- lib/mcp_client/schema_validator/references.rb
|
|
211
|
+
- lib/mcp_client/schema_validator/scalars.rb
|
|
212
|
+
- lib/mcp_client/schema_validator/shapes.rb
|
|
213
|
+
- lib/mcp_client/schema_validator/uri_references.rb
|
|
153
214
|
- lib/mcp_client/server_base.rb
|
|
154
215
|
- lib/mcp_client/server_factory.rb
|
|
155
216
|
- lib/mcp_client/server_http.rb
|
|
@@ -160,9 +221,14 @@ files:
|
|
|
160
221
|
- lib/mcp_client/server_sse/reconnect_monitor.rb
|
|
161
222
|
- lib/mcp_client/server_sse/sse_parser.rb
|
|
162
223
|
- lib/mcp_client/server_stdio.rb
|
|
224
|
+
- lib/mcp_client/server_stdio/child_session.rb
|
|
163
225
|
- lib/mcp_client/server_stdio/json_rpc_transport.rb
|
|
164
226
|
- lib/mcp_client/server_streamable_http.rb
|
|
165
227
|
- lib/mcp_client/server_streamable_http/json_rpc_transport.rb
|
|
228
|
+
- lib/mcp_client/session_pin.rb
|
|
229
|
+
- lib/mcp_client/subscription.rb
|
|
230
|
+
- lib/mcp_client/subscription/notification_dispatcher.rb
|
|
231
|
+
- lib/mcp_client/subscription_support.rb
|
|
166
232
|
- lib/mcp_client/task.rb
|
|
167
233
|
- lib/mcp_client/tool.rb
|
|
168
234
|
- lib/mcp_client/version.rb
|
|
@@ -178,7 +244,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
178
244
|
requirements:
|
|
179
245
|
- - ">="
|
|
180
246
|
- !ruby/object:Gem::Version
|
|
181
|
-
version: 3.
|
|
247
|
+
version: 3.3.0
|
|
182
248
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
249
|
requirements:
|
|
184
250
|
- - ">="
|