Source File
prompts.go
Belonging Package
github.com/mark3labs/mcp-go/mcp
package mcpimport/* Prompts */// ListPromptsRequest is sent from the client to request a list of prompts and// prompt templates the server has.type ListPromptsRequest struct {PaginatedRequestHeader http.Header `json:"-"`}// ListPromptsResult is the server's response to a prompts/list request from// the client.type ListPromptsResult struct {PaginatedResultPrompts []Prompt `json:"prompts"`}// GetPromptRequest is used by the client to get a prompt provided by the// server.type GetPromptRequest struct {RequestParams GetPromptParams `json:"params"`Header http.Header `json:"-"`}type GetPromptParams struct {// The name of the prompt or prompt template.Name string `json:"name"`// Arguments to use for templating the prompt.Arguments map[string]string `json:"arguments,omitempty"`}// GetPromptResult is the server's response to a prompts/get request from the// client.type GetPromptResult struct {Result// An optional description for the prompt.Description string `json:"description,omitempty"`Messages []PromptMessage `json:"messages"`}// Prompt represents a prompt or prompt template that the server offers.// If Arguments is non-nil and non-empty, this indicates the prompt is a template// that requires argument values to be provided when calling prompts/get.// If Arguments is nil or empty, this is a static prompt that takes no arguments.type Prompt struct {// Meta is a metadata object that is reserved by MCP for storing additional information.Meta *Meta `json:"_meta,omitempty"`// The name of the prompt or prompt template.Name string `json:"name"`// An optional description of what this prompt providesDescription string `json:"description,omitempty"`// A list of arguments to use for templating the prompt.// The presence of arguments indicates this is a template prompt.Arguments []PromptArgument `json:"arguments,omitempty"`// Icons provides visual identifiers for the promptIcons []Icon `json:"icons,omitempty"`}// GetName returns the name of the prompt.func ( Prompt) () string {return .Name}// PromptArgument describes an argument that a prompt template can accept.// When a prompt includes arguments, clients must provide values for all// required arguments when making a prompts/get request.type PromptArgument struct {// The name of the argument.Name string `json:"name"`// A human-readable description of the argument.Description string `json:"description,omitempty"`// Whether this argument must be provided.// If true, clients must include this argument when calling prompts/get.Required bool `json:"required,omitempty"`}// Role represents the sender or recipient of messages and data in a// conversation.type Role stringconst (RoleUser Role = "user"RoleAssistant Role = "assistant")// PromptMessage describes a message returned as part of a prompt.//// This is similar to `SamplingMessage`, but also supports the embedding of// resources from the MCP server.type PromptMessage struct {Role Role `json:"role"`Content Content `json:"content"` // Can be TextContent, ImageContent, AudioContent or EmbeddedResource}// PromptListChangedNotification is an optional notification from the server// to the client, informing it that the list of prompts it offers has changed. This// may be issued by servers without any previous subscription from the client.type PromptListChangedNotification struct {Notification}// PromptOption is a function that configures a Prompt.// It provides a flexible way to set various properties of a Prompt using the functional options pattern.type PromptOption func(*Prompt)// ArgumentOption is a function that configures a PromptArgument.// It allows for flexible configuration of prompt arguments using the functional options pattern.type ArgumentOption func(*PromptArgument)//// Core Prompt Functions//// NewPrompt creates a new Prompt with the given name and options.// The prompt will be configured based on the provided options.// Options are applied in order, allowing for flexible prompt configuration.func ( string, ...PromptOption) Prompt {:= Prompt{Name: ,}for , := range {(&)}return}// WithPromptDescription adds a description to the Prompt.// The description should provide a clear, human-readable explanation of what the prompt does.func ( string) PromptOption {return func( *Prompt) {.Description =}}// WithPromptIcons adds icons to the Prompt.// Icons provide visual identifiers for the prompt.func ( ...Icon) PromptOption {return func( *Prompt) {.Icons =}}// WithArgument adds an argument to the prompt's argument list.// The argument will be configured based on the provided options.func ( string, ...ArgumentOption) PromptOption {return func( *Prompt) {:= PromptArgument{Name: ,}for , := range {(&)}if .Arguments == nil {.Arguments = make([]PromptArgument, 0)}.Arguments = append(.Arguments, )}}//// Argument Options//// ArgumentDescription adds a description to a prompt argument.// The description should explain the purpose and expected values of the argument.func ( string) ArgumentOption {return func( *PromptArgument) {.Description =}}// RequiredArgument marks an argument as required in the prompt.// Required arguments must be provided when getting the prompt.func () ArgumentOption {return func( *PromptArgument) {.Required = true}}
![]() |
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |