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: {}, 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



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

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

#argumentsHash (readonly)

Returns the JSON arguments for the prompt.

Returns:

  • (Hash)

    the JSON arguments for the prompt



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

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

#descriptionString (readonly)

Returns the description of the prompt.

Returns:

  • (String)

    the description of the prompt



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

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

#iconsArray<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)



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

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

#metaHash? (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)



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

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

#nameString (readonly)

Returns the name of the prompt.

Returns:

  • (String)

    the name of the prompt



20
21
22
# File 'lib/mcp_client/prompt.rb', line 20

def name
  @name
end

#serverObject (readonly)

Returns the value of attribute server.



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

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

#titleString? (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



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

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:



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mcp_client/prompt.rb', line 44

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