Class: VSM::MCP::RemoteToolCapsule
- Inherits:
-
ToolCapsule
- Object
- ToolCapsule
- VSM::MCP::RemoteToolCapsule
- Defined in:
- lib/vsm/mcp/remote_tool_capsule.rb
Instance Attribute Summary collapse
-
#bus ⇒ Object
writeonly
Sets the attribute bus.
Attributes inherited from ToolCapsule
Instance Method Summary collapse
- #execution_mode ⇒ Object
-
#initialize(client:, remote_name:, descriptor:) ⇒ RemoteToolCapsule
constructor
A new instance of RemoteToolCapsule.
- #run(args) ⇒ Object
- #tool_descriptor ⇒ Object
Methods included from ActsAsTool
Constructor Details
#initialize(client:, remote_name:, descriptor:) ⇒ RemoteToolCapsule
Returns a new instance of RemoteToolCapsule.
7 8 9 10 11 |
# File 'lib/vsm/mcp/remote_tool_capsule.rb', line 7 def initialize(client:, remote_name:, descriptor:) @client = client @remote_name = remote_name @descriptor = descriptor # { name:, description:, input_schema: } end |
Instance Attribute Details
#bus=(value) ⇒ Object (writeonly)
Sets the attribute bus
5 6 7 |
# File 'lib/vsm/mcp/remote_tool_capsule.rb', line 5 def bus=(value) @bus = value end |
Instance Method Details
#execution_mode ⇒ Object
21 22 23 |
# File 'lib/vsm/mcp/remote_tool_capsule.rb', line 21 def execution_mode :thread end |
#run(args) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/vsm/mcp/remote_tool_capsule.rb', line 25 def run(args) @bus&.emit VSM::Message.new(kind: :progress, payload: "mcp call #{@client.name}.#{@remote_name}", path: [:mcp, :client, @client.name, @remote_name]) out = @client.call_tool(name: @remote_name, arguments: args || {}) @bus&.emit VSM::Message.new(kind: :progress, payload: "mcp result #{@client.name}.#{@remote_name}", path: [:mcp, :client, @client.name, @remote_name]) out.to_s rescue => e "ERROR: #{e.class}: #{e.}" end |
#tool_descriptor ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/vsm/mcp/remote_tool_capsule.rb', line 13 def tool_descriptor VSM::Tool::Descriptor.new( name: @descriptor[:name], description: @descriptor[:description], schema: @descriptor[:input_schema] ) end |