Class: ActionMCP::Client::PromptBook::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/action_mcp/client/prompt_book.rb

Overview

Internal Prompt class to represent individual prompts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Prompt

Initialize a new Prompt instance

Parameters:

  • data (Hash)

    Prompt definition hash containing name, description, and arguments



76
77
78
79
80
# File 'lib/action_mcp/client/prompt_book.rb', line 76

def initialize(data)
  @name = data["name"]
  @description = data["description"]
  @arguments = data["arguments"] || []
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



71
72
73
# File 'lib/action_mcp/client/prompt_book.rb', line 71

def arguments
  @arguments
end

#descriptionObject (readonly)

Returns the value of attribute description.



71
72
73
# File 'lib/action_mcp/client/prompt_book.rb', line 71

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



71
72
73
# File 'lib/action_mcp/client/prompt_book.rb', line 71

def name
  @name
end

Instance Method Details

#has_argument?(name) ⇒ Boolean

Check if the prompt has a specific argument

Parameters:

  • name (String)

    Name of the argument to check for

Returns:

  • (Boolean)

    true if the argument exists



100
101
102
# File 'lib/action_mcp/client/prompt_book.rb', line 100

def has_argument?(name)
  @arguments.any? { |arg| arg["name"] == name }
end

#optional_argumentsArray<Hash>

Get all optional arguments for this prompt

Returns:

  • (Array<Hash>)

    Array of argument hashes that are optional



92
93
94
# File 'lib/action_mcp/client/prompt_book.rb', line 92

def optional_arguments
  @arguments.reject { |arg| arg["required"] }
end

#required_argumentsArray<Hash>

Get all required arguments for this prompt

Returns:

  • (Array<Hash>)

    Array of argument hashes that are required



85
86
87
# File 'lib/action_mcp/client/prompt_book.rb', line 85

def required_arguments
  @arguments.select { |arg| arg["required"] }
end

#to_hHash

Generate a hash representation of the prompt

Returns:

  • (Hash)

    Hash containing prompt details



107
108
109
110
111
112
113
# File 'lib/action_mcp/client/prompt_book.rb', line 107

def to_h
  {
    "name" => @name,
    "description" => @description,
    "arguments" => @arguments
  }
end