Class: SolidLoop::McpToolExecutionService

Inherits:
Object
  • Object
show all
Defined in:
app/services/solid_loop/mcp_tool_execution_service.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mcp_tool, agent, tool_call: nil) ⇒ McpToolExecutionService

Returns a new instance of McpToolExecutionService.



9
10
11
12
13
14
15
16
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 9

def initialize(mcp_tool, agent, tool_call: nil)
  @mcp_tool = mcp_tool
  @agent = agent
  @tool_call = tool_call
  @session = mcp_tool.mcp_session
  @mcp_config = agent.mcps.find { |c| c[:name].to_s == @session&.mcp_name }
  @retries_count = 0
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



3
4
5
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 3

def agent
  @agent
end

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 3

def client
  @client
end

#mcp_configObject (readonly)

Returns the value of attribute mcp_config.



3
4
5
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 3

def mcp_config
  @mcp_config
end

#mcp_toolObject (readonly)

Returns the value of attribute mcp_tool.



3
4
5
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 3

def mcp_tool
  @mcp_tool
end

#retries_countObject (readonly)

Returns the value of attribute retries_count.



3
4
5
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 3

def retries_count
  @retries_count
end

#sessionObject (readonly)

Returns the value of attribute session.



3
4
5
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 3

def session
  @session
end

#tool_callObject (readonly)

Returns the value of attribute tool_call.



3
4
5
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 3

def tool_call
  @tool_call
end

Class Method Details

.call(mcp_tool:, agent:, arguments:, tool_call: nil) ⇒ Object



5
6
7
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 5

def self.call(mcp_tool:, agent:, arguments:, tool_call: nil)
  new(mcp_tool, agent, tool_call: tool_call).call(arguments)
end

Instance Method Details

#call(arguments) ⇒ Object



18
19
20
21
22
23
24
25
# File 'app/services/solid_loop/mcp_tool_execution_service.rb', line 18

def call(arguments)
  @start_time = Time.current
  validate_context!
  @client = create_client
  execute_with_retries(arguments)
rescue => e
  build_error_result(e)
end