ruby-mcp-client 1.1.0 → 2.1.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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +216 -10
  3. data/lib/mcp_client/auth/oauth_provider.rb +325 -27
  4. data/lib/mcp_client/auth.rb +38 -11
  5. data/lib/mcp_client/client.rb +523 -150
  6. data/lib/mcp_client/elicitation_validator.rb +99 -13
  7. data/lib/mcp_client/errors.rb +43 -1
  8. data/lib/mcp_client/http_transport_base.rb +254 -41
  9. data/lib/mcp_client/json_rpc_common.rb +196 -14
  10. data/lib/mcp_client/oauth_client.rb +8 -3
  11. data/lib/mcp_client/prompt.rb +17 -2
  12. data/lib/mcp_client/resource.rb +13 -2
  13. data/lib/mcp_client/resource_content.rb +8 -3
  14. data/lib/mcp_client/resource_link.rb +14 -3
  15. data/lib/mcp_client/resource_template.rb +13 -2
  16. data/lib/mcp_client/root.rb +61 -7
  17. data/lib/mcp_client/schema_validator.rb +329 -0
  18. data/lib/mcp_client/server_base.rb +66 -0
  19. data/lib/mcp_client/server_factory.rb +4 -1
  20. data/lib/mcp_client/server_http/json_rpc_transport.rb +3 -2
  21. data/lib/mcp_client/server_http.rb +18 -12
  22. data/lib/mcp_client/server_sse/json_rpc_transport.rb +97 -14
  23. data/lib/mcp_client/server_sse/origin_policy.rb +57 -0
  24. data/lib/mcp_client/server_sse/reconnect_monitor.rb +17 -4
  25. data/lib/mcp_client/server_sse/sse_parser.rb +78 -10
  26. data/lib/mcp_client/server_sse.rb +132 -35
  27. data/lib/mcp_client/server_stdio/json_rpc_transport.rb +31 -8
  28. data/lib/mcp_client/server_stdio.rb +98 -20
  29. data/lib/mcp_client/server_streamable_http/json_rpc_transport.rb +222 -26
  30. data/lib/mcp_client/server_streamable_http.rb +472 -108
  31. data/lib/mcp_client/tool.rb +16 -3
  32. data/lib/mcp_client/version.rb +6 -1
  33. data/lib/mcp_client.rb +9 -1
  34. metadata +5 -6
@@ -20,7 +20,12 @@ module MCPClient
20
20
  # @!attribute [r] task_support
21
21
  # @return [String, nil] tool-level task negotiation (MCP 2025-11-25):
22
22
  # 'forbidden' (default), 'optional', or 'required'; nil when not advertised
23
- attr_reader :name, :title, :description, :schema, :output_schema, :annotations, :server, :task_support
23
+ # @!attribute [r] icons
24
+ # @return [Array<Hash>, nil] optional icons for display in user interfaces (MCP 2025-11-25, SEP-973)
25
+ # @!attribute [r] meta
26
+ # @return [Hash, nil] optional `_meta` metadata attached to the tool (MCP 2025-11-25)
27
+ attr_reader :name, :title, :description, :schema, :output_schema, :annotations, :server, :task_support,
28
+ :icons, :meta
24
29
 
25
30
  # Initialize a new Tool
26
31
  # @param name [String] the name of the tool
@@ -31,8 +36,10 @@ module MCPClient
31
36
  # @param annotations [Hash, nil] optional annotations describing tool behavior
32
37
  # @param server [MCPClient::ServerBase, nil] the server this tool belongs to
33
38
  # @param task_support [String, nil] execution.taskSupport value (MCP 2025-11-25)
39
+ # @param icons [Array<Hash>, nil] optional icons for display in user interfaces (MCP 2025-11-25)
40
+ # @param meta [Hash, nil] optional `_meta` metadata attached to the tool (MCP 2025-11-25)
34
41
  def initialize(name:, description:, schema:, title: nil, output_schema: nil, annotations: nil, server: nil,
35
- task_support: nil)
42
+ task_support: nil, icons: nil, meta: nil)
36
43
  @name = name
37
44
  @title = title
38
45
  @description = description
@@ -41,6 +48,8 @@ module MCPClient
41
48
  @annotations = annotations
42
49
  @server = server
43
50
  @task_support = task_support
51
+ @icons = icons
52
+ @meta = meta
44
53
  end
45
54
 
46
55
  # Create a Tool instance from JSON data
@@ -56,6 +65,8 @@ module MCPClient
56
65
  title = data['title'] || data[:title]
57
66
  execution = data['execution'] || data[:execution]
58
67
  task_support = execution && (execution['taskSupport'] || execution[:taskSupport])
