protocol

package
v1.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodInitialize = "initialize"
	MethodPing       = "ping"

	MethodToolsList = "tools/list"
	MethodToolsCall = "tools/call"

	MethodResourcesList          = "resources/list"
	MethodResourcesRead          = "resources/read"
	MethodResourcesTemplatesList = "resources/templates/list"
	MethodResourcesSubscribe     = "resources/subscribe"
	MethodResourcesUnsubscribe   = "resources/unsubscribe"

	MethodPromptsList = "prompts/list"
	MethodPromptsGet  = "prompts/get"

	MethodCompletionComplete = "completion/complete"

	MethodRootsList = "roots/list"

	MethodSamplingCreateMessage = "sampling/createMessage"

	MethodElicitationCreate = "elicitation/create"

	MethodLoggingSetLevel = "logging/setLevel"

	// Tasks methods (MCP 2025-11-25)
	MethodTasksGet    = "tasks/get"
	MethodTasksList   = "tasks/list"
	MethodTasksCancel = "tasks/cancel"
	MethodTasksResult = "tasks/result"
)
View Source
const (
	NotificationInitialized = "notifications/initialized"

	NotificationToolsListChanged = "notifications/tools/list_changed"

	NotificationResourcesListChanged = "notifications/resources/list_changed"
	NotificationResourcesUpdated     = "notifications/resources/updated"

	NotificationPromptsListChanged = "notifications/prompts/list_changed"

	NotificationRootsListChanged = "notifications/roots/list_changed"

	NotificationProgress  = "notifications/progress"
	NotificationCancelled = "notifications/cancelled"

	NotificationLoggingMessage = "notifications/message"

	// Elicitation notifications (MCP 2025-11-25)
	NotificationElicitationComplete = "notifications/elicitation/complete"

	// Tasks notifications (MCP 2025-11-25)
	NotificationTasksStatus = "notifications/tasks/status"
)
View Source
const (
	MCPVersion     = "2025-11-25"
	JSONRPCVersion = "2.0"

	// Supported protocol versions list (for backward compatibility check)
	MCPVersion2025_06_18 = "2025-06-18"
	MCPVersion2025_03_26 = "2025-03-26"
	MCPVersionLegacy     = "2024-11-05"
)
View Source
const (
	ParseError     = -32700
	InvalidRequest = -32600
	MethodNotFound = -32601
	InvalidParams  = -32602
	InternalError  = -32603
)

JSON-RPC 2.0 standard error codes

View Source
const (
	ToolNotFound     = -32000 // Tool not found
	ResourceNotFound = -32002 // Resource not found
	PromptNotFound   = -32001 // Prompt not found
	InvalidTool      = -32003 // Invalid tool
	InvalidResource  = -32004 // Invalid resource
	InvalidPrompt    = -32005 // Invalid prompt

	// MCP 2025-11-25: URL elicitation required error
	URLElicitationRequired = -32042

	ErrorCodeInvalidParams = InvalidParams
)

MCP specific error codes

Variables

This section is empty.

Functions

func ContentToJSON

func ContentToJSON(content []Content) ([]json.RawMessage, error)

func GetSupportedVersions

func GetSupportedVersions() []string

func IDToString

func IDToString(id json.RawMessage) string

func IsVersionSupported

func IsVersionSupported(version string) bool

func ShouldLog added in v1.2.2

func ShouldLog(messageLevel, minLevel LoggingLevel) bool

ShouldLog determines whether a log of the specified level should be sent messageLevel: the level of the message to send minLevel: the minimum level set by the client Returns true if the message should be sent (messageLevel >= minLevel)

func StringToID

func StringToID(id string) json.RawMessage

StringToID converts string to JSON-RPC ID

func ValidateElicitationAction added in v1.1.1

func ValidateElicitationAction(action string) bool

ValidateElicitationAction validates whether the elicitation action is valid

func ValidateStructuredOutput added in v1.1.0

func ValidateStructuredOutput(data interface{}, schema JSONSchema) error

ValidateStructuredOutput validates whether structured output conforms to the schema

Types

type Annotation added in v1.1.2

type Annotation struct {
	Audience     []Role  `json:"audience,omitempty"`     // Target audience (user, assistant)
	Priority     float64 `json:"priority,omitempty"`     // Priority (0.0-1.0)
	LastModified string  `json:"lastModified,omitempty"` // Last modified time (ISO 8601)
}

Annotation represents content annotation (MCP 2025-06-18)

func NewAnnotation added in v1.1.2

func NewAnnotation() *Annotation

NewAnnotation creates annotation (MCP 2025-06-18)

func (*Annotation) WithAudience added in v1.1.2

func (a *Annotation) WithAudience(audience ...Role) *Annotation

func (*Annotation) WithLastModified added in v1.1.2

func (a *Annotation) WithLastModified(lastModified string) *Annotation

func (*Annotation) WithPriority added in v1.1.2

func (a *Annotation) WithPriority(priority float64) *Annotation

type AudioContent added in v1.1.2

type AudioContent struct {
	Type        ContentType `json:"type"`
	Data        string      `json:"data"`     // Base64 encoded audio data
	MimeType    string      `json:"mimeType"` // e.g., audio/wav, audio/mp3
	Annotations *Annotation `json:"annotations,omitempty"`
}

AudioContent represents audio content (MCP 2025-06-18)

func NewAudioContent added in v1.1.2

func NewAudioContent(data, mimeType string) AudioContent

NewAudioContent creates audio content (MCP 2025-06-18)

func (AudioContent) GetType added in v1.1.2

func (ac AudioContent) GetType() ContentType

func (*AudioContent) WithAnnotations added in v1.1.2

func (ac *AudioContent) WithAnnotations(annotations *Annotation) *AudioContent

type CallToolParams

type CallToolParams struct {
	Meta      map[string]any `json:"_meta,omitempty"`
	Name      string         `json:"name"`
	Arguments map[string]any `json:"arguments"`
	Task      *TaskMetadata  `json:"task,omitempty"` // MCP 2025-11-25: Task metadata for task-augmented requests
}

type CallToolRequest

type CallToolRequest struct {
	Name      string         `json:"name"`
	Arguments map[string]any `json:"arguments,omitempty"`
	Task      *TaskMetadata  `json:"task,omitempty"` // MCP 2025-11-25: Task metadata for task-augmented requests
}

type CallToolResult

type CallToolResult struct {
	Content           []Content      `json:"content"`
	IsError           bool           `json:"isError,omitempty"`
	StructuredContent any            `json:"structuredContent,omitempty"` // MCP 2025-06-18
	Meta              map[string]any `json:"_meta,omitempty"`             // MCP 2025-06-18: Extended metadata
}

