Class: VSM::MCP::RemoteToolCapsule

Inherits:
ToolCapsule show all
Defined in:
lib/vsm/mcp/remote_tool_capsule.rb

Instance Attribute Summary collapse

Attributes inherited from ToolCapsule

#governance

Instance Method Summary collapse

Methods included from ActsAsTool

included

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

Parameters:

  • value

    the value to set the attribute bus to.



5
6
7
# File 'lib/vsm/mcp/remote_tool_capsule.rb', line 5

def bus=(value)
  @bus = value
end

Instance Method Details

#execution_modeObject



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.message}"
end

#tool_descriptorObject



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