Class: MCPClient::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/mcp_client/prompt.rb

Overview

Representation of an MCP prompt

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, description:, arguments: {}, server: nil) ⇒ Prompt

Initialize a new prompt

Parameters:

  • name (String)

    the name of the prompt

  • description (String)

    the description of the prompt

  • arguments (Hash) (defaults to: {})

    the JSON arguments for the prompt

  • server (MCPClient::ServerBase, nil) (defaults to: nil)

    the server this prompt belongs to



21
22
23
24
25
26
# File 'lib/mcp_client/prompt.rb', line 21

def initialize(name:, description:, arguments: {}, server: nil)
  @name = name
  @description = description
  @arguments = arguments
  @server = server
end

Instance Attribute Details

#argumentsHash (readonly)

Returns the JSON arguments for the prompt.

Returns:

  • (Hash)

    the JSON arguments for the prompt



14
# File 'lib/mcp_client/prompt.rb', line 14

attr_reader :name, :description, :arguments, :server

#descriptionString (readonly)

Returns the description of the prompt.

Returns:

  • (String)

    the description of the prompt



14
# File 'lib/mcp_client/prompt.rb', line 14

attr_reader :name, :description, :arguments, :server

#nameString (readonly)

Returns the name of the prompt.

Returns:

  • (String)

    the name of the prompt



14
15
16
# File 'lib/mcp_client/prompt.rb', line 14

def name
  @name
end

#serverObject (readonly)

Returns the value of attribute server.



14
# File 'lib/mcp_client/prompt.rb', line 14

attr_reader :name, :description, :arguments, :server

Class Method Details

.from_json(data, server: nil) ⇒ MCPClient::Prompt

Create a Prompt instance from JSON data

Parameters:

  • data (Hash)

    JSON data from MCP server

  • server (MCPClient::ServerBase, nil) (defaults to: nil)

    the server this prompt belongs to

Returns:



32
33
34
35
36
37
38
39
# File 'lib/mcp_client/prompt.rb', line 32

def self.from_json(data, server: nil)
  new(
    name: data['name'],
    description: data['description'],
    arguments: data['arguments'] || {},
    server: server
  )
end