Class: MCPClient::Prompt

Inherits:
Object
  • Object
show all
Includes:
DeepCopy
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

Methods included from DeepCopy

copy, #initialize_copy, shallow_copy

Constructor Details

#initialize(name:, description:, arguments: {}, title: nil, icons: nil, meta: nil, 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

  • title (String, nil) (defaults to: nil) —

    optional human-readable name of the prompt for display purposes

  • icons (Array<Hash>, nil) (defaults to: nil) —

    optional icons for display in user interfaces (MCP 2025-11-25)

  • meta (Hash, nil) (defaults to: nil) —

    optional _meta metadata attached to the prompt (MCP 2025-11-25)

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

    the server this prompt belongs to



34
35
36
37
38
39
40
41
42
# File 'lib/mcp_client/prompt.rb', line 34

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

Instance Attribute Details

#arguments ⇒ Hash (readonly)

Returns the JSON arguments for the prompt.

Returns:

  • (Hash) —

    the JSON arguments for the prompt



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

attr_reader :name, :title, :description, :arguments, :icons, :meta, :server

#description ⇒ String (readonly)

Returns the description of the prompt.

Returns:

  • (String) —

    the description of the prompt



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

attr_reader :name, :title, :description, :arguments, :icons, :meta, :server

#icons ⇒ Array<Hash>? (readonly)

Returns optional icons for display in user interfaces (MCP 2025-11-25, SEP-973).

Returns:

  • (Array<Hash>, nil) —

    optional icons for display in user interfaces (MCP 2025-11-25, SEP-973)



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

attr_reader :name, :title, :description, :arguments, :icons, :meta, :server

#meta ⇒ Hash? (readonly)

Returns optional _meta metadata attached to the prompt (MCP 2025-11-25).

Returns:

  • (Hash, nil) —

    optional _meta metadata attached to the prompt (MCP 2025-11-25)



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

attr_reader :name, :title, :description, :arguments, :icons, :meta, :server

#name ⇒ String (readonly)

Returns the name of the prompt.

Returns:

  • (String) —

    the name of the prompt



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

def name
  @name
end

#server ⇒ Object (readonly)

Returns the value of attribute server.



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

attr_reader :name, :title, :description, :arguments, :icons, :meta, :server

#title ⇒ String? (readonly)

Returns optional human-readable name of the prompt for display purposes.

Returns:

  • (String, nil) —

    optional human-readable name of the prompt for display purposes



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

attr_reader :name, :title, :description, :arguments, :icons, :meta, :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:



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/mcp_client/prompt.rb', line 48

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