Class: ActionMCP::Client::StreamableClient

Inherits:
Base
  • Object
show all
Defined in:
lib/action_mcp/client/streamable_client.rb

Overview

MCP client using Server-Sent Events (SSE) transport

Defined Under Namespace

Classes: ConnectionError

Constant Summary collapse

SSE_TIMEOUT =
10
ENDPOINT_TIMEOUT =

Seconds

5

Instance Attribute Summary collapse

Attributes inherited from Base

#blueprint, #catalog, #connection_error, #logger, #prompt_book, #server, #server_capabilities, #toolbox, #transport

Instance Method Summary collapse

Methods inherited from Base

#connect, #disconnect, #initialized?, #inspect, #write_message

Methods included from Elicitation

#process_elicitation_request, #send_elicitation_response

Methods included from Roots

#roots_list_changed_notification

Methods included from Resources

#list_resource_templates, #list_resources, #read_resource, #subscribe_resource, #unsubscribe_resource

Methods included from Prompts

#get_prompt, #list_prompts

Methods included from Tools

#call_tool, #list_tools

Methods included from Messaging

#send_jsonrpc_error, #send_jsonrpc_notification, #send_jsonrpc_request, #send_jsonrpc_response

Constructor Details

#initialize(url, connect: true, logger: ActionMCP.logger, **_options) ⇒ StreamableClient

Returns a new instance of StreamableClient.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/action_mcp/client/streamable_client.rb', line 15

def initialize(url, connect: true, logger: ActionMCP.logger, **_options)
  gem "faraday", ">= 2.0"
  require "faraday"
  require "uri"
  super(logger: logger)
  @type = :sse
  setup_connection(url)
  @buffer = +""
  @stop_requested = false
  @endpoint_received = false
  @endpoint_mutex = Mutex.new
  @endpoint_condition = ConditionVariable.new
  @connection_mutex = Mutex.new
  @connection_condition = ConditionVariable.new

  self.connect if connect
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



13
14
15
# File 'lib/action_mcp/client/streamable_client.rb', line 13

def base_url
  @base_url
end

#post_urlObject (readonly)

Returns the value of attribute post_url.



13
14
15
# File 'lib/action_mcp/client/streamable_client.rb', line 13

def post_url
  @post_url
end

#sessionObject (readonly)

Returns the value of attribute session.



13
14
15
# File 'lib/action_mcp/client/streamable_client.rb', line 13

def session
  @session
end

#sse_pathObject (readonly)

Returns the value of attribute sse_path.



13
14
15
# File 'lib/action_mcp/client/streamable_client.rb', line 13

def sse_path
  @sse_path
end