func NewToolResult

func NewToolResult(content []Content, isError bool) *CallToolResult

func NewToolResultError

func NewToolResultError(errorMsg string) *CallToolResult

func NewToolResultText

func NewToolResultText(text string) *CallToolResult

func NewToolResultTextWithStructured

func NewToolResultTextWithStructured(text string, structuredContent interface{}) *CallToolResult

NewToolResultTextWithStructured creates a tool result with text and structured content

func NewToolResultWithStructured

func NewToolResultWithStructured(content []Content, structuredContent interface{}) *CallToolResult

NewToolResultWithStructured creates a tool result with structured content (MCP 2025-06-18)

func (*CallToolResult) UnmarshalJSON

func (ctr *CallToolResult) UnmarshalJSON(data []byte) error

type CancelTaskParams added in v1.2.5

type CancelTaskParams struct {
	Meta   map[string]any `json:"_meta,omitempty"`
	TaskID string         `json:"taskId"`
	Reason string         `json:"reason,omitempty"`
}

CancelTaskParams represents the parameters for tasks/cancel request (MCP 2025-11-25)

type CancelTaskResult added in v1.2.5

type CancelTaskResult struct {
	Task
}

CancelTaskResult represents the result of tasks/cancel request (MCP 2025-11-25) Per spec, the result directly contains Task fields (no "task" wrapper)

type CancelledNotificationParams added in v1.1.6

type CancelledNotificationParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
	// Request ID to cancel
	RequestID any `json:"requestId"`
	// Optional cancellation reason description
	Reason string `json:"reason,omitempty"`
}

CancelledNotificationParams cancellation notification parameters

type ClientCapabilities

type ClientCapabilities struct {
	Roots        *RootsCapability       `json:"roots,omitempty"`
	Sampling     *SamplingCapability    `json:"sampling,omitempty"`
	Elicitation  *ElicitationCapability `json:"elicitation,omitempty"`
	Tasks        *ClientTasksCapability `json:"tasks,omitempty"` // MCP 2025-11-25
	Experimental map[string]interface{} `json:"experimental,omitempty"`
}

type ClientInfo

type ClientInfo struct {
	Name        string `json:"name"`
	Title       string `json:"title,omitempty"`
	Version     string `json:"version"`
	Description string `json:"description,omitempty"` // MCP 2025-11-25: Human-readable description
	WebsiteURL  string `json:"websiteUrl,omitempty"`
	Icons       []Icon `json:"icons,omitempty"`
}

type ClientTaskRequestsCapability added in v1.2.5

type ClientTaskRequestsCapability struct {
	// Sampling specifies task support for sampling-related requests
	Sampling *SamplingTaskCapability `json:"sampling,omitempty"`
	// Elicitation specifies task support for elicitation-related requests
	Elicitation *ElicitationTaskCapability `json:"elicitation,omitempty"`
}

ClientTaskRequestsCapability specifies which client-side requests support tasks (MCP 2025-11-25)

type ClientTasksCapability added in v1.2.5

type ClientTasksCapability struct {
	// List indicates client supports the tasks/list operation
	List *struct{} `json:"list,omitempty"`
	// Cancel indicates client supports the tasks/cancel operation
	Cancel *struct{} `json:"cancel,omitempty"`
	// Requests specifies which request types support task augmentation
	Requests *ClientTaskRequestsCapability `json:"requests,omitempty"`
}

ClientTasksCapability represents the tasks capability for clients (MCP 2025-11-25)

type CompleteRequest added in v1.1.2

type CompleteRequest struct {
	Ref      map[string]any     `json:"ref"`               // Reference (PromptReference or ResourceReference)
	Argument CompletionArgument `json:"argument"`          // Argument to complete
	Context  *CompletionContext `json:"context,omitempty"` // Optional context
}

CompleteRequest represents the completion request (completion/complete)

type CompleteResult added in v1.1.2

type CompleteResult struct {
	Completion CompletionResult `json:"completion"` // Completion result
}

CompleteResult represents the completion response

type CompletionArgument added in v1.1.2

type CompletionArgument struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type CompletionCapability added in v1.1.2

type CompletionCapability struct{}

CompletionCapability completion capability declaration

type CompletionContext added in v1.1.2

type CompletionContext struct {
	Arguments map[string]string `json:"arguments,omitempty"`
}

type CompletionReference added in v1.1.2

type CompletionReference interface {
	GetType() ReferenceType
}

CompletionReference completion reference (PromptReference or ResourceReference)

func UnmarshalCompletionReference added in v1.1.2

func UnmarshalCompletionReference(data map[string]any) (CompletionReference, error)

UnmarshalCompletionReference deserializes completion reference

type CompletionResult added in v1.1.2

type CompletionResult struct {
	Values  []string `json:"values"`          // Completion suggestions (max 100)
	Total   *int     `json:"total,omitempty"` // Optional: total matches count
	HasMore bool     `json:"hasMore"`         // Whether there are more results
}

CompletionResult represents completion result

func NewCompletionResult added in v1.1.2

func NewCompletionResult(values []string, hasMore bool) CompletionResult

func NewCompletionResultWithTotal added in v1.1.2

func NewCompletionResultWithTotal(values []string, total int, hasMore bool) CompletionResult

type Content

type Content interface {
	GetType() ContentType
}

func UnmarshalContent

func UnmarshalContent(data []byte) (Content, error)

type ContentBlock added in v1.2.5

type ContentBlock struct {
	Type     ContentType `json:"type"`
	Text     string      `json:"text,omitempty"`
	Data     string      `json:"data,omitempty"`
	MimeType string      `json:"mimeType,omitempty"`
}

ContentBlock represents a block of content in tool results (MCP 2025-11-25)

func NewImageContentBlock added in v1.2.5

func NewImageContentBlock(data, mimeType string) ContentBlock

NewImageContentBlock creates an image content block (MCP 2025-11-25)

func NewTextContentBlock added in v1.2.5

func NewTextContentBlock(text string) ContentBlock

NewTextContentBlock creates a text content block (MCP 2025-11-25)

type ContentType

type ContentType string
const (
	ContentTypeText         ContentType = "text"
	ContentTypeImage        ContentType = "image"
	ContentTypeAudio        ContentType = "audio"         // MCP 2025-06-18
	ContentTypeResourceLink ContentType = "resource_link" // MCP 2025-06-18
	ContentTypeResource     ContentType = "resource"      // MCP 2025-06-18: Embedded Resource
	ContentTypeToolUse      ContentType = "tool_use"      // MCP 2025-11-25: Tool use in sampling
	ContentTypeToolResult   ContentType = "tool_result"   // MCP 2025-11-25: Tool result in sampling
)

