Class: RailsAiBridge::Instrumentation::InstrumentedTool
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- RailsAiBridge::Instrumentation::InstrumentedTool
- 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
- #call(server_context: nil, **arguments) ⇒ MCP::Tool::Response
-
#initialize(tool_class) ⇒ InstrumentedTool
constructor
A new instance of InstrumentedTool.
Constructor Details
#initialize(tool_class) ⇒ InstrumentedTool
Returns a new instance of InstrumentedTool.
32 33 34 35 36 |
# File 'lib/rails_ai_bridge/instrumentation.rb', line 32 def initialize(tool_class) super @tool_class = tool_class @server_context_param = detect_server_context_param(tool_class) end |
Instance Method Details
#call(server_context: nil, **arguments) ⇒ MCP::Tool::Response
41 42 43 44 45 46 47 |
# File 'lib/rails_ai_bridge/instrumentation.rb', line 41 def call(server_context: nil, **arguments) Instrumentation.instrument('tool.call', tool_name: @tool_class.tool_name, arguments: arguments) do Registry.with_request_resolver do invoke_tool(arguments, server_context) end end end |