OzMcp.Structs.GetPromptResult (OzMcp v0.9.0)

Copy Markdown View Source

Helper module used to build GetPromptResult structure.

(MCP protocol: 2025-11-25)

Short example:

%GetPromptResult{}
  |> GetPromptResult.messages([
    %PromptMessage{}
    |> PromptMessage.role(:user)
    |> PromptMessage.content(
      %TextContent{}
      |> TextContent.text("Hello, world!")
    )
  ])
  |> GetPromptResult.build()

Result:

%{
  messages: [
    %{"content" => %{type: "text", text: "Hello, world!"}, "role" => "user"}
  ]
}

Long example:

%GetPromptResult{}
  |> GetPromptResult.description("Get the weather for a city")
  |> GetPromptResult.messages([
    %PromptMessage{}
    |> PromptMessage.role(:user)
    |> PromptMessage.content(
      %TextContent{}
      |> TextContent.text("What is the weather in Paris?")
    ),
    %PromptMessage{}
    |> PromptMessage.role(:assistant)
    |> PromptMessage.content(
      %TextContent{}
      |> TextContent.text("The weather in Paris is sunny.")
    )
  ])
  |> GetPromptResult.build()

Result:

%{
  messages: [
    %{
      "content" => %{type: "text", text: "What is the weather in Paris?"},
      "role" => "user"
    },
    %{
      "content" => %{type: "text", text: "The weather in Paris is sunny."},
      "role" => "assistant"
    }
  ],
  description: "Get the weather for a city"
}

Specification: GetPromptResult

Fields

FieldSetterTypeRequired
messagesmessages/2messages()yes
descriptiondescription/2stringno
_meta_meta/2mapno

Summary

Types

messages()

@type messages() ::
  OzMcp.Structs.Types.list_of(%OzMcp.Structs.PromptMessage{
    content: term(),
    role: term()
  })

t()

@type t() :: %OzMcp.Structs.GetPromptResult{
  _meta: map() | nil,
  description: String.t() | nil,
  messages: messages()
}

Functions

build(struct)

@spec build(t()) :: map()

description(struct, value)

@spec description(t(), String.t() | nil) :: t()

messages(struct, value)

@spec messages(t(), messages()) :: t()