type CreateMessageParams added in v1.2.0

type CreateMessageParams = CreateMessageRequest

CreateMessageParams is an alias for CreateMessageRequest for consistency

type CreateMessageRequest added in v1.1.1

type CreateMessageRequest struct {
	Meta             map[string]any         `json:"_meta,omitempty"`
	Messages         []SamplingMessage      `json:"messages"`
	ModelPreferences *ModelPreferences      `json:"modelPreferences,omitempty"`
	SystemPrompt     string                 `json:"systemPrompt,omitempty"`
	IncludeContext   IncludeContext         `json:"includeContext,omitempty"`
	Temperature      *float64               `json:"temperature,omitempty"` // 0.0-1.0
	MaxTokens        int                    `json:"maxTokens"`             // Required
	StopSequences    []string               `json:"stopSequences,omitempty"`
	Metadata         map[string]interface{} `json:"metadata,omitempty"`
	// Tools available for the LLM to use (MCP 2025-11-25)
	Tools []SamplingTool `json:"tools,omitempty"`
	// ToolChoice controls tool selection behavior (MCP 2025-11-25)
	ToolChoice *ToolChoice `json:"toolChoice,omitempty"`
	// Task metadata for task-augmented requests (MCP 2025-11-25)
	Task *TaskMetadata `json:"task,omitempty"`
}

CreateMessageRequest create message request (server-initiated LLM sampling)

func (*CreateMessageRequest) Validate added in v1.1.1

func (cmr *CreateMessageRequest) Validate() error

Validate validates the create message request

type CreateMessageResult added in v1.1.1

type CreateMessageResult struct {
	Role       Role       `json:"role"`
	Content    Content    `json:"content"`
	Model      string     `json:"model"`
	StopReason StopReason `json:"stopReason"`
}

func NewCreateMessageResult added in v1.1.1

func NewCreateMessageResult(role Role, content Content, model string, stopReason StopReason) *CreateMessageResult

NewCreateMessageResult creates a message result

func (*CreateMessageResult) UnmarshalJSON added in v1.2.5

func (cmr *CreateMessageResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for CreateMessageResult

type CreateTaskResult added in v1.2.5

type CreateTaskResult struct {
	Meta map[string]any `json:"_meta,omitempty"`
	Task Task           `json:"task"`
}

CreateTaskResult is returned when a task-augmented request is accepted (MCP 2025-11-25)

type ElicitationAction added in v1.1.1

type ElicitationAction string
const (
	ElicitationActionAccept  ElicitationAction = "accept"
	ElicitationActionDecline ElicitationAction = "decline"
	ElicitationActionCancel  ElicitationAction = "cancel"
)

type ElicitationCapability added in v1.1.1

type ElicitationCapability struct {
	// Form indicates support for form-based elicitation (in-band structured data collection)
	Form *struct{} `json:"form,omitempty"`
	// URL indicates support for URL-based elicitation (out-of-band interaction)
	URL *struct{} `json:"url,omitempty"`
}

ElicitationCapability represents elicitation capability declaration (MCP 2025-11-25) Supports both form mode and URL mode

type ElicitationCompleteNotificationParams added in v1.2.5

type ElicitationCompleteNotificationParams struct {
	ElicitationID string `json:"elicitationId"`
}

ElicitationCompleteNotificationParams represents the parameters for notifications/elicitation/complete notification (MCP 2025-11-25) Sent when URL mode elicitation is completed

type ElicitationCreateParams added in v1.1.1

type ElicitationCreateParams struct {
	// Mode specifies the elicitation mode: "form" or "url" (MCP 2025-11-25)
	// Defaults to "form" for backward compatibility
	Mode ElicitationMode `json:"mode,omitempty"`
	// Message is the human-readable message to display to the user
	Message string `json:"message"`
	// RequestedSchema is the JSON schema for form mode validation (form mode only)
	RequestedSchema JSONSchema `json:"requestedSchema,omitempty"`
	// ElicitationID is a unique identifier for URL mode elicitation (url mode only)
	ElicitationID string `json:"elicitationId,omitempty"`
	// URL is the URL to navigate to for out-of-band interaction (url mode only)
	URL string `json:"url,omitempty"`
}

ElicitationCreateParams represents the parameters for elicitation/create request Supports both form mode and URL mode (MCP 2025-11-25)

func NewElicitationCreateParams added in v1.1.1

func NewElicitationCreateParams(message string, schema JSONSchema) *ElicitationCreateParams

type ElicitationMode added in v1.2.6

type ElicitationMode string

ElicitationMode represents the mode of elicitation (MCP 2025-11-25)

const (
	// ElicitationModeForm is for in-band structured data collection
	ElicitationModeForm ElicitationMode = "form"
	// ElicitationModeURL is for out-of-band interaction via URL navigation
	ElicitationModeURL ElicitationMode = "url"
)

type ElicitationResult added in v1.1.1

type ElicitationResult struct {
	Action  ElicitationAction `json:"action"`
	Content interface{}       `json:"content,omitempty"`
}

ElicitationResult represents the result of an elicitation request

func NewElicitationAccept added in v1.1.1

func NewElicitationAccept(content interface{}) *ElicitationResult

func NewElicitationCancel added in v1.1.1

func NewElicitationCancel() *ElicitationResult

func NewElicitationDecline added in v1.1.1

func NewElicitationDecline() *ElicitationResult

func NewElicitationResult added in v1.1.1

func NewElicitationResult(action ElicitationAction, content interface{}) *ElicitationResult

func (*ElicitationResult) IsAccepted added in v1.1.1

func (r *ElicitationResult) IsAccepted() bool

func (*ElicitationResult) IsCancelled added in v1.1.1

func (r *ElicitationResult) IsCancelled() bool

func (*ElicitationResult) IsDeclined added in v1.1.1

func (r *ElicitationResult) IsDeclined() bool

func (*ElicitationResult) MarshalJSON added in v1.1.1

func (r *ElicitationResult) MarshalJSON() ([]byte, error)

func (*ElicitationResult) UnmarshalJSON added in v1.1.1

func (r *ElicitationResult) UnmarshalJSON(data []byte) error

func (*ElicitationResult) Validate added in v1.1.1

func (r *ElicitationResult) Validate() error

type ElicitationTaskCapability added in v1.2.5

type ElicitationTaskCapability struct {
	// Create indicates client supports task-augmented elicitation/create requests
	Create *struct{} `json:"create,omitempty"`
}

ElicitationTaskCapability specifies task support for elicitation operations (MCP 2025-11-25)

type EmbeddedResourceContent added in v1.1.2

type EmbeddedResourceContent struct {
	Type     ContentType      `json:"type"`
	Resource ResourceContents `json:"resource"`
}

EmbeddedResourceContent represents embedded resource (MCP 2025-06-18)

func NewEmbeddedResourceContent added in v1.1.2

func NewEmbeddedResourceContent(resource ResourceContents) EmbeddedResourceContent

NewEmbeddedResourceContent creates embedded resource content (MCP 2025-06-18)

func (EmbeddedResourceContent) GetType added in v1.1.2

func (erc EmbeddedResourceContent) GetType() ContentType

type EmptyResult added in v1.2.0

type EmptyResult struct{}

type GetPromptParams

type GetPromptParams struct {
	Name      string            `json:"name"`
	Arguments map[string]string `json:"arguments,omitempty"`
}

GetPromptParams parameter type for getting prompt templates

type GetPromptRequest

type GetPromptRequest struct {
	Name      string            `json:"name"`
	Arguments map[string]string `json:"arguments,omitempty"`
}

GetPromptRequest prompts/get request and response

type GetPromptResult

type GetPromptResult struct {
	Description string          `json:"description,omitempty"`
	Messages    []PromptMessage `json:"messages"`
	Meta        map[string]any  `json:"_meta,omitempty"`
}

func NewGetPromptResult

func NewGetPromptResult(description string, messages ...PromptMessage) *GetPromptResult

type GetTaskParams added in v1.2.5

type GetTaskParams struct {
	Meta   map[string]any `json:"_meta,omitempty"`
	TaskID string         `json:"taskId"`
}

GetTaskParams represents the parameters for tasks/get request (MCP 2025-11-25)

type GetTaskResult added in v1.2.5

type GetTaskResult struct {
	Task
}

GetTaskResult represents the result of tasks/get request (MCP 2025-11-25) Per spec, the result directly contains Task fields (no "task" wrapper)

type Icon added in v1.2.2

type Icon struct {
	// Source is the URI pointing to the icon resource (required), can be:
	// - HTTP/HTTPS URL pointing to an image file
	// - data URI containing base64 encoded image data
	Source string `json:"src"`
	// MIMEType is an optional MIME type
	MIMEType string `json:"mimeType,omitempty"`
	// Sizes is an optional size specification (e.g., ["48x48"], ["any"] for scalable formats like SVG)
	Sizes []string `json:"sizes,omitempty"`
	// Theme is an optional theme, such as "light" or "dark"
	Theme string `json:"theme,omitempty"`
}

Icon defines icon for visual identification of resources, tools, prompts, and implementations

type ImageContent

type ImageContent struct {
	Type        ContentType `json:"type"`
	Data        string      `json:"data"`
	MimeType    string      `json:"mimeType"`
	Annotations *Annotation `json:"annotations,omitempty"` // MCP 2025-06-18
}

func NewImageContent

func NewImageContent(data, mimeType string) ImageContent

func (ImageContent) GetType

func (ic ImageContent) GetType() ContentType

func (*ImageContent) WithAnnotations added in v1.1.2

func (ic *ImageContent) WithAnnotations(annotations *Annotation) *ImageContent

type IncludeContext added in v1.1.1

type IncludeContext string

IncludeContext context inclusion options

const (
	IncludeContextNone       IncludeContext = "none"
	IncludeContextThisServer IncludeContext = "thisServer"
	IncludeContextAllServers IncludeContext = "allServers"
)

type InitializeParams added in v1.2.0

type InitializeParams struct {
	Meta            map[string]any     `json:"_meta,omitempty"`
	ProtocolVersion string             `json:"protocolVersion"`
	Capabilities    ClientCapabilities `json:"capabilities"`
	ClientInfo      ClientInfo         `json:"clientInfo"`
}

InitializeParams represents initialize request parameters

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string             `json:"protocolVersion"`
	Capabilities    ServerCapabilities `json:"capabilities"`
	ServerInfo      ServerInfo         `json:"serverInfo"`
	Instructions    string             `json:"instructions,omitempty"`
}