68
+ icons = data['icons'] || data[:icons]
69
+ meta = data['_meta'] || data[:_meta]
59
70
  new(
60
71
  name: data['name'] || data[:name],
61
72
  description: data['description'] || data[:description],
@@ -64,7 +75,9 @@ module MCPClient
64
75
  output_schema: output_schema,
65
76
  annotations: annotations,
66
77
  server: server,
67
- task_support: task_support
78
+ task_support: task_support,
79
+ icons: icons,
80
+ meta: meta
68
81
  )
69
82
  end
70
83
 
@@ -2,8 +2,13 @@
2
2
 
3
3
  module MCPClient
4
4
  # Current version of the MCP client gem
5
- VERSION = '1.1.0'
5
+ VERSION = '2.1.0'
6
6
 
7
7
  # MCP protocol version (date-based) - unified across all transports
8
8
  PROTOCOL_VERSION = '2025-11-25'
9
+
10
+ # Protocol revisions this client can speak, newest first. Used during
11
+ # version negotiation: if the server answers initialize with a version
12
+ # outside this set, the client must disconnect (MCP lifecycle).
13
+ SUPPORTED_PROTOCOL_VERSIONS = %w[2025-11-25 2025-06-18 2025-03-26 2024-11-05].freeze
9
14
  end
data/lib/mcp_client.rb CHANGED
@@ -11,6 +11,7 @@ require_relative 'mcp_client/audio_content'
11
11
  require_relative 'mcp_client/resource_link'
12
12
  require_relative 'mcp_client/root'
13
13
  require_relative 'mcp_client/elicitation_validator'
14
+ require_relative 'mcp_client/schema_validator'
14
15
  require_relative 'mcp_client/task'
15
16
  require_relative 'mcp_client/server_base'
16
17
  require_relative 'mcp_client/server_stdio'
@@ -452,11 +453,17 @@ module MCPClient
452
453
  # @param retry_backoff [Integer] Backoff delay in seconds (default: 1)
453
454
  # @param name [String, nil] Optional name for this server
454
455
  # @param logger [Logger, nil] Optional logger for server operations
456
+ # @param max_decompressed_body_bytes [Integer] ceiling on how far a gzip-encoded
457
+ # response may expand before it is rejected, guarding against a small highly
458
+ # compressed body exhausting memory (default: 64 MiB)
455
459
  # @yieldparam faraday [Faraday::Connection] the configured connection instance for additional customization
456
460
  # (e.g., SSL settings, custom middleware). The block is called after default configuration is applied.
457
461
  # @return [Hash] server configuration
458
462
  def self.streamable_http_config(base_url:, endpoint: '/rpc', headers: {}, read_timeout: 30, retries: 3,
459
- retry_backoff: 1, name: nil, logger: nil, &faraday_config)
463
+ retry_backoff: 1, name: nil, logger: nil,
464
+ max_decompressed_body_bytes:
465
+ MCPClient::ServerStreamableHTTP::JsonRpcTransport::MAX_DECOMPRESSED_BODY_BYTES,
466
+ &faraday_config)
460
467
  {
461
468
  type: 'streamable_http',
462
469
  base_url: base_url,
@@ -467,6 +474,7 @@ module MCPClient
467
474
  retry_backoff: retry_backoff,
468
475
  name: name,
469
476
  logger: logger,
477
+ max_decompressed_body_bytes: max_decompressed_body_bytes,
470
478
  faraday_config: faraday_config
471
479
  }
472
480
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mcp-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Kurcab
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-07-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base64
@@ -150,12 +149,14 @@ files:
150
149
  - lib/mcp_client/resource_link.rb
151
150
  - lib/mcp_client/resource_template.rb
152
151
  - lib/mcp_client/root.rb
152
+ - lib/mcp_client/schema_validator.rb
153
153
  - lib/mcp_client/server_base.rb
154
154
  - lib/mcp_client/server_factory.rb
155
155
  - lib/mcp_client/server_http.rb
156
156
  - lib/mcp_client/server_http/json_rpc_transport.rb
157
157
  - lib/mcp_client/server_sse.rb
158
158
  - lib/mcp_client/server_sse/json_rpc_transport.rb
159
+ - lib/mcp_client/server_sse/origin_policy.rb
159
160
  - lib/mcp_client/server_sse/reconnect_monitor.rb
160
161
  - lib/mcp_client/server_sse/sse_parser.rb
161
162
  - lib/mcp_client/server_stdio.rb
@@ -170,7 +171,6 @@ licenses:
170
171
  - MIT
171
172
  metadata:
172
173
  rubygems_mfa_required: 'true'
173
- post_install_message:
174
174
  rdoc_options: []
175
175
  require_paths:
176
176
  - lib
@@ -185,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
- rubygems_version: 3.5.16
189
- signing_key:
188
+ rubygems_version: 4.0.17
190
189
  specification_version: 4
191
190
  summary: A Ruby client for the Model Context Protocol (MCP)
192
191
  test_files: []