@@ -33,16 +33,12 @@ def start
3333 return if @mcp_client
3434
3535 transport = build_transport
36-
37- # Explicitly start the transport BEFORE creating the MCP client
38- # This ensures the stdio process is running before the client tries to use it
3936 transport . start if transport . respond_to? ( :start )
4037
4138 @mcp_client = ::MCP ::Client . new ( transport : transport )
4239 end
4340
4441 def stop
45- # Close the transport if it has a close method
4642 if @mcp_client && @mcp_client . transport . respond_to? ( :close )
4743 @mcp_client . transport . close
4844 end
@@ -59,7 +55,6 @@ def alive?
5955 end
6056
6157 def ping # rubocop:disable Naming/PredicateMethod
62- # Auto-start if not started
6358 ensure_started
6459 alive?
6560 end
@@ -107,33 +102,28 @@ def resource_read(uri:)
107102 end
108103
109104 def prompt_list ( cursor : nil ) # rubocop:disable Lint/UnusedMethodArgument
110- # The MCP gem does not support prompts
111105 [ ]
112106 end
113107
114108 def execute_prompt ( name :, arguments :)
115- # The MCP gem does not support prompts
116109 raise NotImplementedError , "Prompts are not supported by the MCP SDK (gem 'mcp')"
117110 end
118111
119112 def resource_template_list ( cursor : nil ) # rubocop:disable Lint/UnusedMethodArgument
120- # The MCP gem does not support resource templates
121113 [ ]
122114 end
123115
124- # Notifications
125116 def cancelled_notification ( reason :, request_id :)
126117 return unless @mcp_client &.transport . respond_to? ( :native_transport )
127118
128119 native_transport = @mcp_client . transport . native_transport
129120 return unless native_transport
130121
131- # Use the Native::Notifications::Cancelled class directly
132- RubyLLM ::MCP ::Native ::Notifications ::Cancelled . new (
133- native_transport ,
134- reason : reason ,
135- request_id : request_id
136- ) . call
122+ body = RubyLLM ::MCP ::Native ::Messages ::Notifications . cancelled (
123+ request_id : request_id ,
124+ reason : reason
125+ )
126+ native_transport . request ( body , wait_for_response : false )
137127 end
138128
139129 # These methods remain as NotImplementedError from base class:
@@ -198,7 +188,6 @@ def build_transport
198188 request_timeout : @config [ :request_timeout ] || 10_000
199189 )
200190 when :streamable , :streamable_http
201- # Prepare OAuth provider if OAuth config is present
202191 config_copy = @config . dup
203192 oauth_provider = Auth ::TransportOauthHelper . create_oauth_provider ( config_copy ) if Auth ::TransportOauthHelper . oauth_config_present? ( config_copy )
204193
@@ -233,7 +222,6 @@ def transform_tool(tool)
233222 end
234223
235224 def transform_resource ( resource )
236- # MCP gem returns resources as hashes, not objects
237225 {
238226 "name" => resource [ "name" ] ,
239227 "uri" => resource [ "uri" ] ,
@@ -253,12 +241,10 @@ def transform_tool_result(result)
253241 [ { "type" => "text" , "text" => result . to_s } ]
254242 end
255243
256- # Extract isError flag if present
257244 is_error = if result . is_a? ( Hash ) && result [ "result" ]
258245 result [ "result" ] [ "isError" ]
259246 end
260247
261- # Result expects response["result"] to contain the data
262248 result_data = { "content" => content }
263249 result_data [ "isError" ] = is_error unless is_error . nil?
264250
@@ -279,14 +265,12 @@ def transform_content_item(item)
279265 end
280266
281267 def transform_resource_content ( result )
282- # The MCP gem returns an array of content hashes
283268 contents = if result . is_a? ( Array )
284269 result . map { |r | transform_single_resource_content ( r ) }
285270 else
286271 [ transform_single_resource_content ( result ) ]
287272 end
288273
289- # Result expects response["result"] to contain the data
290274 Result . new ( {
291275 "result" => {
292276 "contents" => contents
@@ -295,7 +279,6 @@ def transform_resource_content(result)
295279 end
296280
297281 def transform_single_resource_content ( result )
298- # MCP gem returns resource contents as hashes, not objects
299282 {
300283 "uri" => result [ "uri" ] ,
301284 "mimeType" => result [ "mimeType" ] ,
0 commit comments