Module: ActionMCP::Renderable
- Included in:
- Capability
- Defined in:
- lib/action_mcp/renderable.rb
Overview
Module for rendering content.
Instance Method Summary collapse
-
#render(text: nil, audio: nil, image: nil, resource: nil, mime_type: nil, blob: nil) ⇒ Content::Text, ...
Renders content for Model Context Protocol responses.
-
#render_resource_link(uri:, name: nil, description: nil, mime_type: nil, annotations: nil) ⇒ Content::ResourceLink
Renders a resource link for Model Context Protocol responses.
Instance Method Details
#render(text: nil, audio: nil, image: nil, resource: nil, mime_type: nil, blob: nil) ⇒ Content::Text, ...
Renders content for Model Context Protocol responses.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/action_mcp/renderable.rb', line 23 def render(text: nil, audio: nil, image: nil, resource: nil, mime_type: nil, blob: nil) if resource && mime_type Content::Resource.new(resource, mime_type, text: text, blob: blob, annotations: nil) elsif text Content::Text.new(text, annotations: nil) elsif audio && mime_type Content::Audio.new(audio, mime_type, annotations: nil) elsif image && mime_type Content::Image.new(image, mime_type, annotations: nil) else raise ArgumentError, "No content to render" end end |
#render_resource_link(uri:, name: nil, description: nil, mime_type: nil, annotations: nil) ⇒ Content::ResourceLink
Renders a resource link for Model Context Protocol responses.
50 51 52 53 |
# File 'lib/action_mcp/renderable.rb', line 50 def render_resource_link(uri:, name: nil, description: nil, mime_type: nil, annotations: nil) Content::ResourceLink.new(uri, name: name, description: description, mime_type: mime_type, annotations: annotations) end |