mcp 1.11.0 → 1.13.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/lib/json_rpc_handler.rb +94 -2
- data/lib/mcp/client/http.rb +46 -12
- data/lib/mcp/client/oauth/client_credentials_provider.rb +7 -0
- data/lib/mcp/client/stdio.rb +17 -2
- data/lib/mcp/client.rb +55 -11
- data/lib/mcp/client_capabilities.rb +25 -0
- data/lib/mcp/content.rb +12 -0
- data/lib/mcp/duration.rb +13 -0
- data/lib/mcp/resource_template.rb +81 -12
- data/lib/mcp/server/input_required_result.rb +4 -12
- data/lib/mcp/server/oauth/introspection_verifier.rb +6 -0
- data/lib/mcp/server/oauth/jwt_verifier.rb +6 -0
- data/lib/mcp/server/request_state_security.rb +9 -3
- data/lib/mcp/server/subscription_bus.rb +63 -0
- data/lib/mcp/server/transports/stdio_transport.rb +5 -3
- data/lib/mcp/server/transports/streamable_http_transport.rb +539 -132
- data/lib/mcp/server.rb +215 -30
- data/lib/mcp/server_context.rb +8 -7
- data/lib/mcp/server_session.rb +61 -9
- data/lib/mcp/subscriptions.rb +75 -0
- data/lib/mcp/version.rb +1 -1
- data/lib/mcp.rb +1 -0
- metadata +6 -2
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "methods"
|
|
4
|
+
|
|
5
|
+
module MCP
|
|
6
|
+
# The typed change-event vocabulary of `subscriptions/listen` (SEP-2575):
|
|
7
|
+
# `MCP::Server::SubscriptionBus` carries these events between processes. Each event maps onto exactly one
|
|
8
|
+
# change notification method; the wire shape itself never travels through these classes.
|
|
9
|
+
module Subscriptions
|
|
10
|
+
# Base for the payload-free list-changed events; equality is class identity.
|
|
11
|
+
class ListChangedEvent
|
|
12
|
+
def initialize
|
|
13
|
+
freeze
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def ==(other)
|
|
17
|
+
other.instance_of?(self.class)
|
|
18
|
+
end
|
|
19
|
+
alias_method :eql?, :==
|
|
20
|
+
|
|
21
|
+
def hash
|
|
22
|
+
self.class.hash
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Announces `notifications/tools/list_changed`.
|
|
27
|
+
class ToolsListChanged < ListChangedEvent; end
|
|
28
|
+
|
|
29
|
+
# Announces `notifications/prompts/list_changed`.
|
|
30
|
+
class PromptsListChanged < ListChangedEvent; end
|
|
31
|
+
|
|
32
|
+
# Announces `notifications/resources/list_changed`.
|
|
33
|
+
class ResourcesListChanged < ListChangedEvent; end
|
|
34
|
+
|
|
35
|
+
# Announces `notifications/resources/updated` for one resource URI.
|
|
36
|
+
class ResourceUpdated
|
|
37
|
+
attr_reader :uri
|
|
38
|
+
|
|
39
|
+
def initialize(uri:)
|
|
40
|
+
raise ArgumentError, "uri must be a String" unless uri.is_a?(String)
|
|
41
|
+
|
|
42
|
+
@uri = -uri
|
|
43
|
+
freeze
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def ==(other)
|
|
47
|
+
other.instance_of?(self.class) && other.uri == uri
|
|
48
|
+
end
|
|
49
|
+
alias_method :eql?, :==
|
|
50
|
+
|
|
51
|
+
def hash
|
|
52
|
+
[self.class, uri].hash
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
class << self
|
|
57
|
+
# Decodes a change notification into its typed event, or `nil` for any other method
|
|
58
|
+
# (progress, log, and the other request- or session-scoped notifications).
|
|
59
|
+
# Accepts symbol or string params keys, since parsed frames arrive in either form.
|
|
60
|
+
def event_from_wire(method, params)
|
|
61
|
+
case method
|
|
62
|
+
when Methods::NOTIFICATIONS_TOOLS_LIST_CHANGED
|
|
63
|
+
ToolsListChanged.new
|
|
64
|
+
when Methods::NOTIFICATIONS_PROMPTS_LIST_CHANGED
|
|
65
|
+
PromptsListChanged.new
|
|
66
|
+
when Methods::NOTIFICATIONS_RESOURCES_LIST_CHANGED
|
|
67
|
+
ResourcesListChanged.new
|
|
68
|
+
when Methods::NOTIFICATIONS_RESOURCES_UPDATED
|
|
69
|
+
uri = params.is_a?(Hash) ? params[:uri] || params["uri"] : nil
|
|
70
|
+
ResourceUpdated.new(uri: uri) if uri.is_a?(String)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
data/lib/mcp/version.rb
CHANGED
data/lib/mcp.rb
CHANGED
|
@@ -27,6 +27,7 @@ module MCP
|
|
|
27
27
|
autoload :ServerContext, "mcp/server_context"
|
|
28
28
|
autoload :ServerSession, "mcp/server_session"
|
|
29
29
|
autoload :Skill, "mcp/skill"
|
|
30
|
+
autoload :Subscriptions, "mcp/subscriptions"
|
|
30
31
|
autoload :Tool, "mcp/tool"
|
|
31
32
|
autoload :TraceContext, "mcp/trace_context"
|
|
32
33
|
|
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.
|
|
4
|
+
version: 1.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Model Context Protocol
|
|
@@ -62,8 +62,10 @@ files:
|
|
|
62
62
|
- lib/mcp/client/skills.rb
|
|
63
63
|
- lib/mcp/client/stdio.rb
|
|
64
64
|
- lib/mcp/client/tool.rb
|
|
65
|
+
- lib/mcp/client_capabilities.rb
|
|
65
66
|
- lib/mcp/configuration.rb
|
|
66
67
|
- lib/mcp/content.rb
|
|
68
|
+
- lib/mcp/duration.rb
|
|
67
69
|
- lib/mcp/elicitation.rb
|
|
68
70
|
- lib/mcp/elicitation/enum_schema.rb
|
|
69
71
|
- lib/mcp/error_codes.rb
|
|
@@ -101,6 +103,7 @@ files:
|
|
|
101
103
|
- lib/mcp/server/pagination.rb
|
|
102
104
|
- lib/mcp/server/pending_response.rb
|
|
103
105
|
- lib/mcp/server/request_state_security.rb
|
|
106
|
+
- lib/mcp/server/subscription_bus.rb
|
|
104
107
|
- lib/mcp/server/transports.rb
|
|
105
108
|
- lib/mcp/server/transports/event_store.rb
|
|
106
109
|
- lib/mcp/server/transports/stdio_transport.rb
|
|
@@ -112,6 +115,7 @@ files:
|
|
|
112
115
|
- lib/mcp/skill/frontmatter.rb
|
|
113
116
|
- lib/mcp/skill/resource_entry.rb
|
|
114
117
|
- lib/mcp/string_utils.rb
|
|
118
|
+
- lib/mcp/subscriptions.rb
|
|
115
119
|
- lib/mcp/tool.rb
|
|
116
120
|
- lib/mcp/tool/annotations.rb
|
|
117
121
|
- lib/mcp/tool/input_schema.rb
|
|
@@ -126,7 +130,7 @@ licenses:
|
|
|
126
130
|
- Apache-2.0
|
|
127
131
|
metadata:
|
|
128
132
|
allowed_push_host: https://rubygems.org
|
|
129
|
-
changelog_uri: https://github.com/modelcontextprotocol/ruby-sdk/releases/tag/v1.
|
|
133
|
+
changelog_uri: https://github.com/modelcontextprotocol/ruby-sdk/releases/tag/v1.13.0
|
|
130
134
|
homepage_uri: https://ruby.sdk.modelcontextprotocol.io
|
|
131
135
|
source_code_uri: https://github.com/modelcontextprotocol/ruby-sdk
|
|
132
136
|
bug_tracker_uri: https://github.com/modelcontextprotocol/ruby-sdk/issues
|