Low-level protocol types for MCP requests, responses, parameters, and results. These types are used for communication between clients and servers.
Parameters for calling a tool (used by clients).
import "github.com/modelcontextprotocol/go-sdk/mcp"
type CallToolParams struct {
Meta `json:"_meta,omitempty"`
Name string `json:"name"`
Arguments any `json:"arguments,omitempty"`
}Fields:
Meta: Reserved metadata fieldName: Name of the tool to callArguments: Tool arguments (any JSON-marshalable value)Methods:
func (p *CallToolParams) GetProgressToken() any
func (p *CallToolParams) SetProgressToken(t any)Parameters passed to tool handlers on the server with raw (unmarshaled) arguments.
type CallToolParamsRaw struct {
Meta `json:"_meta,omitempty"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}Fields:
Meta: Reserved metadata fieldName: Name of the tool being calledArguments: Raw arguments from the client (handler must unmarshal)Methods:
func (p *CallToolParamsRaw) GetProgressToken() any
func (p *CallToolParamsRaw) SetProgressToken(t any)Type alias for tool call requests received by servers.
type CallToolRequest = ServerRequest[*CallToolParamsRaw]Server's response to a tool call.
type CallToolResult struct {
Meta `json:"_meta,omitempty"`
Content []Content `json:"content"`
StructuredContent any `json:"structuredContent,omitempty"`
IsError bool `json:"isError,omitempty"`
}Fields:
Meta: Reserved metadata fieldContent: List of content objects representing unstructured resultStructuredContent: Optional structured result (must marshal to JSON object)IsError: Whether the tool call ended in errorMethods:
func (r *CallToolResult) UnmarshalJSON(data []byte) errorParameters for listing tools.
type ListToolsParams struct {
Meta `json:"_meta,omitempty"`
Cursor string `json:"cursor,omitempty"`
}Fields:
Meta: Reserved metadata fieldCursor: Opaque pagination tokenMethods:
func (p *ListToolsParams) GetProgressToken() any
func (p *ListToolsParams) SetProgressToken(t any)Type alias for list tools requests.
type ListToolsRequest = ServerRequest[*ListToolsParams]Server's response to a list tools request.
type ListToolsResult struct {
Meta `json:"_meta,omitempty"`
NextCursor string `json:"nextCursor,omitempty"`
Tools []*Tool `json:"tools"`
}Fields:
Meta: Reserved metadata fieldNextCursor: Pagination token for next pageTools: List of available toolsParameters for tool list changed notifications.
type ToolListChangedParams struct {
Meta `json:"_meta,omitempty"`
}Methods:
func (p *ToolListChangedParams) GetProgressToken() any
func (p *ToolListChangedParams) SetProgressToken(t any)Type alias for tool list changed notification requests.
type ToolListChangedRequest = ClientRequest[*ToolListChangedParams]Parameters for getting a prompt.
type GetPromptParams struct {
Meta `json:"_meta,omitempty"`
Arguments map[string]string `json:"arguments,omitempty"`
Name string `json:"name"`
}Fields:
Meta: Reserved metadata fieldArguments: Arguments for templating the promptName: Name of the prompt or prompt templateMethods:
func (p *GetPromptParams) GetProgressToken() any
func (p *GetPromptParams) SetProgressToken(t any)Type alias for get prompt requests.
type GetPromptRequest = ServerRequest[*GetPromptParams]Server's response to a get prompt request.
type GetPromptResult struct {
Meta `json:"_meta,omitempty"`
Description string `json:"description,omitempty"`
Messages []*PromptMessage `json:"messages"`
}Fields:
Meta: Reserved metadata fieldDescription: Optional prompt descriptionMessages: List of prompt messagesParameters for listing prompts.
type ListPromptsParams struct {
Meta `json:"_meta,omitempty"`
Cursor string `json:"cursor,omitempty"`
}Fields:
Meta: Reserved metadata fieldCursor: Opaque pagination tokenMethods:
func (p *ListPromptsParams) GetProgressToken() any
func (p *ListPromptsParams) SetProgressToken(t any)Type alias for list prompts requests.
type ListPromptsRequest = ServerRequest[*ListPromptsParams]Server's response to a list prompts request.
type ListPromptsResult struct {
Meta `json:"_meta,omitempty"`
NextCursor string `json:"nextCursor,omitempty"`
Prompts []*Prompt `json:"prompts"`
}Fields:
Meta: Reserved metadata fieldNextCursor: Pagination token for next pagePrompts: List of available promptsParameters for prompt list changed notifications.
type PromptListChangedParams struct {
Meta `json:"_meta,omitempty"`
}Methods:
func (p *PromptListChangedParams) GetProgressToken() any
func (p *PromptListChangedParams) SetProgressToken(t any)Type alias for prompt list changed notification requests.
type PromptListChangedRequest = ClientRequest[*PromptListChangedParams]Parameters for reading a resource.
type ReadResourceParams struct {
Meta `json:"_meta,omitempty"`
URI string `json:"uri"`
}Fields:
Meta: Reserved metadata fieldURI: URI of the resource to readMethods:
func (p *ReadResourceParams) GetProgressToken() any
func (p *ReadResourceParams) SetProgressToken(t any)Type alias for read resource requests.
type ReadResourceRequest = ServerRequest[*ReadResourceParams]Server's response to a read resource request.
type ReadResourceResult struct {
Meta `json:"_meta,omitempty"`
Contents []*ResourceContents `json:"contents"`
}Fields:
Meta: Reserved metadata fieldContents: List of resource contentsParameters for listing resources.
type ListResourcesParams struct {
Meta `json:"_meta,omitempty"`
Cursor string `json:"cursor,omitempty"`
}Fields:
Meta: Reserved metadata fieldCursor: Opaque pagination tokenMethods:
func (p *ListResourcesParams) GetProgressToken() any
func (p *ListResourcesParams) SetProgressToken(t any)Type alias for list resources requests.
type ListResourcesRequest = ServerRequest[*ListResourcesParams]Server's response to a list resources request.
type ListResourcesResult struct {
Meta `json:"_meta,omitempty"`
NextCursor string `json:"nextCursor,omitempty"`
Resources []*Resource `json:"resources"`
}Fields:
Meta: Reserved metadata fieldNextCursor: Pagination token for next pageResources: List of available resourcesParameters for listing resource templates.
type ListResourceTemplatesParams struct {
Meta `json:"_meta,omitempty"`
Cursor string `json:"cursor,omitempty"`
}Fields:
Meta: Reserved metadata fieldCursor: Opaque pagination tokenMethods:
func (p *ListResourceTemplatesParams) GetProgressToken() any
func (p *ListResourceTemplatesParams) SetProgressToken(t any)Type alias for list resource templates requests.
type ListResourceTemplatesRequest = ServerRequest[*ListResourceTemplatesParams]Server's response to a list resource templates request.
type ListResourceTemplatesResult struct {
Meta `json:"_meta,omitempty"`
NextCursor string `json:"nextCursor,omitempty"`
ResourceTemplates []*ResourceTemplate `json:"resourceTemplates"`
}Fields:
Meta: Reserved metadata fieldNextCursor: Pagination token for next pageResourceTemplates: List of available resource templatesParameters for subscribing to resource updates.
type SubscribeParams struct {
Meta `json:"_meta,omitempty"`
URI string `json:"uri"`
}Fields:
Meta: Reserved metadata fieldURI: URI of the resource to subscribe toType alias for subscribe requests.
type SubscribeRequest = ServerRequest[*SubscribeParams]Parameters for unsubscribing from resource updates.
type UnsubscribeParams struct {
Meta `json:"_meta,omitempty"`
URI string `json:"uri"`
}Fields:
Meta: Reserved metadata fieldURI: URI of the resource to unsubscribe fromType alias for unsubscribe requests.
type UnsubscribeRequest = ServerRequest[*UnsubscribeParams]Parameters for resource updated notifications.
type ResourceUpdatedNotificationParams struct {
Meta `json:"_meta,omitempty"`
URI string `json:"uri"`
}Fields:
Meta: Reserved metadata fieldURI: URI of the resource that has been updatedType alias for resource updated notification requests.
type ResourceUpdatedNotificationRequest = ClientRequest[*ResourceUpdatedNotificationParams]Parameters for resource list changed notifications.
type ResourceListChangedParams struct {
Meta `json:"_meta,omitempty"`
}Methods:
func (p *ResourceListChangedParams) GetProgressToken() any
func (p *ResourceListChangedParams) SetProgressToken(t any)Type alias for resource list changed notification requests.
type ResourceListChangedRequest = ClientRequest[*ResourceListChangedParams]Parameters for requesting message creation from an LLM.
type CreateMessageParams struct {
Meta `json:"_meta,omitempty"`
IncludeContext string `json:"includeContext,omitempty"`
MaxTokens int64 `json:"maxTokens"`
Messages []*SamplingMessage `json:"messages"`
Metadata any `json:"metadata,omitempty"`
ModelPreferences *ModelPreferences `json:"modelPreferences,omitempty"`
StopSequences []string `json:"stopSequences,omitempty"`
SystemPrompt string `json:"systemPrompt,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
}Fields:
Meta: Reserved metadata fieldIncludeContext: Request to include context from MCP serversMaxTokens: Maximum tokens to sampleMessages: List of messages for the conversationMetadata: Optional metadata to pass to LLM providerModelPreferences: Server's model selection preferencesStopSequences: Stop sequences for generationSystemPrompt: Optional system prompt for samplingTemperature: Temperature for samplingMethods:
func (p *CreateMessageParams) GetProgressToken() any
func (p *CreateMessageParams) SetProgressToken(t any)Type alias for create message requests.
type CreateMessageRequest = ClientRequest[*CreateMessageParams]Client's response to a create message request.
type CreateMessageResult struct {
Meta `json:"_meta,omitempty"`
Content Content `json:"content"`
Model string `json:"model"`
Role Role `json:"role"`
StopReason string `json:"stopReason,omitempty"`
}Fields:
Meta: Reserved metadata fieldContent: Message content from the LLMModel: Name of the model that generated the messageRole: Role of the message senderStopReason: Why sampling stopped, if knownMethods:
func (r *CreateMessageResult) UnmarshalJSON(data []byte) errorParameters for elicitation requests (asking user for information).
type ElicitParams struct {
Meta `json:"_meta,omitempty"`
Message string `json:"message"`
RequestedSchema any `json:"requestedSchema"`
}Fields:
Meta: Reserved metadata fieldMessage: Message to present to the userRequestedSchema: JSON schema object defining requested schemaMethods:
func (p *ElicitParams) GetProgressToken() any
func (p *ElicitParams) SetProgressToken(t any)Type alias for elicitation requests.
type ElicitRequest = ClientRequest[*ElicitParams]Client's response to an elicitation request.
type ElicitResult struct {
Meta `json:"_meta,omitempty"`
Action string `json:"action"`
Content map[string]any `json:"content,omitempty"`
}Fields:
Meta: Reserved metadata fieldAction: User action ("accept", "decline", or "cancel")Content: Submitted form data (only present when action is "accept")Parameters for listing client roots.
type ListRootsParams struct {
Meta `json:"_meta,omitempty"`
}Methods:
func (p *ListRootsParams) GetProgressToken() any
func (p *ListRootsParams) SetProgressToken(t any)Type alias for list roots requests.
type ListRootsRequest = ClientRequest[*ListRootsParams]Client's response to a list roots request.
type ListRootsResult struct {
Meta `json:"_meta,omitempty"`
Roots []*Root `json:"roots"`
}Fields:
Meta: Reserved metadata fieldRoots: List of client rootsParameters for roots list changed notifications.
type RootsListChangedParams struct {
Meta `json:"_meta,omitempty"`
}Methods:
func (p *RootsListChangedParams) GetProgressToken() any
func (p *RootsListChangedParams) SetProgressToken(t any)Type alias for roots list changed notification requests.
type RootsListChangedRequest = ServerRequest[*RootsListChangedParams]Parameters for completion requests.
type CompleteParams struct {
Meta `json:"_meta,omitempty"`
Argument CompleteParamsArgument `json:"argument"`
Context *CompleteContext `json:"context,omitempty"`
Ref *CompleteReference `json:"ref"`
}Fields:
Meta: Reserved metadata fieldArgument: The argument's informationContext: Optional completion contextRef: The completion referenceArgument information for completion requests.
type CompleteParamsArgument struct {
Name string `json:"name"`
Value string `json:"value"`
}Fields:
Name: Name of the argumentValue: Value for completion matchingType alias for completion requests.
type CompleteRequest = ServerRequest[*CompleteParams]Server's response to a completion request.
type CompleteResult struct {
Meta `json:"_meta,omitempty"`
Completion CompletionResultDetails `json:"completion"`
}Fields:
Meta: Reserved metadata fieldCompletion: Completion detailsParameters for logging messages.
type LoggingMessageParams struct {
Meta `json:"_meta,omitempty"`
Data any `json:"data"`
Level LoggingLevel `json:"level"`
Logger string `json:"logger,omitempty"`
}Fields:
Meta: Reserved metadata fieldData: Data to be loggedLevel: Severity of the log messageLogger: Optional name of the loggerMethods:
func (p *LoggingMessageParams) GetProgressToken() any
func (p *LoggingMessageParams) SetProgressToken(t any)Type alias for logging message requests.
type LoggingMessageRequest = ClientRequest[*LoggingMessageParams]Parameters for setting logging level.
type SetLoggingLevelParams struct {
Meta `json:"_meta,omitempty"`
Level LoggingLevel `json:"level"`
}Fields:
Meta: Reserved metadata fieldLevel: The logging level client wants to receiveMethods:
func (p *SetLoggingLevelParams) GetProgressToken() any
func (p *SetLoggingLevelParams) SetProgressToken(t any)Type alias for progress notifications from server to client.
type ProgressNotificationClientRequest = ClientRequest[*ProgressNotificationParams]Type alias for progress notifications from client to server.
type ProgressNotificationServerRequest = ServerRequest[*ProgressNotificationParams]Parameters for initialization requests.
type InitializeParams struct {
Meta `json:"_meta,omitempty"`
Capabilities *ClientCapabilities `json:"capabilities"`
ClientInfo *Implementation `json:"clientInfo"`
ProtocolVersion string `json:"protocolVersion"`
}Fields:
Meta: Reserved metadata fieldCapabilities: Client capabilitiesClientInfo: Client implementation informationProtocolVersion: Latest MCP version the client supportsMethods:
func (p *InitializeParams) GetProgressToken() any
func (p *InitializeParams) SetProgressToken(t any)Type alias for initialize requests.
type InitializeRequest = ClientRequest[*InitializeParams]Server's response after initialization.
type InitializeResult struct {
Meta `json:"_meta,omitempty"`
Capabilities *ServerCapabilities `json:"capabilities"`
Instructions string `json:"instructions,omitempty"`
ProtocolVersion string `json:"protocolVersion"`
ServerInfo *Implementation `json:"serverInfo"`
}Fields:
Meta: Reserved metadata fieldCapabilities: Server capabilitiesInstructions: Instructions for using the serverProtocolVersion: MCP version the server wants to useServerInfo: Server implementation informationParameters for initialized notifications.
type InitializedParams struct {
Meta `json:"_meta,omitempty"`
}Methods:
func (p *InitializedParams) GetProgressToken() any
func (p *InitializedParams) SetProgressToken(t any)Type alias for initialized notification requests.
type InitializedRequest = ServerRequest[*InitializedParams]Parameters for ping requests.
type PingParams struct {
Meta `json:"_meta,omitempty"`
}Methods:
func (p *PingParams) GetProgressToken() any
func (p *PingParams) SetProgressToken(t any)Parameters for cancellation notifications.
type CancelledParams struct {
Meta `json:"_meta,omitempty"`
Reason string `json:"reason,omitempty"`
RequestID any `json:"requestId"`
}Fields:
Meta: Reserved metadata fieldReason: Optional cancellation reasonRequestID: ID of the request to cancelMethods:
func (p *CancelledParams) GetProgressToken() any
func (p *CancelledParams) SetProgressToken(t any)