Method: ActionMCP::Tool#render

Defined in:
lib/action_mcp/tool.rb

#render(structured: nil, **args) ⇒ Object

Override render to collect Content objects and support structured content



491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/action_mcp/tool.rb', line 491

def render(structured: nil, **args)
  if structured
    # Validate structured content against output_schema if enabled
    validate_structured_content!(structured) if self.class._output_schema

    # Render structured content
    set_structured_content(structured)
    structured
  else
    # Normal content rendering
    content = super(**args) # Call Renderable's render method
    @response.add(content)  # Add to the response
    content # Return the content for potential use in perform
  end
end