mcp 0.10.0 → 0.14.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.
@@ -5,9 +5,9 @@ module MCP
5
5
  class Response
6
6
  NOT_GIVEN = Object.new.freeze
7
7
 
8
- attr_reader :content, :structured_content
8
+ attr_reader :content, :structured_content, :meta
9
9
 
10
- def initialize(content = nil, deprecated_error = NOT_GIVEN, error: false, structured_content: nil)
10
+ def initialize(content = nil, deprecated_error = NOT_GIVEN, error: false, structured_content: nil, meta: nil)
11
11
  if deprecated_error != NOT_GIVEN
12
12
  warn("Passing `error` with the 2nd argument of `Response.new` is deprecated. Use keyword argument like `Response.new(content, error: error)` instead.", uplevel: 1)
13
13
  error = deprecated_error
@@ -16,6 +16,7 @@ module MCP
16
16
  @content = content || []
17
17
  @error = error
18
18
  @structured_content = structured_content
19
+ @meta = meta
19
20
  end
20
21
 
21
22
  def error?
@@ -23,7 +24,7 @@ module MCP
23
24
  end
24
25
 
25
26
  def to_h
26
- { content: content, isError: error?, structuredContent: @structured_content }.compact
27
+ { content: content, isError: error?, structuredContent: @structured_content, _meta: meta }.compact
27
28
  end
28
29
  end
29
30
  end
@@ -8,7 +8,7 @@ module MCP
8
8
  attr_reader :schema
9
9
 
10
10
  def initialize(schema = {})
11
- @schema = deep_transform_keys(JSON.parse(JSON.dump(schema)), &:to_sym)
11
+ @schema = JSON.parse(JSON.dump(schema), symbolize_names: true)
12
12
  @schema[:type] ||= "object"
13
13
  validate_schema!
14
14
  end
@@ -27,19 +27,6 @@ module MCP
27
27
  JSON::Validator.fully_validate(to_h, data)
28
28
  end
29
29
 
30
- def deep_transform_keys(schema, &block)
31
- case schema
32
- when Hash
33
- schema.each_with_object({}) do |(key, value), result|
34
- result[yield(key)] = deep_transform_keys(value, &block)
35
- end
36
- when Array
37
- schema.map { |e| deep_transform_keys(e, &block) }
38
- else
39
- schema
40
- end
41
- end
42
-
43
30
  def validate_schema!
44
31
  schema = to_h
45
32
  gem_path = File.realpath(Gem.loaded_specs["json-schema"].full_gem_path)
data/lib/mcp/transport.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "securerandom"
4
+
3
5
  module MCP
4
6
  class Transport
5
7
  # Initialize the transport with the server instance
6
8
  def initialize(server)
7
9
  @server = server
10
+ server.transport = self
8
11
  end
9
12
 
10
13
  # Send a response to the client
@@ -41,5 +44,16 @@ module MCP
41
44
  def send_notification(method, params = nil)
42
45
  raise NotImplementedError, "Subclasses must implement send_notification"
43
46
  end
47
+
48
+ # Send a JSON-RPC request to the client and wait for a response.
49
+ def send_request(method, params = nil)
50
+ raise NotImplementedError, "Subclasses must implement send_request"
51
+ end
52
+
53
+ private
54
+
55
+ def generate_request_id
56
+ SecureRandom.uuid
57
+ end
44
58
  end
45
59
  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.10.0"
4
+ VERSION = "0.14.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: 0.10.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Model Context Protocol
@@ -28,7 +28,9 @@ email:
28
28
  - mcp-support@anthropic.com
29
29
  executables: []
30
30
  extensions: []
31
- extra_rdoc_files: []
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.md
32
34
  files:
33
35
  - LICENSE
34
36
  - README.md
@@ -37,6 +39,7 @@ files:
37
39
  - lib/mcp/annotations.rb
38
40
  - lib/mcp/client.rb
39
41
  - lib/mcp/client/http.rb
42
+ - lib/mcp/client/paginated_result.rb
40
43
  - lib/mcp/client/stdio.rb
41
44
  - lib/mcp/client/tool.rb
42
45
  - lib/mcp/configuration.rb
@@ -56,6 +59,7 @@ files:
56
59
  - lib/mcp/resource_template.rb
57
60
  - lib/mcp/server.rb
58
61
  - lib/mcp/server/capabilities.rb
62
+ - lib/mcp/server/pagination.rb
59
63
  - lib/mcp/server/transports.rb
60
64
  - lib/mcp/server/transports/stdio_transport.rb
61
65
  - lib/mcp/server/transports/streamable_http_transport.rb
@@ -71,13 +75,13 @@ files:
71
75
  - lib/mcp/transport.rb
72
76
  - lib/mcp/transports/stdio.rb
73
77
  - lib/mcp/version.rb
74
- homepage: https://github.com/modelcontextprotocol/ruby-sdk
78
+ homepage: https://ruby.sdk.modelcontextprotocol.io
75
79
  licenses:
76
80
  - Apache-2.0
77
81
  metadata:
78
82
  allowed_push_host: https://rubygems.org
79
- changelog_uri: https://github.com/modelcontextprotocol/ruby-sdk/releases/tag/v0.10.0
80
- homepage_uri: https://github.com/modelcontextprotocol/ruby-sdk
83
+ changelog_uri: https://github.com/modelcontextprotocol/ruby-sdk/releases/tag/v0.14.0
84
+ homepage_uri: https://ruby.sdk.modelcontextprotocol.io
81
85
  source_code_uri: https://github.com/modelcontextprotocol/ruby-sdk
82
86
  bug_tracker_uri: https://github.com/modelcontextprotocol/ruby-sdk/issues
83
87
  documentation_uri: https://rubydoc.info/gems/mcp