InitializeResult represents initialize response

type InitializedParams added in v1.2.0

type InitializedParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
}

type JSONRPCError

type JSONRPCError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

type JSONRPCMessage

type JSONRPCMessage struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Params  json.RawMessage `json:"params,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *JSONRPCError   `json:"error,omitempty"`
}

func (*JSONRPCMessage) GetIDString

func (m *JSONRPCMessage) GetIDString() string

func (*JSONRPCMessage) IsNotification

func (m *JSONRPCMessage) IsNotification() bool

type JSONSchema

type JSONSchema map[string]interface{}

func CreateBooleanElicitationSchema added in v1.1.1

func CreateBooleanElicitationSchema(propertyName, description string, defaultValue *bool, required bool) JSONSchema

CreateBooleanElicitationSchema creates a schema for requesting boolean input

func CreateElicitationSchema added in v1.1.1

func CreateElicitationSchema() JSONSchema

CreateElicitationSchema creates a common elicitation schema

func CreateEnumElicitationSchema added in v1.1.1

func CreateEnumElicitationSchema(propertyName, description string, options []string, optionNames []string, required bool) JSONSchema

CreateEnumElicitationSchema creates a schema for requesting enum selection

func CreateNumberElicitationSchema added in v1.1.1

func CreateNumberElicitationSchema(propertyName, description string, min, max *float64, required bool) JSONSchema

CreateNumberElicitationSchema creates a schema for requesting number input

func CreateStringElicitationSchema added in v1.1.1

func CreateStringElicitationSchema(propertyName, description string, required bool) JSONSchema

CreateStringElicitationSchema creates a schema for requesting string input

type ListPromptsParams

type ListPromptsParams struct {
	Cursor string `json:"cursor,omitempty"`
}

ListPromptsParams parameter type for listing prompt templates

type ListPromptsRequest

type ListPromptsRequest struct {
	Cursor string `json:"cursor,omitempty"`
}

ListPromptsRequest prompts/list request and response

type ListPromptsResult

type ListPromptsResult struct {
	Prompts []Prompt `json:"prompts"`
	PaginatedResult
}

type ListResourceTemplatesParams added in v1.2.2

type ListResourceTemplatesParams = ListResourceTemplatesRequest

ListResourceTemplatesParams is an alias for ListResourceTemplatesRequest

type ListResourceTemplatesRequest

type ListResourceTemplatesRequest struct {
	Cursor string `json:"cursor,omitempty"`
}

ListResourceTemplatesRequest resources/templates/list request and response

type ListResourceTemplatesResult

type ListResourceTemplatesResult struct {
	ResourceTemplates []ResourceTemplate `json:"resourceTemplates"`
	PaginatedResult
}

type ListResourcesParams

type ListResourcesParams struct {
	Cursor string `json:"cursor,omitempty"`
}

ListResourcesParams parameter type for listing resources

type ListResourcesRequest

type ListResourcesRequest struct {
	Cursor string `json:"cursor,omitempty"`
}

ListResourcesRequest resources/list request and response

type ListResourcesResult

type ListResourcesResult struct {
	Resources []Resource `json:"resources"`
	PaginatedResult
}

type ListRootsParams added in v1.1.2

type ListRootsParams struct {
}

ListRootsParams parameter type for listing root directories

type ListRootsRequest added in v1.1.2

type ListRootsRequest struct {
}

ListRootsRequest roots/list request

type ListRootsResult added in v1.1.2

type ListRootsResult struct {
	Roots []Root `json:"roots"`
}

ListRootsResult roots/list response

func NewListRootsResult added in v1.1.2

func NewListRootsResult(roots ...Root) *ListRootsResult

type ListTasksParams added in v1.2.5

type ListTasksParams struct {
	Meta   map[string]any `json:"_meta,omitempty"`
	Cursor string         `json:"cursor,omitempty"`
}

ListTasksParams represents the parameters for tasks/list request (MCP 2025-11-25)

type ListTasksResult added in v1.2.5

type ListTasksResult struct {
	Meta       map[string]any `json:"_meta,omitempty"`
	Tasks      []Task         `json:"tasks"`
	NextCursor *string        `json:"nextCursor,omitempty"`
}

ListTasksResult represents the result of tasks/list request (MCP 2025-11-25)

type ListToolsParams

type ListToolsParams struct {
	Cursor string `json:"cursor,omitempty"`
}

type ListToolsRequest

type ListToolsRequest struct {
	Cursor string `json:"cursor,omitempty"`
}

type ListToolsResult

type ListToolsResult struct {
	Tools []Tool `json:"tools"`
	PaginatedResult
}

type LoggingCapability

type LoggingCapability struct{}

type LoggingLevel added in v1.1.6

type LoggingLevel string

LoggingLevel logging level Maps to syslog message severity as described in RFC-5424: https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1

const (
	LogLevelDebug     LoggingLevel = "debug"     // Debug level messages
	LogLevelInfo      LoggingLevel = "info"      // Informational messages
	LogLevelNotice    LoggingLevel = "notice"    // Normal but significant messages
	LogLevelWarning   LoggingLevel = "warning"   // Warning messages
	LogLevelError     LoggingLevel = "error"     // Error messages
	LogLevelCritical  LoggingLevel = "critical"  // Critical error messages
	LogLevelAlert     LoggingLevel = "alert"     // Action must be taken immediately
	LogLevelEmergency LoggingLevel = "emergency" // System is unusable
)

type LoggingMessageParams added in v1.1.6

type LoggingMessageParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
	// Data to log, such as a string message or object
	// Allows any JSON-serializable type
	Data any `json:"data"`
	// Severity level of this log message
	Level LoggingLevel `json:"level"`
	// Optional name of the logger that emitted this message
	Logger string `json:"logger,omitempty"`
}

LoggingMessageParams notifications/message notification parameters

type MCPError added in v1.1.1

type MCPError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

MCPError represents MCP-specific error type

func NewMCPError added in v1.1.1

func NewMCPError(code int, message string, data interface{}) *MCPError

NewMCPError creates a new MCP error

func (*MCPError) Error added in v1.1.1

func (e *MCPError) Error() string

type ModelHint added in v1.1.1

type ModelHint struct {
	Name string `json:"name,omitempty"`
}

ModelHint model hint

type ModelPreferences added in v1.1.1

type ModelPreferences struct {
	Hints                []ModelHint `json:"hints,omitempty"`
	CostPriority         *float64    `json:"costPriority,omitempty"`         // 0-1, cost priority
	SpeedPriority        *float64    `json:"speedPriority,omitempty"`        // 0-1, speed priority
	IntelligencePriority *float64    `json:"intelligencePriority,omitempty"` // 0-1, intelligence priority
}

ModelPreferences model preference settings

func (*ModelPreferences) Validate added in v1.1.1

func (mp *ModelPreferences) Validate() error

Validate validates model preference settings

type PaginatedResult

type PaginatedResult struct {
	NextCursor *string `json:"nextCursor,omitempty"`
}

type PaginationParams

type PaginationParams struct {
	Cursor string `json:"cursor,omitempty"`
}

type PingParams added in v1.1.6

type PingParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
}

PingParams ping request parameters (empty parameters)

type ProgressNotificationParams added in v1.1.6

type ProgressNotificationParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
	// Progress token to associate this notification with an ongoing request
	ProgressToken any `json:"progressToken"`
	// Current progress value, should increase with each progress update
	Progress float64 `json:"progress"`
	// Total progress value (if known), 0 indicates unknown
	Total float64 `json:"total,omitempty"`
	// Optional progress description message
	Message string `json:"message,omitempty"`
}

ProgressNotificationParams progress notification parameters

type Prompt

type Prompt struct {
	Name        string           `json:"name"`
	Title       string           `json:"title,omitempty"` // MCP 2025-06-18: Human-friendly title
	Description string           `json:"description,omitempty"`
	Arguments   []PromptArgument `json:"arguments,omitempty"`
	Icons       []Icon           `json:"icons,omitempty"` // MCP 2025-11-25: Icons for UI display
	Meta        map[string]any   `json:"_meta,omitempty"` // MCP 2025-06-18: Extended metadata
}

func NewPrompt

func NewPrompt(name, description string, arguments ...PromptArgument) Prompt

type PromptArgument

type PromptArgument struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

func NewPromptArgument

func NewPromptArgument(name, description string, required bool) PromptArgument

type PromptListChangedParams added in v1.2.0

type PromptListChangedParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
}

type PromptMessage

type PromptMessage struct {
	Role    Role    `json:"role"`
	Content Content `json:"content"`
}

func NewPromptMessage

func NewPromptMessage(role Role, content Content) PromptMessage

func (*PromptMessage) UnmarshalJSON

func (pm *PromptMessage) UnmarshalJSON(data []byte) error

type PromptReference added in v1.1.2

type PromptReference struct {
	Type ReferenceType `json:"type"` // Must be "ref/prompt"
	Name string        `json:"name"` // Prompt name
}

func NewPromptReference added in v1.1.2

func NewPromptReference(name string) PromptReference

func (PromptReference) GetType added in v1.1.2

func (p PromptReference) GetType() ReferenceType

type PromptsCapability

type PromptsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

type PromptsListChangedNotification

type PromptsListChangedNotification struct{}

PromptsListChangedNotification prompt template change notification

type ReadResourceParams

type ReadResourceParams struct {
	URI string `json:"uri"`
}

ReadResourceParams parameter type for reading resources

type ReadResourceRequest

type ReadResourceRequest struct {
	URI string `json:"uri"`
}

ReadResourceRequest resources/read request and response

type ReadResourceResult

type ReadResourceResult struct {
	Contents []ResourceContents `json:"contents"`
}

func NewReadResourceResult

func NewReadResourceResult(contents ...ResourceContents) *ReadResourceResult

type ReferenceType added in v1.1.2

type ReferenceType string
const (
	ReferenceTypePrompt   ReferenceType = "ref/prompt"   // Prompt reference
	ReferenceTypeResource ReferenceType = "ref/resource" // Resource reference
)

type Resource

type Resource struct {
	URI         string         `json:"uri"`
	Name        string         `json:"name"`
	Title       string         `json:"title,omitempty"` // MCP 2025-11-25: Human-readable display name
	Description string         `json:"description,omitempty"`
	MimeType    string         `json:"mimeType,omitempty"`
	Icons       []Icon         `json:"icons,omitempty"`       // MCP 2025-11-25: Icons for UI display
	Size        *int64         `json:"size,omitempty"`        // MCP 2025-11-25: Size in bytes
	Annotations *Annotation    `json:"annotations,omitempty"` // MCP 2025-06-18: Resource annotations
	Meta        map[string]any `json:"_meta,omitempty"`
}

func NewResource

func NewResource(uri, name, description, mimeType string) Resource

type ResourceContents

type ResourceContents struct {
	URI         string      `json:"uri"`
	Title       string      `json:"title,omitempty"`
	MimeType    string      `json:"mimeType,omitempty"`
	Text        string      `json:"text,omitempty"`
	Blob        string      `json:"blob,omitempty"`
	Annotations *Annotation `json:"annotations,omitempty"`
}

func NewBlobResourceContents

func NewBlobResourceContents(uri, blob, mimeType string) ResourceContents

func NewTextResourceContents

func NewTextResourceContents(uri, text string) ResourceContents

type ResourceLinkContent added in v1.1.2

type ResourceLinkContent struct {
	Type        ContentType `json:"type"`
	URI         string      `json:"uri"`
	Name        string      `json:"name,omitempty"`
	Description string      `json:"description,omitempty"`
	MimeType    string      `json:"mimeType,omitempty"`
	Annotations *Annotation `json:"annotations,omitempty"`
}

ResourceLinkContent represents resource link (MCP 2025-06-18)

func NewResourceLinkContent added in v1.1.2

func NewResourceLinkContent(uri string) ResourceLinkContent

NewResourceLinkContent creates resource link content (MCP 2025-06-18)

func NewResourceLinkContentWithDetails added in v1.1.2

func NewResourceLinkContentWithDetails(uri, name, description, mimeType string) ResourceLinkContent

NewResourceLinkContentWithDetails creates resource link with details (MCP 2025-06-18)

func (ResourceLinkContent) GetType added in v1.1.2

func (rlc ResourceLinkContent) GetType() ContentType

func (*ResourceLinkContent) WithAnnotations added in v1.1.2

func (rlc *ResourceLinkContent) WithAnnotations(annotations *Annotation) *ResourceLinkContent

type ResourceListChangedParams added in v1.2.0

type ResourceListChangedParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
}

type ResourceReference added in v1.1.2

type ResourceReference struct {
	Type ReferenceType `json:"type"` // Must be "ref/resource"
	URI  string        `json:"uri"`  // Resource URI (may contain template variables)
}

ResourceReference resource reference

func NewResourceReference added in v1.1.2

func NewResourceReference(uri string) ResourceReference

func (ResourceReference) GetType added in v1.1.2

func (r ResourceReference) GetType() ReferenceType

type ResourceTemplate

type ResourceTemplate struct {
	URITemplate string         `json:"uriTemplate"`
	Name        string         `json:"name"`
	Title       string         `json:"title,omitempty"` // MCP 2025-11-25: Human-readable display name
	Description string         `json:"description,omitempty"`
	MimeType    string         `json:"mimeType,omitempty"`
	Icons       []Icon         `json:"icons,omitempty"` // MCP 2025-11-25: Icons for UI display
	Meta        map[string]any `json:"_meta,omitempty"`
}

func NewResourceTemplate added in v1.1.2

func NewResourceTemplate(uriTemplate, name, description, mimeType string) ResourceTemplate

type ResourceTemplatesListChangedNotification added in v1.1.2

type ResourceTemplatesListChangedNotification struct{}

type ResourceUpdatedNotificationParams added in v1.1.6

type ResourceUpdatedNotificationParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
	// Updated resource URI
	URI string `json:"uri"`
}

ResourceUpdatedNotificationParams resource update notification parameters

type ResourcesCapability

type ResourcesCapability struct {
	Subscribe   bool `json:"subscribe,omitempty"`
	ListChanged bool `json:"listChanged,omitempty"`
}

type ResourcesListChangedNotification

type ResourcesListChangedNotification struct{}

ResourcesListChangedNotification resource change notification

type Role

type Role string
const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleSystem    Role = "system"
)

type Root added in v1.1.2

type Root struct {
	URI  string `json:"uri"`            // Root directory URI, must use file:// protocol
	Name string `json:"name,omitempty"` // Optional human-readable name
}

Root root directory definition

func NewRoot added in v1.1.2

func NewRoot(uri, name string) Root

type RootsCapability

type RootsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

type RootsListChangedNotification added in v1.1.2

type RootsListChangedNotification struct{}

RootsListChangedNotification root directory list change notification

func NewRootsListChangedNotification added in v1.1.2

func NewRootsListChangedNotification() RootsListChangedNotification

type RootsListChangedParams added in v1.2.0

type RootsListChangedParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
}

RootsListChangedParams roots list change notification parameters

type SamplingCapability

type SamplingCapability struct {
	// Tools indicates client supports tool use in sampling requests (MCP 2025-11-25)
	Tools *struct{} `json:"tools,omitempty"`
}

type SamplingMessage added in v1.1.1

type SamplingMessage struct {
	Role    Role    `json:"role"`
	Content Content `json:"content"`
}

SamplingMessage sampling message

func (*SamplingMessage) UnmarshalJSON added in v1.2.5

func (sm *SamplingMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for SamplingMessage

type SamplingTaskCapability added in v1.2.5

type SamplingTaskCapability struct {
	// CreateMessage indicates client supports task-augmented sampling/createMessage requests
	CreateMessage *struct{} `json:"createMessage,omitempty"`
}

SamplingTaskCapability specifies task support for sampling operations (MCP 2025-11-25)

type SamplingTool added in v1.2.5

type SamplingTool struct {
	Name        string     `json:"name"`
	Description string     `json:"description,omitempty"`
	InputSchema JSONSchema `json:"inputSchema"`
}

SamplingTool represents a tool available for use in sampling (MCP 2025-11-25)

type ServerCapabilities

type ServerCapabilities struct {
	Tools        *ToolsCapability       `json:"tools,omitempty"`
	Resources    *ResourcesCapability   `json:"resources,omitempty"`
	Prompts      *PromptsCapability     `json:"prompts,omitempty"`
	Logging      *LoggingCapability     `json:"logging,omitempty"`
	Completion   *CompletionCapability  `json:"completion,omitempty"` // MCP 2025-06-18: Parameter auto-completion
	Tasks        *TasksCapability       `json:"tasks,omitempty"`      // MCP 2025-11-25
	Experimental map[string]interface{} `json:"experimental,omitempty"`
}

type ServerInfo

type ServerInfo struct {
	Name        string `json:"name"`
	Title       string `json:"title,omitempty"`
	Version     string `json:"version"`
	Description string `json:"description,omitempty"` // MCP 2025-11-25: Human-readable description
	WebsiteURL  string `json:"websiteUrl,omitempty"`
	Icons       []Icon `json:"icons,omitempty"`
}

type ServerTaskRequestsCapability added in v1.2.5

type ServerTaskRequestsCapability struct {
	// Tools specifies task support for tool-related requests
	Tools *ToolsTaskCapability `json:"tools,omitempty"`
}

ServerTaskRequestsCapability specifies which server-side requests support tasks (MCP 2025-11-25)

type SetLoggingLevelParams added in v1.1.6

type SetLoggingLevelParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
	// The log level the client wishes to receive from the server
	// The server should send all logs at this level and higher (i.e., more severe) to the client
	Level LoggingLevel `json:"level"`
}

SetLoggingLevelParams logging/setLevel request parameters

type StopReason added in v1.1.1

type StopReason string
const (
	StopReasonEndTurn      StopReason = "endTurn"
	StopReasonMaxTokens    StopReason = "maxTokens"
	StopReasonStopSequence StopReason = "stopSequence"
	StopReasonToolUse      StopReason = "toolUse"
)

type SubscribeParams added in v1.1.6

type SubscribeParams struct {
	URI string `json:"uri"`
}

SubscribeParams resources/subscribe request parameters

type Task added in v1.2.5

type Task struct {
	// TaskID is the unique identifier for this task
	TaskID string `json:"taskId"`
	// Status is the current state of the task execution
	Status TaskStatus `json:"status"`
	// StatusMessage is an optional human-readable message providing additional details
	StatusMessage string `json:"statusMessage,omitempty"`
	// CreatedAt is the ISO 8601 timestamp when the task was created
	CreatedAt string `json:"createdAt"`
	// LastUpdatedAt is the ISO 8601 timestamp when the task status was last updated
	LastUpdatedAt string `json:"lastUpdatedAt"`
	// TTL is the time-to-live in milliseconds from creation before task may be deleted
	// null indicates no TTL is set
	TTL *int `json:"ttl"`
	// PollInterval is the suggested time in milliseconds between status checks
	PollInterval *int `json:"pollInterval,omitempty"`
}

Task represents a durable state machine that carries information about the underlying execution state of a request (MCP 2025-11-25)

type TaskMetadata added in v1.2.5

type TaskMetadata struct {
	// TTL specifies the retention duration of a task in milliseconds
	TTL *int `json:"ttl,omitempty"`
}

TaskMetadata is used for augmenting requests with task execution details (MCP 2025-11-25)

type TaskResultParams added in v1.2.5

type TaskResultParams struct {
	Meta   map[string]any `json:"_meta,omitempty"`
	TaskID string         `json:"taskId"`
}

TaskResultParams represents the parameters for tasks/result request (MCP 2025-11-25)

type TaskStatus added in v1.2.5

type TaskStatus string

TaskStatus represents the current state of a task (MCP 2025-11-25)

const (
	// TaskStatusWorking indicates the task is currently being processed
	TaskStatusWorking TaskStatus = "working"
	// TaskStatusInputRequired indicates the task requires additional input from the requestor
	TaskStatusInputRequired TaskStatus = "input_required"
	// TaskStatusCompleted indicates the task has completed successfully
	TaskStatusCompleted TaskStatus = "completed"
	// TaskStatusFailed indicates the task failed during execution
	TaskStatusFailed TaskStatus = "failed"
	// TaskStatusCancelled indicates the task was cancelled
	TaskStatusCancelled TaskStatus = "cancelled"
)

type TaskStatusNotificationParams added in v1.2.5

type TaskStatusNotificationParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
	Task
}

TaskStatusNotificationParams represents the parameters for notifications/tasks/status (MCP 2025-11-25)

type TaskSupport added in v1.2.5

type TaskSupport string

TaskSupport indicates the level of task support for a tool (MCP 2025-11-25)

const (
	// TaskSupportRequired means clients MUST invoke the tool as a task
	TaskSupportRequired TaskSupport = "required"
	// TaskSupportOptional means clients MAY invoke the tool as a task or normal request
	TaskSupportOptional TaskSupport = "optional"
	// TaskSupportForbidden means clients MUST NOT invoke the tool as a task
	TaskSupportForbidden TaskSupport = "forbidden"
)

type TasksCapability added in v1.2.5

type TasksCapability struct {
	// List indicates server supports the tasks/list operation
	List *struct{} `json:"list,omitempty"`
	// Cancel indicates server supports the tasks/cancel operation
	Cancel *struct{} `json:"cancel,omitempty"`
	// Requests specifies which request types support task augmentation
	Requests *ServerTaskRequestsCapability `json:"requests,omitempty"`
}

TasksCapability represents the tasks capability for servers (MCP 2025-11-25)

type TextContent

type TextContent struct {
	Type        ContentType `json:"type"`
	Text        string      `json:"text"`
	Annotations *Annotation `json:"annotations,omitempty"` // MCP 2025-06-18
}

func NewTextContent

func NewTextContent(text string) TextContent

func (TextContent) GetType

func (tc TextContent) GetType() ContentType

func (*TextContent) WithAnnotations added in v1.1.2

func (tc *TextContent) WithAnnotations(annotations *Annotation) *TextContent

WithAnnotations adds annotations to content (MCP 2025-06-18)

type Tool

type Tool struct {
	Name         string          `json:"name"`
	Title        string          `json:"title,omitempty"` // MCP 2025-06-18: Human-friendly title
	Description  string          `json:"description,omitempty"`
	InputSchema  JSONSchema      `json:"inputSchema"`
	OutputSchema JSONSchema      `json:"outputSchema,omitempty"` // MCP 2025-06-18
	Execution    *ToolExecution  `json:"execution,omitempty"`    // MCP 2025-11-25: Execution behavior
	Icons        []Icon          `json:"icons,omitempty"`        // MCP 2025-11-25: Icons for UI display
	Annotations  *ToolAnnotation `json:"annotations,omitempty"`  // MCP 2025-06-18: Tool behavior annotations
	Meta         map[string]any  `json:"_meta,omitempty"`        // MCP 2025-06-18: Extended metadata
}

func NewTool

func NewTool(name, description string, inputSchema JSONSchema) Tool

func NewToolWithOutput added in v1.1.0

func NewToolWithOutput(name, description string, inputSchema, outputSchema JSONSchema) Tool

NewToolWithOutput creates a tool with output schema (MCP 2025-06-18)

type ToolAnnotation added in v1.2.6

type ToolAnnotation struct {
	// Title is a human-readable title for the tool
	Title string `json:"title,omitempty"`
	// ReadOnlyHint indicates the tool only reads data without side effects
	ReadOnlyHint bool `json:"readOnlyHint,omitempty"`
	// DestructiveHint indicates the tool may have destructive/irreversible effects
	DestructiveHint bool `json:"destructiveHint,omitempty"`
	// IdempotentHint indicates calling the tool multiple times has the same effect
	IdempotentHint bool `json:"idempotentHint,omitempty"`
	// OpenWorldHint indicates the tool interacts with external entities
	OpenWorldHint bool `json:"openWorldHint,omitempty"`
}

ToolAnnotation describes tool behavior characteristics (MCP 2025-06-18)

type ToolChoice added in v1.2.5

type ToolChoice struct {
	Mode ToolChoiceMode `json:"mode,omitempty"`
}

ToolChoice controls tool selection behavior in sampling requests (MCP 2025-11-25)

type ToolChoiceMode added in v1.2.5

type ToolChoiceMode string

ToolChoiceMode represents the tool selection mode (MCP 2025-11-25)

const (
	// ToolChoiceModeAuto allows the model to decide whether to use tools (default)
	ToolChoiceModeAuto ToolChoiceMode = "auto"
	// ToolChoiceModeRequired forces the model to use at least one tool
	ToolChoiceModeRequired ToolChoiceMode = "required"
	// ToolChoiceModeNone prevents the model from using any tools
	ToolChoiceModeNone ToolChoiceMode = "none"
)

type ToolExecution added in v1.2.5

type ToolExecution struct {
	// TaskSupport indicates the level of task support for this tool
	// Can be "required", "optional", or "forbidden"
	TaskSupport TaskSupport `json:"taskSupport,omitempty"`
}

ToolExecution specifies execution behavior for a tool (MCP 2025-11-25)

type ToolList

type ToolList struct {
	Tools []Tool `json:"tools"`
}

type ToolListChangedParams added in v1.2.0

type ToolListChangedParams struct {
	Meta map[string]any `json:"_meta,omitempty"`
}

type ToolParameter

type ToolParameter struct {
	Name        string     `json:"name"`
	Description string     `json:"description,omitempty"`
	Required    bool       `json:"required,omitempty"`
	Schema      JSONSchema `json:"schema,omitempty"`
}

func BooleanParameter

func BooleanParameter(name, description string, required bool) ToolParameter

func NumberParameter

func NumberParameter(name, description string, required bool) ToolParameter

func ObjectParameter

func ObjectParameter(name, description string, required bool, properties JSONSchema, required_props []string) ToolParameter

func StringParameter

func StringParameter(name, description string, required bool) ToolParameter

type ToolResultContent added in v1.2.5

type ToolResultContent struct {
	Type              ContentType            `json:"type"`
	ToolUseID         string                 `json:"toolUseId"`
	Content           []ContentBlock         `json:"content"`
	IsError           bool                   `json:"isError,omitempty"`
	StructuredContent map[string]interface{} `json:"structuredContent,omitempty"`
	Meta              map[string]any         `json:"_meta,omitempty"`
}

ToolResultContent represents the result of a tool execution in sampling (MCP 2025-11-25)

func NewToolResultContent added in v1.2.5

func NewToolResultContent(toolUseID string, content []ContentBlock) ToolResultContent

NewToolResultContent creates tool result content for sampling (MCP 2025-11-25)

func NewToolResultContentWithError added in v1.2.5

func NewToolResultContentWithError(toolUseID string, content []ContentBlock, isError bool) ToolResultContent

NewToolResultContentWithError creates tool result content with error flag (MCP 2025-11-25)

func (ToolResultContent) GetType added in v1.2.5

func (trc ToolResultContent) GetType() ContentType

type ToolUseContent added in v1.2.5

type ToolUseContent struct {
	Type  ContentType            `json:"type"`
	ID    string                 `json:"id"`
	Name  string                 `json:"name"`
	Input map[string]interface{} `json:"input"`
	Meta  map[string]any         `json:"_meta,omitempty"`
}

ToolUseContent represents a tool invocation request in sampling (MCP 2025-11-25)

func NewToolUseContent added in v1.2.5

func NewToolUseContent(id, name string, input map[string]interface{}) ToolUseContent

NewToolUseContent creates tool use content for sampling (MCP 2025-11-25)

func (ToolUseContent) GetType added in v1.2.5

func (tuc ToolUseContent) GetType() ContentType

type ToolsCapability

type ToolsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

type ToolsListChangedNotification

type ToolsListChangedNotification struct{}

type ToolsTaskCapability added in v1.2.5

type ToolsTaskCapability struct {
	// Call specifies task augmentation support for tools/call (MCP 2025-11-25)
	Call *struct{} `json:"call,omitempty"`
}

ToolsTaskCapability specifies task support for tool operations (MCP 2025-11-25)

type UnsubscribeParams added in v1.1.6

type UnsubscribeParams struct {
	URI string `json:"uri"`
}

UnsubscribeParams resources/unsubscribe request parameters

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL