Class: RailsAiBridge::Instrumentation::InstrumentedTool

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/rails_ai_bridge/instrumentation.rb

Overview

Wraps an MCP tool class so every call emits a rails_ai_bridge.tool.call event. Caching, when enabled, is handled by the inner wrapper so cache hit/miss events stay separate from the invocation event.

Instance Method Summary collapse

Constructor Details

#initialize(tool_class) ⇒ InstrumentedTool

Returns a new instance of InstrumentedTool.



32
33
34
35
# File 'lib/rails_ai_bridge/instrumentation.rb', line 32

def initialize(tool_class)
  super
  @tool_class = tool_class
end

Instance Method Details

#call(server_context: nil, **arguments) ⇒ MCP::Tool::Response

Parameters:

  • server_context (Object, nil) (defaults to: nil)
  • arguments (Hash)

Returns:

  • (MCP::Tool::Response)


40
41
42
43
44
# File 'lib/rails_ai_bridge/instrumentation.rb', line 40

def call(server_context: nil, **arguments)
  Instrumentation.instrument('tool.call', tool_name: @tool_class.tool_name, arguments: arguments) do
    @tool_class.call(server_context: server_context, **arguments)
  end
end